@@ -19,7 +19,6 @@ import (
19
19
20
20
//"github.com/xanzy/go-gitlab"
21
21
"net/http"
22
- "regexp"
23
22
)
24
23
25
24
type InstalledAppGitOpsService interface {
@@ -47,18 +46,6 @@ func (impl *FullModeDeploymentServiceImpl) GitOpsOperations(manifestResponse *be
47
46
impl .Logger .Errorw ("Error in pushing chart to git" , "err" , err )
48
47
return appStoreGitOpsResponse , err
49
48
}
50
- space := regexp .MustCompile (`\s+` )
51
- appStoreName := space .ReplaceAllString (installAppVersionRequest .AppName , "-" )
52
-
53
- // Checking this is the first time chart has been pushed , if yes requirements.yaml has been already pushed with chart as there was sync-delay with github api.
54
- // step-2 commit dependencies and values in git
55
- if ! installAppVersionRequest .IsNewGitOpsRepo {
56
- githash , err = impl .gitOperationService .CommitRequirementsAndValues (appStoreName , chartGitAttribute .RepoUrl , manifestResponse .RequirementsConfig , manifestResponse .ValuesConfig )
57
- if err != nil {
58
- impl .Logger .Errorw ("error in committing config to git" , "err" , err )
59
- return appStoreGitOpsResponse , err
60
- }
61
- }
62
49
appStoreGitOpsResponse .ChartGitAttribute = chartGitAttribute
63
50
appStoreGitOpsResponse .GitHash = githash
64
51
return appStoreGitOpsResponse , nil
@@ -73,6 +60,8 @@ func (impl *FullModeDeploymentServiceImpl) GenerateManifest(installAppVersionReq
73
60
impl .Logger .Errorw ("Error in building chart while generating manifest" , "err" , err )
74
61
return manifestResponse , err
75
62
}
63
+ // valuesConfig and dependencyConfig's ChartConfig object contains ChartRepoName which is extracted from gitOpsRepoUrl
64
+ // that resides in the db and not from the current orchestrator cm prefix and appName.
76
65
valuesConfig , dependencyConfig , err := impl .getValuesAndRequirementForGitConfig (installAppVersionRequest )
77
66
if err != nil {
78
67
impl .Logger .Errorw ("error in fetching values and requirements.yaml config while generating manifest" , "err" , err )
@@ -127,14 +116,18 @@ func (impl *FullModeDeploymentServiceImpl) UpdateAppGitOpsOperations(manifest *b
127
116
noTargetFoundForRequirements , _ := impl .parseGitRepoErrorResponse (requirementsCommitErr )
128
117
if noTargetFoundForRequirements || noTargetFoundForValues {
129
118
//create repo again and try again - auto fix
130
- * monoRepoMigrationRequired = true // since repo is created again, will use this flag to check if ACD patch operation required
131
- installAppVersionRequest .GitOpsRepoURL = ""
119
+ _ , _ , err := impl .createGitOpsRepo (impl .gitOpsConfigReadService .GetGitOpsRepoNameFromUrl (installAppVersionRequest .GitOpsRepoURL ), installAppVersionRequest .UserId )
120
+ if err != nil {
121
+ impl .Logger .Errorw ("error in creating gitops repo for valuesCommitErr or requirementsCommitErr" , "gitRepoUrl" , installAppVersionRequest .GitOpsRepoURL )
122
+ return nil , err
123
+ }
132
124
return impl .GitOpsOperations (manifest , installAppVersionRequest )
133
125
}
134
126
impl .Logger .Errorw ("error in performing GitOps for upgrade deployment" , "ValuesCommitErr" , valuesCommitErr , "RequirementsCommitErr" , requirementsCommitErr )
135
127
return nil , fmt .Errorf ("error in committing values and requirements to git repository" )
136
128
}
137
129
gitOpsResponse .GitHash = gitHash
130
+ gitOpsResponse .ChartGitAttribute = & commonBean.ChartGitAttribute {RepoUrl : installAppVersionRequest .GitOpsRepoURL , ChartLocation : installAppVersionRequest .ACDAppName }
138
131
return gitOpsResponse , nil
139
132
}
140
133
@@ -169,6 +162,7 @@ func (impl *FullModeDeploymentServiceImpl) parseGitRepoErrorResponse(err error)
169
162
170
163
// createGitOpsRepoAndPushChart is a wrapper for creating GitOps repo and pushing chart to created repo
171
164
func (impl * FullModeDeploymentServiceImpl ) createGitOpsRepoAndPushChart (installAppVersionRequest * appStoreBean.InstallAppVersionDTO , builtChartPath string , requirementsConfig * git.ChartConfig , valuesConfig * git.ChartConfig ) (* commonBean.ChartGitAttribute , string , error ) {
165
+ // in case of monorepo migration installAppVersionRequest.GitOpsRepoURL is ""
172
166
if len (installAppVersionRequest .GitOpsRepoURL ) == 0 {
173
167
gitOpsConfigStatus , err := impl .gitOpsConfigReadService .GetGitOpsConfigActive ()
174
168
if err != nil {
@@ -191,24 +185,7 @@ func (impl *FullModeDeploymentServiceImpl) createGitOpsRepoAndPushChart(installA
191
185
installAppVersionRequest .GitOpsRepoURL = gitopsRepoURL
192
186
installAppVersionRequest .IsCustomRepository = false
193
187
installAppVersionRequest .IsNewGitOpsRepo = isNew
194
- dbConnection := impl .installedAppRepository .GetConnection ()
195
- tx , err := dbConnection .Begin ()
196
- if err != nil {
197
- return nil , "" , err
198
- }
199
- // Rollback tx on error.
200
- defer tx .Rollback ()
201
- InstalledApp .UpdateGitOpsRepository (gitopsRepoURL , false )
202
- _ , err = impl .installedAppRepository .UpdateInstalledApp (InstalledApp , tx )
203
- if err != nil {
204
- impl .Logger .Errorw ("error while fetching from db" , "error" , err )
205
- return nil , "" , err
206
- }
207
- err = tx .Commit ()
208
- if err != nil {
209
- impl .Logger .Errorw ("error while commit db transaction to db" , "error" , err )
210
- return nil , "" , err
211
- }
188
+
212
189
}
213
190
pushChartToGitRequest := adapter .ParseChartGitPushRequest (installAppVersionRequest , builtChartPath )
214
191
chartGitAttribute , commitHash , err := impl .gitOperationService .PushChartToGitOpsRepoForHelmApp (pushChartToGitRequest , requirementsConfig , valuesConfig )
0 commit comments