Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- (Bugfix) Fix AnyPB Parsing in Meta Service
- (Feature) Add Arch Tolerations
- (Bugfix) Enable Platform Operator on EE Chart
- (Feature) Improve GRPC JSON Handling

## [1.3.0](https://github.com/arangodb/kube-arangodb/tree/1.3.0) (2025-08-01)
- (Feature) (Platform) Storage Debug
Expand Down
2 changes: 1 addition & 1 deletion integrations/inventory/v1/definition/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (s *Inventory) JSON() ([]byte, error) {
return []byte("{}"), nil
}

return ugrpc.Marshal(s)
return ugrpc.Marshal(s, ugrpc.WithUseProtoNames(true))
}

func NewArangoDBConfiguration(spec api.DeploymentSpec, status api.DeploymentStatus) *ArangoDBConfiguration {
Expand Down
1 change: 1 addition & 0 deletions integrations/inventory/v1/definition/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func Test_State_Marshal(t *testing.T) {

data, err := ugrpc.Marshal(&s, func(in *protojson.MarshalOptions) {
in.EmitDefaultValues = true
in.UseProtoNames = false
})
require.NoError(t, err)

Expand Down
5 changes: 2 additions & 3 deletions pkg/deployment/resources/config_map_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,8 @@ func (r *Resources) ensureGatewayConfig(ctx context.Context, cachedStatus inspec
},
Marshaller: ugrpc.Marshal[*pbInventoryV1.Inventory],
Options: []util.Mod[protojson.MarshalOptions]{
func(in *protojson.MarshalOptions) {
in.EmitDefaultValues = true
},
ugrpc.WithUseProtoNames(true),
ugrpc.WithEmitDefaultValues(true),
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/resources/gateway/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func NodeDynamicConfig(cluster, id string, cds, lds *DynamicConfig) ([]byte, str
b.DynamicResources.LdsConfig = v.AsConfigSource()
}

data, err := ugrpc.MarshalYAML(&b)
data, err := ugrpc.MarshalYAML(&b, ugrpc.WithUseProtoNames(true))
if err != nil {
return nil, "", nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/deployment/resources/gateway/gateway_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (c Config) RenderYAML() ([]byte, string, *pbEnvoyBootstrapV3.Bootstrap, err
return nil, "", nil, err
}

data, err := ugrpc.MarshalYAML(cfg)
data, err := ugrpc.MarshalYAML(cfg, ugrpc.WithUseProtoNames(true))
if err != nil {
return nil, "", nil, err
}
Expand All @@ -90,7 +90,7 @@ func (c Config) RenderCDSYAML() ([]byte, string, *discoveryApi.DiscoveryResponse
return nil, "", nil, err
}

data, err := ugrpc.MarshalYAML(cfg)
data, err := ugrpc.MarshalYAML(cfg, ugrpc.WithUseProtoNames(true))
if err != nil {
return nil, "", nil, err
}
Expand All @@ -103,7 +103,7 @@ func (c Config) RenderLDSYAML() ([]byte, string, *discoveryApi.DiscoveryResponse
return nil, "", nil, err
}

data, err := ugrpc.MarshalYAML(cfg)
data, err := ugrpc.MarshalYAML(cfg, ugrpc.WithUseProtoNames(true))
if err != nil {
return nil, "", nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/grpc/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func Get[T proto.Message](ctx context.Context, client operatorHTTP.HTTPClient, u
}

func Post[IN, T proto.Message](ctx context.Context, client operatorHTTP.HTTPClient, in IN, url string, mods ...util.Mod[goHttp.Request]) HTTPResponse[T] {
data, err := Marshal(in)
data, err := Marshal(in, WithUseProtoNames(true))
if err != nil {
return httpErrorResponse[T]{err: err}
}
Expand Down
16 changes: 13 additions & 3 deletions pkg/util/grpc/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,20 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util"
)

func Marshal[T proto.Message](in T, opts ...util.Mod[protojson.MarshalOptions]) ([]byte, error) {
options := protojson.MarshalOptions{
UseProtoNames: true,
func WithUseProtoNames(value bool) util.Mod[protojson.MarshalOptions] {
return func(in *protojson.MarshalOptions) {
in.UseProtoNames = value
}
}

func WithEmitDefaultValues(value bool) util.Mod[protojson.MarshalOptions] {
return func(in *protojson.MarshalOptions) {
in.EmitDefaultValues = value
}
}

func Marshal[T proto.Message](in T, opts ...util.Mod[protojson.MarshalOptions]) ([]byte, error) {
options := protojson.MarshalOptions{}
Comment on lines +43 to +44
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the default UseProtoNames: true setting is a breaking change. Existing code that relies on this default behavior will now produce different JSON output. Consider maintaining backward compatibility by keeping the default or adding a major version bump.

Suggested change
func Marshal[T proto.Message](in T, opts ...util.Mod[protojson.MarshalOptions]) ([]byte, error) {
options := protojson.MarshalOptions{}
options := protojson.MarshalOptions{
UseProtoNames: true,
}

Copilot uses AI. Check for mistakes.


util.ApplyMods(&options, opts...)

Expand Down