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

pomerium / pomerium / 25022422176

27 Apr 2026 10:14PM UTC coverage: 45.509% (-0.3%) from 45.773%
25022422176

push

github

web-flow
core/config: improve code generation (#6299)

## Summary
Update the code generator for protobuf -> config types so that it
handles more protobuf types. Also use a `nullable.Value[T]` instead of
`*T` to represent unset fields. Code still needs to be added to handle
protobuf enums, but that will be done in a subsequent PR, and after that
some of the existing configuration options could be ported over to the
generated code.

## Related issues
-
[ENG-3948](https://linear.app/pomerium/issue/ENG-3948/coreconfig-improve-code-generation-from-protobuf)


## Checklist

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

32 of 569 new or added lines in 6 files covered. (5.62%)

38 existing lines in 10 files now uncovered.

35645 of 78326 relevant lines covered (45.51%)

114.41 hits per line

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

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

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

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

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

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

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

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

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

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

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

NEW
50
func (v *Value[T]) UnmarshalJSON(data []byte) error {
×
NEW
51
        var def T
×
NEW
52
        if bytes.Equal(data, []byte("null")) {
×
NEW
53
                v.IsSet = false
×
NEW
54
                v.Value = def
×
NEW
55
        }
×
NEW
56
        v.IsSet = true
×
NEW
57
        return json.Unmarshal(data, &v.Value)
×
58
}
59

NEW
60
func (v *Value[T]) UnmarshalYAML(value *yaml.Node) error {
×
NEW
61
        var ptr *T
×
NEW
62
        err := value.Decode(&ptr)
×
NEW
63
        if err != nil {
×
NEW
64
                return err
×
NEW
65
        }
×
NEW
66
        *v = FromPtr(ptr)
×
NEW
67
        return nil
×
68
}
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