Skip to content

Commit e2db6a1

Browse files
vrutkovswangke19
andauthored
Apply suggestion from @wangke19
Co-authored-by: Ke Wang <kewang@redhat.com>
1 parent 096e30f commit e2db6a1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/operator/nodekubeconfigcontroller/nodekubeconfigcontroller.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,14 @@ func ensureNodeKubeconfigs(ctx context.Context, client coreclientv1.CoreV1Interf
154154
}
155155
requiredSecret.Annotations[annotations.OpenShiftComponent] = "kube-apiserver"
156156
// Copy not-before/not-after annotations from systemAdminClientCert
157-
if len(systemAdminCredsSecret.Annotations[certrotation.CertificateNotBeforeAnnotation]) > 0 {
158-
requiredSecret.Annotations[certrotation.CertificateNotBeforeAnnotation] = systemAdminCredsSecret.Annotations[certrotation.CertificateNotBeforeAnnotation]
157+
if systemAdminCredsSecret.Annotations != nil {
158+
if val, ok := systemAdminCredsSecret.Annotations[certrotation.CertificateNotBeforeAnnotation]; ok && len(val) > 0 {
159+
requiredSecret.Annotations[certrotation.CertificateNotBeforeAnnotation] = val
159160
}
160-
if len(systemAdminCredsSecret.Annotations[certrotation.CertificateNotAfterAnnotation]) > 0 {
161-
requiredSecret.Annotations[certrotation.CertificateNotAfterAnnotation] = systemAdminCredsSecret.Annotations[certrotation.CertificateNotAfterAnnotation]
161+
if val, ok := systemAdminCredsSecret.Annotations[certrotation.CertificateNotAfterAnnotation]; ok && len(val) > 0 {
162+
requiredSecret.Annotations[certrotation.CertificateNotAfterAnnotation] = val
162163
}
164+
}
163165

164166
_, _, err = resourceapply.ApplySecret(ctx, client, recorder, requiredSecret)
165167
if err != nil {

0 commit comments

Comments
 (0)