@@ -231,7 +231,7 @@ func (impl *GitOpsConfigServiceImpl) CreateGitOpsConfig(ctx context.Context, req
231231 if err != nil {
232232 return nil , err
233233 }
234- secret , err := impl .K8sUtil .GetSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , GitOpsSecretName , client )
234+ secret , err := impl .K8sUtil .GetSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , impl . aCDAuthConfig . GitOpsSecretName , client )
235235 statusError , _ := err .(* errors.StatusError )
236236 if err != nil && statusError .Status ().Code != http .StatusNotFound {
237237 impl .logger .Errorw ("secret not found" , "err" , err )
@@ -241,7 +241,7 @@ func (impl *GitOpsConfigServiceImpl) CreateGitOpsConfig(ctx context.Context, req
241241 data ["username" ] = []byte (request .Username )
242242 data ["password" ] = []byte (request .Token )
243243 if secret == nil {
244- secret , err = impl .K8sUtil .CreateSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , data , GitOpsSecretName , "" , client , nil , nil )
244+ secret , err = impl .K8sUtil .CreateSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , data , impl . aCDAuthConfig . GitOpsSecretName , "" , client , nil , nil )
245245 if err != nil {
246246 impl .logger .Errorw ("err on creating secret" , "err" , err )
247247 return nil , err
@@ -254,7 +254,7 @@ func (impl *GitOpsConfigServiceImpl) CreateGitOpsConfig(ctx context.Context, req
254254 retryCount := 0
255255 for ! operationComplete && retryCount < 3 {
256256 retryCount = retryCount + 1
257- secret , err := impl .K8sUtil .GetSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , GitOpsSecretName , client )
257+ secret , err := impl .K8sUtil .GetSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , impl . aCDAuthConfig . GitOpsSecretName , client )
258258 if err != nil {
259259 impl .logger .Errorw ("secret not found" , "err" , err )
260260 return nil , err
@@ -302,7 +302,8 @@ func (impl *GitOpsConfigServiceImpl) CreateGitOpsConfig(ctx context.Context, req
302302 if err != nil {
303303 return nil , err
304304 }
305- updatedData := impl .updateData (cm .Data , request , GitOpsSecretName , existingModel .Host )
305+ currentHost := request .Host
306+ updatedData := impl .updateData (cm .Data , request , impl .aCDAuthConfig .GitOpsSecretName , currentHost )
306307 data := cm .Data
307308 if data == nil {
308309 data = make (map [string ]string , 0 )
@@ -432,7 +433,7 @@ func (impl *GitOpsConfigServiceImpl) UpdateGitOpsConfig(request *bean2.GitOpsCon
432433 return err
433434 }
434435
435- secret , err := impl .K8sUtil .GetSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , GitOpsSecretName , client )
436+ secret , err := impl .K8sUtil .GetSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , impl . aCDAuthConfig . GitOpsSecretName , client )
436437 statusError , _ := err .(* errors.StatusError )
437438 if err != nil && statusError .Status ().Code != http .StatusNotFound {
438439 impl .logger .Errorw ("secret not found" , "err" , err )
@@ -442,7 +443,7 @@ func (impl *GitOpsConfigServiceImpl) UpdateGitOpsConfig(request *bean2.GitOpsCon
442443 data ["username" ] = []byte (request .Username )
443444 data ["password" ] = []byte (request .Token )
444445 if secret == nil {
445- secret , err = impl .K8sUtil .CreateSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , data , GitOpsSecretName , "" , client , nil , nil )
446+ secret , err = impl .K8sUtil .CreateSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , data , impl . aCDAuthConfig . GitOpsSecretName , "" , client , nil , nil )
446447 if err != nil {
447448 impl .logger .Errorw ("err on creating secret" , "err" , err )
448449 return err
@@ -455,7 +456,7 @@ func (impl *GitOpsConfigServiceImpl) UpdateGitOpsConfig(request *bean2.GitOpsCon
455456 retryCount := 0
456457 for ! operationComplete && retryCount < 3 {
457458 retryCount = retryCount + 1
458- secret , err := impl .K8sUtil .GetSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , GitOpsSecretName , client )
459+ secret , err := impl .K8sUtil .GetSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , impl . aCDAuthConfig . GitOpsSecretName , client )
459460 if err != nil {
460461 impl .logger .Errorw ("secret not found" , "err" , err )
461462 return err
@@ -503,7 +504,8 @@ func (impl *GitOpsConfigServiceImpl) UpdateGitOpsConfig(request *bean2.GitOpsCon
503504 if err != nil {
504505 return err
505506 }
506- updatedData := impl .updateData (cm .Data , request , GitOpsSecretName , existingModel .Host )
507+ currentHost := request .Host
508+ updatedData := impl .updateData (cm .Data , request , impl .aCDAuthConfig .GitOpsSecretName , currentHost )
507509 data := cm .Data
508510 data ["repository.credentials" ] = updatedData ["repository.credentials" ]
509511 cm .Data = data
@@ -605,7 +607,7 @@ func (impl *GitOpsConfigServiceImpl) GetGitOpsConfigByProvider(provider string)
605607 return config , err
606608}
607609
608- func (impl * GitOpsConfigServiceImpl ) updateData (data map [string ]string , request * bean2.GitOpsConfigDto , secretName string , existingHost string ) map [string ]string {
610+ func (impl * GitOpsConfigServiceImpl ) updateData (data map [string ]string , request * bean2.GitOpsConfigDto , secretName string , currentHost string ) map [string ]string {
609611 var newRepositories []* RepositoryCredentialsDto
610612 var existingRepositories []* RepositoryCredentialsDto
611613 repoStr := data ["repository.credentials" ]
@@ -621,7 +623,7 @@ func (impl *GitOpsConfigServiceImpl) updateData(data map[string]string, request
621623 }
622624
623625 for _ , item := range existingRepositories {
624- if item .Url != existingHost {
626+ if item .Url != currentHost {
625627 newRepositories = append (newRepositories , item )
626628 }
627629 }
0 commit comments