@@ -46,8 +46,8 @@ import (
4646)
4747
4848type GitOpsConfigService interface {
49- ValidateAndCreateGitOpsConfig (config * bean2.GitOpsConfigDto ) (* bean2. GitOpsConfigDto , DetailedErrorGitOpsConfigResponse , error )
50- ValidateAndUpdateGitOpsConfig (config * bean2.GitOpsConfigDto ) (* bean2. GitOpsConfigDto , DetailedErrorGitOpsConfigResponse , error )
49+ ValidateAndCreateGitOpsConfig (config * bean2.GitOpsConfigDto ) (DetailedErrorGitOpsConfigResponse , error )
50+ ValidateAndUpdateGitOpsConfig (config * bean2.GitOpsConfigDto ) (DetailedErrorGitOpsConfigResponse , error )
5151 GitOpsValidateDryRun (config * bean2.GitOpsConfigDto ) DetailedErrorGitOpsConfigResponse
5252 CreateGitOpsConfig (config * bean2.GitOpsConfigDto ) (* bean2.GitOpsConfigDto , error )
5353 UpdateGitOpsConfig (config * bean2.GitOpsConfigDto ) error
@@ -80,7 +80,9 @@ type DetailedErrorGitOpsConfigResponse struct {
8080 SuccessfulStages []string `json:"successfulStages"`
8181 StageErrorMap map [string ]string `json:"stageErrorMap"`
8282 ValidatedOn time.Time `json:"validatedOn"`
83+ DeleteRepoFailed bool `json:"deleteRepoFailed"`
8384}
85+
8486type GitOpsConfigServiceImpl struct {
8587 randSource rand.Source
8688 logger * zap.SugaredLogger
@@ -110,29 +112,27 @@ func NewGitOpsConfigServiceImpl(Logger *zap.SugaredLogger, ciHandler pipeline.Ci
110112 }
111113}
112114
113- func (impl * GitOpsConfigServiceImpl ) ValidateAndCreateGitOpsConfig (config * bean2.GitOpsConfigDto ) (* bean2. GitOpsConfigDto , DetailedErrorGitOpsConfigResponse , error ) {
115+ func (impl * GitOpsConfigServiceImpl ) ValidateAndCreateGitOpsConfig (config * bean2.GitOpsConfigDto ) (DetailedErrorGitOpsConfigResponse , error ) {
114116 detailedErrorGitOpsConfigResponse := impl .GitOpsValidateDryRun (config )
115117 if len (detailedErrorGitOpsConfigResponse .StageErrorMap ) == 0 {
116- gitOpsConfig , err := impl .CreateGitOpsConfig (config )
118+ _ , err := impl .CreateGitOpsConfig (config )
117119 if err != nil {
118120 impl .logger .Errorw ("service err, SaveGitRepoConfig" , "err" , err , "payload" , config )
119- return gitOpsConfig , detailedErrorGitOpsConfigResponse , err
121+ return detailedErrorGitOpsConfigResponse , err
120122 }
121- return gitOpsConfig , detailedErrorGitOpsConfigResponse , nil
122123 }
123- return nil , detailedErrorGitOpsConfigResponse , nil
124+ return detailedErrorGitOpsConfigResponse , nil
124125}
125- func (impl * GitOpsConfigServiceImpl ) ValidateAndUpdateGitOpsConfig (config * bean2.GitOpsConfigDto ) (* bean2. GitOpsConfigDto , DetailedErrorGitOpsConfigResponse , error ) {
126+ func (impl * GitOpsConfigServiceImpl ) ValidateAndUpdateGitOpsConfig (config * bean2.GitOpsConfigDto ) (DetailedErrorGitOpsConfigResponse , error ) {
126127 detailedErrorGitOpsConfigResponse := impl .GitOpsValidateDryRun (config )
127128 if len (detailedErrorGitOpsConfigResponse .StageErrorMap ) == 0 {
128129 err := impl .UpdateGitOpsConfig (config )
129130 if err != nil {
130131 impl .logger .Errorw ("service err, UpdateGitOpsConfig" , "err" , err , "payload" , config )
131- return config , detailedErrorGitOpsConfigResponse , err
132+ return detailedErrorGitOpsConfigResponse , err
132133 }
133- return config , detailedErrorGitOpsConfigResponse , nil
134134 }
135- return nil , detailedErrorGitOpsConfigResponse , nil
135+ return detailedErrorGitOpsConfigResponse , nil
136136}
137137
138138func (impl * GitOpsConfigServiceImpl ) CreateGitOpsConfig (request * bean2.GitOpsConfigDto ) (* bean2.GitOpsConfigDto , error ) {
@@ -687,7 +687,9 @@ func (impl *GitOpsConfigServiceImpl) GitOpsValidateDryRun(config *bean2.GitOpsCo
687687 err = client .DeleteRepository (appName , config .Username , config .GitHubOrgId , config .AzureProjectName , repoOptions )
688688 if err != nil {
689689 impl .logger .Errorw ("error in deleting repo" , "err" , err )
690- detailedErrorGitOpsConfigActions .StageErrorMap [DeleteRepoStage ] = impl .extractErrorMessageByProvider (err , config .Provider )
690+ //here below the assignment of delete is removed for making this stage optional, and it's failure not preventing it from saving/updating gitOps config
691+ //detailedErrorGitOpsConfigActions.StageErrorMap[DeleteRepoStage] = impl.extractErrorMessageByProvider(err, config.Provider)
692+ detailedErrorGitOpsConfigActions .DeleteRepoFailed = true
691693 } else {
692694 detailedErrorGitOpsConfigActions .SuccessfulStages = append (detailedErrorGitOpsConfigActions .SuccessfulStages , DeleteRepoStage )
693695 }
@@ -731,5 +733,6 @@ func (impl *GitOpsConfigServiceImpl) convertDetailedErrorToResponse(detailedErro
731733 for stage , err := range detailedErrorGitOpsConfigActions .StageErrorMap {
732734 detailedErrorResponse .StageErrorMap [stage ] = err .Error ()
733735 }
736+ detailedErrorResponse .DeleteRepoFailed = detailedErrorGitOpsConfigActions .DeleteRepoFailed
734737 return detailedErrorResponse
735738}
0 commit comments