• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pomerium / pomerium / 25123230853

29 Apr 2026 05:14PM UTC coverage: 45.469% (-0.05%) from 45.514%
25123230853

push

github

web-flow
core/config: generate enums from protobuf (#6307)

## Summary
Use the protobuf enums directly instead of locally defined enums with
conversions. A special decode hook has been added that should preserve
any existing enum values. (case-insensitive, trims the common prefix,
etc) Going forward if we want a new enum, we can just add it to the
protobuf and the config code will be generated automatically.

## Related issues
-
[ENG-3949](https://linear.app/pomerium/issue/ENG-3949/coreconfig-implement-enum-support-for-code-generation)


## Checklist

- [x] reference any related issues
- [x] updated unit tests
- [x] add appropriate label (`enhancement`, `bug`, `breaking`,
`dependencies`, `ci`)
- [x] ready for review

119 of 210 new or added lines in 17 files covered. (56.67%)

20 existing lines in 7 files now uncovered.

35553 of 78192 relevant lines covered (45.47%)

114.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

46.81
/pkg/nullable/value.go
1
package nullable
2

3
import (
4
        "bytes"
5
        "encoding/json"
6
        "reflect"
7

8
        "gopkg.in/yaml.v3"
9
)
10

11
type Value[T any] struct {
12
        IsSet bool
13
        Value T
14
}
15

16
func NewValue[T any](isSet bool, value T) Value[T] {
5✔
17
        return Value[T]{IsSet: isSet, Value: value}
5✔
18
}
5✔
19

20
func From[T any](value T) Value[T] {
×
21
        return NewValue(true, value)
×
22
}
×
23

24
func FromPtr[T any](ptr *T) Value[T] {
1✔
25
        var def T
1✔
26
        if ptr == nil {
1✔
27
                return NewValue(false, def)
×
28
        }
×
29
        return NewValue(true, *ptr)
1✔
30
}
31

32
func (v Value[T]) Equal(other Value[T]) bool {
×
33
        return (!v.IsSet && !other.IsSet) || reflect.DeepEqual(v.Value, other.Value)
×
34
}
×
35

36
func (v *Value[T]) MarshalJSON() ([]byte, error) {
×
37
        if v.IsSet {
×
38
                return json.Marshal(v.Value)
×
39
        }
×
40
        return []byte("null"), nil
×
41
}
42

43
func (v Value[T]) MarshalYAML() (any, error) {
×
44
        if v.IsSet {
×
45
                return v.Value, nil
×
46
        }
×
47
        return nil, nil
×
48
}
49

NEW
50
func (v Value[T]) Ptr() *T {
×
NEW
51
        if v.IsSet {
×
NEW
52
                return new(v.Value)
×
NEW
53
        }
×
NEW
54
        return nil
×
55
}
56

57
func (v *Value[T]) UnmarshalJSON(data []byte) error {
2✔
58
        var def T
2✔
59
        if bytes.Equal(data, []byte("null")) {
3✔
60
                v.IsSet = false
1✔
61
                v.Value = def
1✔
62
                return nil
1✔
63
        }
1✔
64
        v.IsSet = true
1✔
65
        return json.Unmarshal(data, &v.Value)
1✔
66
}
67

68
func (v *Value[T]) UnmarshalYAML(value *yaml.Node) error {
1✔
69
        var ptr *T
1✔
70
        err := value.Decode(&ptr)
1✔
71
        if err != nil {
1✔
72
                return err
×
73
        }
×
74
        *v = FromPtr(ptr)
1✔
75
        return nil
1✔
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc