Skip to content

Commit 5dca30c

Browse files
committed
fix
1 parent f8b8a50 commit 5dca30c

File tree

3 files changed

+14
-53
lines changed

3 files changed

+14
-53
lines changed

pkg/appStore/installedApp/service/EAMode/deployment/EAModeDeploymentService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (impl *EAModeDeploymentServiceImpl) InstallApp(installAppVersionRequest *ap
145145
}
146146
}
147147
installReleaseRequest := &gRPC.InstallReleaseRequest{
148-
ChartName: appStoreAppVersion.Name,
148+
ChartName: appStoreDeploymentCommon.GetChartNameFromAppStoreApplicationVersion(appStoreAppVersion),
149149
ChartVersion: appStoreAppVersion.Version,
150150
ValuesYaml: installAppVersionRequest.ValuesOverrideYaml,
151151
ChartRepository: chartRepository,

pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ package deployment
1818

1919
import (
2020
"context"
21-
"errors"
2221
"fmt"
2322
bean2 "github.com/devtron-labs/devtron/api/bean/gitOps"
24-
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/timelineStatus"
2523
"github.com/devtron-labs/devtron/internal/util"
2624
appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean"
2725
appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository"
@@ -245,50 +243,6 @@ func (impl *FullModeDeploymentServiceImpl) createGitOpsRepo(gitOpsRepoName strin
245243
return repoUrl, isNew, err
246244
}
247245

248-
func (impl *FullModeDeploymentServiceImpl) updateValuesYamlInGit(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) {
249-
valuesString, err := impl.appStoreDeploymentCommonService.GetValuesString(installAppVersionRequest.AppStoreName, installAppVersionRequest.ValuesOverrideYaml)
250-
if err != nil {
251-
impl.Logger.Errorw("error in getting values string", "err", err)
252-
return nil, err
253-
}
254-
255-
valuesGitConfig, err := impl.getGitCommitConfig(installAppVersionRequest, valuesString, appStoreBean.VALUES_YAML_FILE)
256-
if err != nil {
257-
impl.Logger.Errorw("error in getting git commit config", "err", err)
258-
}
259-
260-
commitHash, _, err := impl.gitOperationService.CommitValues(context.Background(), valuesGitConfig)
261-
if err != nil {
262-
impl.Logger.Errorw("error in git commit", "err", err)
263-
return installAppVersionRequest, errors.New(timelineStatus.TIMELINE_STATUS_GIT_COMMIT_FAILED.ToString())
264-
}
265-
//update timeline status for git commit state
266-
installAppVersionRequest.GitHash = commitHash
267-
return installAppVersionRequest, nil
268-
}
269-
270-
func (impl *FullModeDeploymentServiceImpl) updateRequirementYamlInGit(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error {
271-
requirementsString, err := impl.appStoreDeploymentCommonService.GetRequirementsString(appStoreAppVersion)
272-
if err != nil {
273-
impl.Logger.Errorw("error in getting requirements string", "err", err)
274-
return err
275-
}
276-
277-
requirementsGitConfig, err := impl.getGitCommitConfig(installAppVersionRequest, requirementsString, appStoreBean.REQUIREMENTS_YAML_FILE)
278-
if err != nil {
279-
impl.Logger.Errorw("error in getting git commit config", "err", err)
280-
return err
281-
}
282-
283-
_, _, err = impl.gitOperationService.CommitValues(context.Background(), requirementsGitConfig)
284-
if err != nil {
285-
impl.Logger.Errorw("error in values commit", "err", err)
286-
return errors.New(timelineStatus.TIMELINE_STATUS_GIT_COMMIT_FAILED.ToString())
287-
}
288-
289-
return nil
290-
}
291-
292246
// createChartProxyAndGetPath parse chart in local directory and returns path of local dir and values.yaml
293247
func (impl *FullModeDeploymentServiceImpl) createChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) {
294248
chartCreateRequest := adapter.ParseChartCreateRequest(installAppVersionRequest.AppName, true)
@@ -370,7 +324,7 @@ func (impl *FullModeDeploymentServiceImpl) getValuesAndRequirementForGitConfig(i
370324
}
371325

372326
}
373-
values, err := impl.appStoreDeploymentCommonService.GetValuesString(appStoreAppVersion.AppStore.Name, installAppVersionRequest.ValuesOverrideYaml)
327+
values, err := impl.appStoreDeploymentCommonService.GetValuesString(appStoreAppVersion, installAppVersionRequest.ValuesOverrideYaml)
374328
if err != nil {
375329
impl.Logger.Errorw("error in getting values fot installedAppVersionRequest", "err", err)
376330
return nil, nil, err

pkg/appStore/installedApp/service/common/AppStoreDeploymentCommonService.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import (
4747

4848
type AppStoreDeploymentCommonService interface {
4949
// GetValuesString will return values string from the given valuesOverrideYaml
50-
GetValuesString(chartName, valuesOverrideYaml string) (string, error)
50+
GetValuesString(appStoreApplicationVersion *appStoreDiscoverRepository.AppStoreApplicationVersion, valuesOverrideYaml string) (string, error)
5151
// GetRequirementsString will return requirement dependencies for the given appStoreVersionId
5252
GetRequirementsString(appStoreApplicationVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) (string, error)
5353
// CreateChartProxyAndGetPath parse chart in local directory and returns path of local dir and values.yaml
@@ -169,7 +169,7 @@ func (impl *AppStoreDeploymentCommonServiceImpl) GetDeploymentHistoryInfoFromDB(
169169
return values, err
170170
}
171171

172-
func (impl AppStoreDeploymentCommonServiceImpl) GetValuesString(chartName, valuesOverrideYaml string) (string, error) {
172+
func (impl AppStoreDeploymentCommonServiceImpl) GetValuesString(appStoreApplicationVersion *appStoreDiscoverRepository.AppStoreApplicationVersion, valuesOverrideYaml string) (string, error) {
173173

174174
ValuesOverrideByte, err := yaml.YAMLToJSON([]byte(valuesOverrideYaml))
175175
if err != nil {
@@ -184,7 +184,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) GetValuesString(chartName, value
184184
}
185185

186186
valuesMap := make(map[string]map[string]interface{})
187-
valuesMap[chartName] = dat
187+
valuesMap[GetChartNameFromAppStoreApplicationVersion(appStoreApplicationVersion)] = dat
188188
valuesByte, err := json.Marshal(valuesMap)
189189
if err != nil {
190190
impl.logger.Errorw("error in marshaling", "err", err)
@@ -193,10 +193,18 @@ func (impl AppStoreDeploymentCommonServiceImpl) GetValuesString(chartName, value
193193
return string(valuesByte), nil
194194
}
195195

196+
func GetChartNameFromAppStoreApplicationVersion(appStoreApplicationVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) string {
197+
if len(appStoreApplicationVersion.Name) > 0 {
198+
return appStoreApplicationVersion.Name //we get this from chartMetadata in app sync job, so more reliable
199+
} else {
200+
return appStoreApplicationVersion.AppStore.Name
201+
}
202+
}
203+
196204
func (impl AppStoreDeploymentCommonServiceImpl) GetRequirementsString(appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) (string, error) {
197205

198206
dependency := appStoreBean.Dependency{
199-
Name: appStoreAppVersion.AppStore.Name,
207+
Name: GetChartNameFromAppStoreApplicationVersion(appStoreAppVersion),
200208
Version: appStoreAppVersion.Version,
201209
}
202210
if appStoreAppVersion.AppStore.ChartRepo != nil {
@@ -209,7 +217,6 @@ func (impl AppStoreDeploymentCommonServiceImpl) GetRequirementsString(appStoreAp
209217
return "", err
210218
}
211219
dependency.Repository = repositoryURL
212-
dependency.Name = repositoryName
213220
}
214221

215222
var dependencies []appStoreBean.Dependency

0 commit comments

Comments
 (0)