@@ -231,7 +231,7 @@ func (impl *GitOpsConfigServiceImpl) CreateGitOpsConfig(ctx context.Context, req
231
231
if err != nil {
232
232
return nil , err
233
233
}
234
- secret , err := impl .K8sUtil .GetSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , GitOpsSecretName , client )
234
+ secret , err := impl .K8sUtil .GetSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , impl . aCDAuthConfig . GitOpsSecretName , client )
235
235
statusError , _ := err .(* errors.StatusError )
236
236
if err != nil && statusError .Status ().Code != http .StatusNotFound {
237
237
impl .logger .Errorw ("secret not found" , "err" , err )
@@ -241,7 +241,7 @@ func (impl *GitOpsConfigServiceImpl) CreateGitOpsConfig(ctx context.Context, req
241
241
data ["username" ] = []byte (request .Username )
242
242
data ["password" ] = []byte (request .Token )
243
243
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 )
245
245
if err != nil {
246
246
impl .logger .Errorw ("err on creating secret" , "err" , err )
247
247
return nil , err
@@ -254,7 +254,7 @@ func (impl *GitOpsConfigServiceImpl) CreateGitOpsConfig(ctx context.Context, req
254
254
retryCount := 0
255
255
for ! operationComplete && retryCount < 3 {
256
256
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 )
258
258
if err != nil {
259
259
impl .logger .Errorw ("secret not found" , "err" , err )
260
260
return nil , err
@@ -302,7 +302,8 @@ func (impl *GitOpsConfigServiceImpl) CreateGitOpsConfig(ctx context.Context, req
302
302
if err != nil {
303
303
return nil , err
304
304
}
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 )
306
307
data := cm .Data
307
308
if data == nil {
308
309
data = make (map [string ]string , 0 )
@@ -432,7 +433,7 @@ func (impl *GitOpsConfigServiceImpl) UpdateGitOpsConfig(request *bean2.GitOpsCon
432
433
return err
433
434
}
434
435
435
- secret , err := impl .K8sUtil .GetSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , GitOpsSecretName , client )
436
+ secret , err := impl .K8sUtil .GetSecret (impl .aCDAuthConfig .ACDConfigMapNamespace , impl . aCDAuthConfig . GitOpsSecretName , client )
436
437
statusError , _ := err .(* errors.StatusError )
437
438
if err != nil && statusError .Status ().Code != http .StatusNotFound {
438
439
impl .logger .Errorw ("secret not found" , "err" , err )
@@ -442,7 +443,7 @@ func (impl *GitOpsConfigServiceImpl) UpdateGitOpsConfig(request *bean2.GitOpsCon
442
443
data ["username" ] = []byte (request .Username )
443
444
data ["password" ] = []byte (request .Token )
444
445
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 )
446
447
if err != nil {
447
448
impl .logger .Errorw ("err on creating secret" , "err" , err )
448
449
return err
@@ -455,7 +456,7 @@ func (impl *GitOpsConfigServiceImpl) UpdateGitOpsConfig(request *bean2.GitOpsCon
455
456
retryCount := 0
456
457
for ! operationComplete && retryCount < 3 {
457
458
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 )
459
460
if err != nil {
460
461
impl .logger .Errorw ("secret not found" , "err" , err )
461
462
return err
@@ -503,7 +504,8 @@ func (impl *GitOpsConfigServiceImpl) UpdateGitOpsConfig(request *bean2.GitOpsCon
503
504
if err != nil {
504
505
return err
505
506
}
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 )
507
509
data := cm .Data
508
510
data ["repository.credentials" ] = updatedData ["repository.credentials" ]
509
511
cm .Data = data
@@ -605,7 +607,7 @@ func (impl *GitOpsConfigServiceImpl) GetGitOpsConfigByProvider(provider string)
605
607
return config , err
606
608
}
607
609
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 {
609
611
var newRepositories []* RepositoryCredentialsDto
610
612
var existingRepositories []* RepositoryCredentialsDto
611
613
repoStr := data ["repository.credentials" ]
@@ -621,7 +623,7 @@ func (impl *GitOpsConfigServiceImpl) updateData(data map[string]string, request
621
623
}
622
624
623
625
for _ , item := range existingRepositories {
624
- if item .Url != existingHost {
626
+ if item .Url != currentHost {
625
627
newRepositories = append (newRepositories , item )
626
628
}
627
629
}
0 commit comments