File tree 6 files changed +25
-22
lines changed
6 files changed +25
-22
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
11
11
. "github.com/onsi/gomega"
12
12
"sigs.k8s.io/controller-runtime/pkg/log/zap"
13
13
14
+ "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers"
14
15
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/licensing/licensingfakes"
15
16
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/configfakes"
16
17
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/file"
@@ -80,17 +81,17 @@ func TestInitialize_Plus(t *testing.T) {
80
81
collectErr : nil ,
81
82
depCtx : dataplane.DeploymentContext {
82
83
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 ) ,
86
87
},
87
88
},
88
89
{
89
90
name : "collecting deployment context errors" ,
90
91
collectErr : errors .New ("collect error" ),
91
92
depCtx : dataplane.DeploymentContext {
92
93
Integration : "ngf" ,
93
- InstallationID : "install-id" ,
94
+ InstallationID : helpers . GetPointer ( "install-id" ) ,
94
95
},
95
96
},
96
97
}
Original file line number Diff line number Diff line change @@ -714,9 +714,9 @@ var _ = Describe("getDeploymentContext", func() {
714
714
It ("returns deployment context" , func () {
715
715
expDepCtx := dataplane.DeploymentContext {
716
716
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 ) ,
720
720
}
721
721
722
722
handler := newEventHandlerImpl (eventHandlerConfig {
Original file line number Diff line number Diff line change @@ -51,16 +51,16 @@ func NewDeploymentContextCollector(
51
51
func (c * DeploymentContextCollector ) Collect (ctx context.Context ) (dataplane.DeploymentContext , error ) {
52
52
depCtx := dataplane.DeploymentContext {
53
53
Integration : integrationID ,
54
- InstallationID : c .cfg .PodUID ,
54
+ InstallationID : & c .cfg .PodUID ,
55
55
}
56
56
57
57
clusterInfo , err := telemetry .CollectClusterInformation (ctx , c .cfg .K8sClientReader )
58
58
if err != nil {
59
59
return depCtx , fmt .Errorf ("error collecting cluster ID and cluster node count: %w" , err )
60
60
}
61
61
62
- depCtx .ClusterID = clusterInfo .ClusterID
63
- depCtx .ClusterNodeCount = clusterInfo .NodeCount
62
+ depCtx .ClusterID = & clusterInfo .ClusterID
63
+ depCtx .ClusterNodeCount = & clusterInfo .NodeCount
64
64
65
65
return depCtx , nil
66
66
}
Original file line number Diff line number Diff line change 9
9
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
10
10
"sigs.k8s.io/controller-runtime/pkg/client/fake"
11
11
12
+ "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers"
12
13
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/licensing"
13
14
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/dataplane"
14
15
)
@@ -37,9 +38,9 @@ var _ = Describe("DeploymentContextCollector", func() {
37
38
38
39
expCtx := dataplane.DeploymentContext {
39
40
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 ) ,
43
44
}
44
45
45
46
depCtx , err := collector .Collect (context .Background ())
@@ -55,7 +56,7 @@ var _ = Describe("DeploymentContextCollector", func() {
55
56
56
57
expCtx := dataplane.DeploymentContext {
57
58
Integration : "ngf" ,
58
- InstallationID : "pod-uid" ,
59
+ InstallationID : helpers . GetPointer ( "pod-uid" ) ,
59
60
}
60
61
61
62
depCtx , err := collector .Collect (context .Background ())
Original file line number Diff line number Diff line change 9
9
"k8s.io/apimachinery/pkg/types"
10
10
ctlrZap "sigs.k8s.io/controller-runtime/pkg/log/zap"
11
11
12
+ "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers"
12
13
ngfConfig "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/config"
13
14
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config"
14
15
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/file"
@@ -121,9 +122,9 @@ func TestGenerate(t *testing.T) {
121
122
},
122
123
DeploymentContext : dataplane.DeploymentContext {
123
124
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 ) ,
127
128
},
128
129
AuxiliarySecrets : map [graph.SecretFileType ][]byte {
129
130
graph .PlusReportJWTToken : []byte ("license" ),
Original file line number Diff line number Diff line change @@ -399,12 +399,12 @@ type Logging struct {
399
399
// DeploymentContext contains metadata about NGF and the cluster.
400
400
// This is JSON marshaled into a file created by the generator, hence the json tags.
401
401
type DeploymentContext struct {
402
- // Integration is "ngf".
403
- Integration string `json:"integration"`
404
402
// ClusterID is the ID of the kube-system namespace.
405
- ClusterID string `json:"cluster_id"`
403
+ ClusterID * string `json:"cluster_id,omitempty "`
406
404
// InstallationID is the ID of the NGF deployment.
407
- InstallationID string `json:"installation_id"`
405
+ InstallationID * string `json:"installation_id,omitempty "`
408
406
// 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"`
410
410
}
You can’t perform that action at this time.
0 commit comments