@@ -792,24 +792,23 @@ func setImageRegistry(ctx context.Context, tenantName string, req *models.ImageR
792
792
}
793
793
794
794
pullSecretName := fmt .Sprintf ("%s-regcred" , tenantName )
795
-
796
- instanceSecret := corev1.Secret {
797
- ObjectMeta : metav1.ObjectMeta {
798
- Name : pullSecretName ,
799
- Labels : map [string ]string {
800
- operator .TenantLabel : tenantName ,
801
- },
802
- },
803
- Data : map [string ][]byte {
804
- corev1 .DockerConfigJsonKey : []byte (string (imRegistryJSON )),
805
- },
806
- Type : corev1 .SecretTypeDockerConfigJson ,
795
+ secretCredentials := map [string ][]byte {
796
+ corev1 .DockerConfigJsonKey : []byte (string (imRegistryJSON )),
807
797
}
808
-
809
798
// Get or Create secret if it doesn't exist
810
- _ , err = clientset .Secrets (namespace ).Get (ctx , pullSecretName , metav1.GetOptions {})
799
+ currentSecret , err : = clientset .Secrets (namespace ).Get (ctx , pullSecretName , metav1.GetOptions {})
811
800
if err != nil {
812
801
if k8sErrors .IsNotFound (err ) {
802
+ instanceSecret := corev1.Secret {
803
+ ObjectMeta : metav1.ObjectMeta {
804
+ Name : pullSecretName ,
805
+ Labels : map [string ]string {
806
+ operator .TenantLabel : tenantName ,
807
+ },
808
+ },
809
+ Data : secretCredentials ,
810
+ Type : corev1 .SecretTypeDockerConfigJson ,
811
+ }
813
812
_ , err = clientset .Secrets (namespace ).Create (ctx , & instanceSecret , metav1.CreateOptions {})
814
813
if err != nil {
815
814
return "" , err
@@ -818,7 +817,8 @@ func setImageRegistry(ctx context.Context, tenantName string, req *models.ImageR
818
817
}
819
818
return "" , err
820
819
}
821
- _ , err = clientset .Secrets (namespace ).Update (ctx , & instanceSecret , metav1.UpdateOptions {})
820
+ currentSecret .Data = secretCredentials
821
+ _ , err = clientset .Secrets (namespace ).Update (ctx , currentSecret , metav1.UpdateOptions {})
822
822
if err != nil {
823
823
return "" , err
824
824
}
0 commit comments