File tree Expand file tree Collapse file tree 6 files changed +25
-22
lines changed Expand file tree Collapse file tree 6 files changed +25
-22
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
1111 . "github.com/onsi/gomega"
1212 "sigs.k8s.io/controller-runtime/pkg/log/zap"
1313
14+ "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers"
1415 "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/licensing/licensingfakes"
1516 "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/configfakes"
1617 "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/file"
@@ -80,17 +81,17 @@ func TestInitialize_Plus(t *testing.T) {
8081 collectErr : nil ,
8182 depCtx : dataplane.DeploymentContext {
8283 Integration : "ngf" ,
83- ClusterID : "cluster-id" ,
84- InstallationID : "install-id" ,
85- ClusterNodeCount : 2 ,
84+ ClusterID : helpers . GetPointer ( "cluster-id" ) ,
85+ InstallationID : helpers . GetPointer ( "install-id" ) ,
86+ ClusterNodeCount : helpers . GetPointer ( 2 ) ,
8687 },
8788 },
8889 {
8990 name : "collecting deployment context errors" ,
9091 collectErr : errors .New ("collect error" ),
9192 depCtx : dataplane.DeploymentContext {
9293 Integration : "ngf" ,
93- InstallationID : "install-id" ,
94+ InstallationID : helpers . GetPointer ( "install-id" ) ,
9495 },
9596 },
9697 }
Original file line number Diff line number Diff line change @@ -714,9 +714,9 @@ var _ = Describe("getDeploymentContext", func() {
714714 It ("returns deployment context" , func () {
715715 expDepCtx := dataplane.DeploymentContext {
716716 Integration : "ngf" ,
717- ClusterID : "cluster-id" ,
718- InstallationID : "installation-id" ,
719- ClusterNodeCount : 1 ,
717+ ClusterID : helpers . GetPointer ( "cluster-id" ) ,
718+ InstallationID : helpers . GetPointer ( "installation-id" ) ,
719+ ClusterNodeCount : helpers . GetPointer ( 1 ) ,
720720 }
721721
722722 handler := newEventHandlerImpl (eventHandlerConfig {
Original file line number Diff line number Diff line change @@ -51,16 +51,16 @@ func NewDeploymentContextCollector(
5151func (c * DeploymentContextCollector ) Collect (ctx context.Context ) (dataplane.DeploymentContext , error ) {
5252 depCtx := dataplane.DeploymentContext {
5353 Integration : integrationID ,
54- InstallationID : c .cfg .PodUID ,
54+ InstallationID : & c .cfg .PodUID ,
5555 }
5656
5757 clusterInfo , err := telemetry .CollectClusterInformation (ctx , c .cfg .K8sClientReader )
5858 if err != nil {
5959 return depCtx , fmt .Errorf ("error collecting cluster ID and cluster node count: %w" , err )
6060 }
6161
62- depCtx .ClusterID = clusterInfo .ClusterID
63- depCtx .ClusterNodeCount = clusterInfo .NodeCount
62+ depCtx .ClusterID = & clusterInfo .ClusterID
63+ depCtx .ClusterNodeCount = & clusterInfo .NodeCount
6464
6565 return depCtx , nil
6666}
Original file line number Diff line number Diff line change 99 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1010 "sigs.k8s.io/controller-runtime/pkg/client/fake"
1111
12+ "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers"
1213 "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/licensing"
1314 "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/dataplane"
1415)
@@ -37,9 +38,9 @@ var _ = Describe("DeploymentContextCollector", func() {
3738
3839 expCtx := dataplane.DeploymentContext {
3940 Integration : "ngf" ,
40- ClusterID : clusterID ,
41- InstallationID : "pod-uid" ,
42- ClusterNodeCount : 1 ,
41+ ClusterID : & clusterID ,
42+ InstallationID : helpers . GetPointer ( "pod-uid" ) ,
43+ ClusterNodeCount : helpers . GetPointer ( 1 ) ,
4344 }
4445
4546 depCtx , err := collector .Collect (context .Background ())
@@ -55,7 +56,7 @@ var _ = Describe("DeploymentContextCollector", func() {
5556
5657 expCtx := dataplane.DeploymentContext {
5758 Integration : "ngf" ,
58- InstallationID : "pod-uid" ,
59+ InstallationID : helpers . GetPointer ( "pod-uid" ) ,
5960 }
6061
6162 depCtx , err := collector .Collect (context .Background ())
Original file line number Diff line number Diff line change 99 "k8s.io/apimachinery/pkg/types"
1010 ctlrZap "sigs.k8s.io/controller-runtime/pkg/log/zap"
1111
12+ "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers"
1213 ngfConfig "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/config"
1314 "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config"
1415 "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/file"
@@ -121,9 +122,9 @@ func TestGenerate(t *testing.T) {
121122 },
122123 DeploymentContext : dataplane.DeploymentContext {
123124 Integration : "ngf" ,
124- ClusterID : "test-uid" ,
125- InstallationID : "test-uid-replicaSet" ,
126- ClusterNodeCount : 1 ,
125+ ClusterID : helpers . GetPointer ( "test-uid" ) ,
126+ InstallationID : helpers . GetPointer ( "test-uid-replicaSet" ) ,
127+ ClusterNodeCount : helpers . GetPointer ( 1 ) ,
127128 },
128129 AuxiliarySecrets : map [graph.SecretFileType ][]byte {
129130 graph .PlusReportJWTToken : []byte ("license" ),
Original file line number Diff line number Diff line change @@ -399,12 +399,12 @@ type Logging struct {
399399// DeploymentContext contains metadata about NGF and the cluster.
400400// This is JSON marshaled into a file created by the generator, hence the json tags.
401401type DeploymentContext struct {
402- // Integration is "ngf".
403- Integration string `json:"integration"`
404402 // ClusterID is the ID of the kube-system namespace.
405- ClusterID string `json:"cluster_id"`
403+ ClusterID * string `json:"cluster_id,omitempty "`
406404 // InstallationID is the ID of the NGF deployment.
407- InstallationID string `json:"installation_id"`
405+ InstallationID * string `json:"installation_id,omitempty "`
408406 // ClusterNodeCount is the count of nodes in the cluster.
409- ClusterNodeCount int `json:"cluster_node_count"`
407+ ClusterNodeCount * int `json:"cluster_node_count,omitempty"`
408+ // Integration is "ngf".
409+ Integration string `json:"integration"`
410410}
You can’t perform that action at this time.
0 commit comments