Skip to content

Commit

Permalink
Use k8s ServiceAccount constants
Browse files Browse the repository at this point in the history
  • Loading branch information
SaaldjorMike committed Aug 5, 2024
1 parent da0c543 commit d6bfbfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions controllers/suite/clusters/humiocluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4105,7 +4105,7 @@ var _ = Describe("HumioCluster Controller", func() {
if volume.Name == serviceAccountSecretVolumeName {
secret, err := kubernetes.GetSecret(ctx, k8sClient, volume.Secret.SecretName, key.Namespace)
Expect(err).ShouldNot(HaveOccurred())
Expect(secret.ObjectMeta.Annotations["kubernetes.io/service-account.name"]).To(Equal(toCreate.Spec.InitServiceAccountName))
Expect(secret.ObjectMeta.Annotations[corev1.ServiceAccountNameKey]).To(Equal(toCreate.Spec.InitServiceAccountName))
}
}
}
Expand All @@ -4123,7 +4123,7 @@ var _ = Describe("HumioCluster Controller", func() {
if volume.Name == serviceAccountSecretVolumeName {
secret, err := kubernetes.GetSecret(ctx, k8sClient, volume.Secret.SecretName, key.Namespace)
Expect(err).ShouldNot(HaveOccurred())
Expect(secret.ObjectMeta.Annotations["kubernetes.io/service-account.name"]).To(Equal(toCreate.Spec.AuthServiceAccountName))
Expect(secret.ObjectMeta.Annotations[corev1.ServiceAccountNameKey]).To(Equal(toCreate.Spec.AuthServiceAccountName))
}
}
}
Expand Down Expand Up @@ -4163,7 +4163,7 @@ var _ = Describe("HumioCluster Controller", func() {
if volume.Name == serviceAccountSecretVolumeName {
secret, err := kubernetes.GetSecret(ctx, k8sClient, volume.Secret.SecretName, key.Namespace)
Expect(err).ShouldNot(HaveOccurred())
Expect(secret.ObjectMeta.Annotations["kubernetes.io/service-account.name"]).To(Equal(toCreate.Spec.InitServiceAccountName))
Expect(secret.ObjectMeta.Annotations[corev1.ServiceAccountNameKey]).To(Equal(toCreate.Spec.InitServiceAccountName))
}
}
}
Expand All @@ -4181,7 +4181,7 @@ var _ = Describe("HumioCluster Controller", func() {
if volume.Name == serviceAccountSecretVolumeName {
secret, err := kubernetes.GetSecret(ctx, k8sClient, volume.Secret.SecretName, key.Namespace)
Expect(err).ShouldNot(HaveOccurred())
Expect(secret.ObjectMeta.Annotations["kubernetes.io/service-account.name"]).To(Equal(toCreate.Spec.AuthServiceAccountName))
Expect(secret.ObjectMeta.Annotations[corev1.ServiceAccountNameKey]).To(Equal(toCreate.Spec.AuthServiceAccountName))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubernetes/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ func ConstructServiceAccountSecret(humioClusterName, humioClusterNamespace, secr
Name: fmt.Sprintf("%s-%s", secretName, RandomString()),
Namespace: humioClusterNamespace,
Labels: LabelsForSecret(humioClusterName, secretName, nil),
Annotations: map[string]string{"kubernetes.io/service-account.name": serviceAccountName},
Annotations: map[string]string{corev1.ServiceAccountNameKey: serviceAccountName},
},
Type: "kubernetes.io/service-account-token",
Type: corev1.SecretTypeServiceAccountToken,
}
}

Expand Down

0 comments on commit d6bfbfa

Please sign in to comment.