8000 rename deployment metadata to required fields · nginx/kubernetes-ingress@70a7645 · GitHub
[go: up one dir, main page]

Skip to content

Commit 70a7645

Browse files
committed
rename deployment metadata to required fields
1 parent 8246032 commit 70a7645

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

internal/common_cluster_info/common_cluster_info.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ func GetInstallationID(ctx context.Context, client kubernetes.Interface, podNSNa
6161
}
6262
}
6363

64-
// GetDeploymentName returns the name of the Deployment
65-
func GetDeploymentName(ctx context.Context, client kubernetes.Interface, podNSName types.NamespacedName) (string, error) {
64+
// GetInstallationName returns the name of the Deployment
65+
func GetInstallationName(ctx context.Context, client kubernetes.Interface, podNSName types.NamespacedName) (string, error) {
6666
pod, err := client.CoreV1().Pods(podNSName.Namespace).Get(ctx, podNSName.Name, metav1.GetOptions{})
6767
if err != nil {
6868
return "", err

internal/metadata/metadata.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ import (
1313

1414
// Labels contains the metadata information needed for reporting to Agent
1515
type Labels struct {
16-
ProductName string `json:"product_name"`
17-
ProductVersion string `json:"product_version"`
18-
ClusterID string `json:"cluster_id"`
19-
DeploymentName string `json:"deployment_name"`
20-
DeploymentID string `json:"deployment_id"`
21-
DeploymentNamespace string `json:"deployment_namespace"`
16+
ProductType string `json:"product-type"`
17+
ProductVersion string `json:"product-version"`
18+
ClusterID string `json:"cluster-id"`
19+
InstallationName string `json:"installation-name"`
20+
InstallationID string `json:"installation-id"`
21+
InstallationNamespace string `json:"installation-namespace"`
2222
}
2323

24-
func newMetadataInfo(deploymentNamespace, clusterID, deploymentID, productVersion, deploymentName string) *Labels {
24+
func newMetadataInfo(installationNamespace, clusterID, installationID, productVersion, installationName string) *Labels {
2525
return &Labels{
26-
ProductName: "nic",
27-
ProductVersion: productVersion,
28-
ClusterID: clusterID,
29-
DeploymentID: deploymentID,
30-
DeploymentName: deploymentName,
31-
DeploymentNamespace: deploymentNamespace,
26+
ProductType: "nic",
27+
ProductVersion: productVersion,
28+
ClusterID: clusterID,
29+
InstallationID: installationID,
30+
InstallationName: installationName,
31+
InstallationNamespace: installationNamespace,
3232
}
3333
}
3434

@@ -52,19 +52,19 @@ func NewMetadataReporter(client kubernetes.Interface, pod *api_v1.Pod, version s
5252

5353
// CollectAndWrite collects the metadata information and returns a Labels struct
5454
func (md *Metadata) CollectAndWrite(ctx context.Context) (*Labels, error) {
55-
deploymentNamespace := md.PodNSName.Namespace
55+
installationNamespace := md.PodNSName.Namespace
5656
clusterID, err := clusterInfo.GetClusterID(ctx, md.K8sClientReader)
5757
if err != nil {
5858
return nil, fmt.Errorf("error collecting ClusterID: %w", err)
5959< E30B div class="diff-text-inner"> }
60-
deploymentID, err := clusterInfo.GetInstallationID(ctx, md.K8sClientReader, md.PodNSName)
60+
installationID, err := clusterInfo.GetInstallationID(ctx, md.K8sClientReader, md.PodNSName)
6161
if err != nil {
6262
return nil, fmt.Errorf("error collecting InstallationID: %w", err)
6363
}
64-
deploymentName, err := clusterInfo.GetDeploymentName(ctx, md.K8sClientReader, md.PodNSName)
64+
installationName, err := clusterInfo.GetInstallationName(ctx, md.K8sClientReader, md.PodNSName)
6565
if err != nil {
66-
return nil, fmt.Errorf("error collecting DeploymentName: %w", err)
66+
return nil, fmt.Errorf("error collecting InstallationName: %w", err)
6767
}
68-
info := newMetadataInfo(deploymentNamespace, clusterID, deploymentID, md.NICVersion, deploymentName)
68+
info := newMetadataInfo(installationNamespace, clusterID, installationID, md.NICVersion, installationName)
6969
return info, nil
7070
}

internal/metadata/metadata_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ import (
1313

1414
func TestNewMetadataInfo(t *testing.T) {
1515
info := newMetadataInfo("nginx-ingress", "e3a5e702-65a7-a55f-753d78cd7ff7", "555-1222-4414test-11223355", "5.0.0", "my-release")
16-
if info.ProductName != "nic" {
17-
t.Errorf("ProductName = %q, want %q", info.ProductName, "nic")
16+
if info.ProductType != "nic" {
17+
t.Errorf("ProductName = %q, want %q", info.ProductType, "nic")
1818
}
19-
if info.DeploymentNamespace != "nginx-ingress" {
20-
t.Errorf("DeploymentNamespace = %q, want %q", info.DeploymentNamespace, "nginx-ingress")
19+
if info.InstallationNamespace != "nginx-ingress" {
20+
t.Errorf("DeploymentNamespace = %q, want %q", info.InstallationNamespace, "nginx-ingress")
2121
}
2222
if info.ClusterID != "e3a5e702-65a7-a55f-753d78cd7ff7" {
2323
t.Errorf("ClusterID = %q, want %q", info.ClusterID, "e3a5e702-65a7-a55f-753d78cd7ff7")
2424
}
25-
if info.DeploymentID != "555-1222-4414test-11223355" {
26-
t.Errorf("DeploymentID = %q, want %q", info.DeploymentID, "555-1222-4414test-11223355")
25+
if info.InstallationID != "555-1222-4414test-11223355" {
26+
t.Errorf("DeploymentID = %q, want %q", info.InstallationID, "555-1222-4414test-11223355")
2727
}
2828
if info.ProductVersion != "5.0.0" {
2929
t.Errorf("ProductVersion = %q, want %q", info.ProductVersion, "5.0.0")
3030
}
31-
if info.DeploymentName != "my-release" {
32-
t.Errorf("DeploymentName = %q, want %q", info.DeploymentName, "my-release")
31+
if info.InstallationName != "my-release" {
32+
t.Errorf("DeploymentName = %q, want %q", info.InstallationName, "my-release")
3333
}
3434
}
3535

@@ -75,8 +75,8 @@ func TestCollectAndWrite(t *testing.T) {
7575
if err != nil {
7676
t.Fatalf("CollectAndWrite() error = %v", err)
7777
}
78-
if got, want := info.ProductName, "nic"; got != want {
79-
t.Errorf("ProductName = %q, want %q", got, want)
78+
if got, want := info.ProductType, "nic"; got != want {
79+
t.Errorf("ProductType = %q, want %q", got, want)
8080
}
8181
}
8282

internal/nginx/manager.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -631,12 +631,12 @@ func (lm *LocalManager) AgentStart(agentDone chan error, instanceGroup string) {
631631
nl.Fatalf(lm.logger, "Failed to start NGINX Agent: %v", err)
632632
}
633633
labels := []string{
634-
fmt.Sprintf("product_name=%s", metadataInfo.ProductName),
635-
fmt.Sprintf("product_version=%s", metadataInfo.ProductVersion),
636-
fmt.Sprintf("cluster_id=%s", metadataInfo.ClusterID),
637-
fmt.Sprintf("deployment_name=%s", metadataInfo.DeploymentName),
638-
fmt.Sprintf("deployment_id=%s", metadataInfo.DeploymentID),
639-
fmt.Sprintf("deployment_namespace=%s", metadataInfo.DeploymentNamespace),
634+
fmt.Sprintf("product-type=%s", metadataInfo.ProductType),
635+
fmt.Sprintf("product-version=%s", metadataInfo.ProductVersion),
636+
fmt.Sprintf("cluster-id=%s", metadataInfo.ClusterID),
637+
fmt.Sprintf("installation-name=%s", metadataInfo.InstallationName),
638+
fmt.Sprintf("installation-id=%s", metadataInfo.InstallationID),
639+
fmt.Sprintf("installation-namespace=%s", metadataInfo.InstallationNamespace),
640640
}
641641
metadataLabels := "--labels=" + strings.Join(labels, ",")
642642
args = append(args, metadataLabels)

0 commit comments

Comments
 (0)
0