Skip to content

Commit a1e9182

Browse files
authored
[Feature] Emit Default values in Inventory (#1849)
1 parent 38532db commit a1e9182

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- (Bugfix) Propagate Gateway Idle Timeout
1111
- (Feature) Update Authz V1 Definitions
1212
- (Feature) (Platform) Add Sharding to the Inventory Endpoint
13+
- (Feature) Emit Default values in Inventory
1314

1415
## [1.2.46](https://github.com/arangodb/kube-arangodb/tree/1.2.46) (2025-02-24)
1516
- (Bugfix) Clean Phase change properly during upgrade

integrations/inventory/v1/definition/inventory_test.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"testing"
2626

2727
"github.com/stretchr/testify/require"
28+
"google.golang.org/protobuf/encoding/protojson"
2829

2930
ugrpc "github.com/arangodb/kube-arangodb/pkg/util/grpc"
3031
)
@@ -35,13 +36,16 @@ func Test_State_Marshal(t *testing.T) {
3536
Hash: "xyz",
3637
},
3738
Arangodb: &ArangoDBConfiguration{
38-
Mode: ArangoDBMode_Cluster,
39-
Edition: ArangoDBEdition_Enterprise,
40-
Version: "1.2.3",
39+
Mode: ArangoDBMode_Cluster,
40+
Edition: ArangoDBEdition_Enterprise,
41+
Version: "1.2.3",
42+
Sharding: ArangoDBSharding_Sharded,
4143
},
4244
}
4345

44-
data, err := ugrpc.Marshal(&s)
46+
data, err := ugrpc.Marshal(&s, func(in *protojson.MarshalOptions) {
47+
in.EmitDefaultValues = true
48+
})
4549
require.NoError(t, err)
4650

4751
t.Log(string(data))

pkg/deployment/resources/config_map_gateway.go

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"path"
2727
"path/filepath"
2828

29+
"google.golang.org/protobuf/encoding/protojson"
2930
core "k8s.io/api/core/v1"
3031
kerrors "k8s.io/apimachinery/pkg/api/errors"
3132
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -75,6 +76,11 @@ func (r *Resources) ensureGatewayConfig(ctx context.Context, cachedStatus inspec
7576
Arangodb: pbInventoryV1.NewArangoDBConfiguration(r.context.GetSpec(), r.context.GetStatus()),
7677
},
7778
Marshaller: ugrpc.Marshal[*pbInventoryV1.Inventory],
79+
Options: []util.Mod[protojson.MarshalOptions]{
80+
func(in *protojson.MarshalOptions) {
81+
in.EmitDefaultValues = true
82+
},
83+
},
7884
},
7985
}
8086

pkg/deployment/resources/gateway/gateway_config_destination_static.go

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ type ConfigDestinationStatic[T any] struct {
4242
Response T `json:"response,omitempty"`
4343

4444
Marshaller ConfigDestinationStaticMarshaller[T] `json:"-"`
45+
46+
Options []util.Mod[protojson.MarshalOptions]
4547
}
4648

4749
func (c *ConfigDestinationStatic[T]) Validate() error {

0 commit comments

Comments
 (0)