Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (impl *EAModeDeploymentServiceImpl) InstallApp(installAppVersionRequest *ap
}
}
installReleaseRequest := &gRPC.InstallReleaseRequest{
ChartName: appStoreAppVersion.Name,
ChartName: appStoreDeploymentCommon.GetChartNameFromAppStoreApplicationVersion(appStoreAppVersion),
ChartVersion: appStoreAppVersion.Version,
ValuesYaml: installAppVersionRequest.ValuesOverrideYaml,
ChartRepository: chartRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ package deployment

import (
"context"
"errors"
"fmt"
bean2 "github.com/devtron-labs/devtron/api/bean/gitOps"
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/timelineStatus"
"github.com/devtron-labs/devtron/internal/util"
appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean"
appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository"
Expand Down Expand Up @@ -245,50 +243,6 @@ func (impl *FullModeDeploymentServiceImpl) createGitOpsRepo(gitOpsRepoName strin
return repoUrl, isNew, err
}

func (impl *FullModeDeploymentServiceImpl) updateValuesYamlInGit(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) {
valuesString, err := impl.appStoreDeploymentCommonService.GetValuesString(installAppVersionRequest.AppStoreName, installAppVersionRequest.ValuesOverrideYaml)
if err != nil {
impl.Logger.Errorw("error in getting values string", "err", err)
return nil, err
}

valuesGitConfig, err := impl.getGitCommitConfig(installAppVersionRequest, valuesString, appStoreBean.VALUES_YAML_FILE)
if err != nil {
impl.Logger.Errorw("error in getting git commit config", "err", err)
}

commitHash, _, err := impl.gitOperationService.CommitValues(context.Background(), valuesGitConfig)
if err != nil {
impl.Logger.Errorw("error in git commit", "err", err)
return installAppVersionRequest, errors.New(timelineStatus.TIMELINE_STATUS_GIT_COMMIT_FAILED.ToString())
}
//update timeline status for git commit state
installAppVersionRequest.GitHash = commitHash
return installAppVersionRequest, nil
}

func (impl *FullModeDeploymentServiceImpl) updateRequirementYamlInGit(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error {
requirementsString, err := impl.appStoreDeploymentCommonService.GetRequirementsString(appStoreAppVersion)
if err != nil {
impl.Logger.Errorw("error in getting requirements string", "err", err)
return err
}

requirementsGitConfig, err := impl.getGitCommitConfig(installAppVersionRequest, requirementsString, appStoreBean.REQUIREMENTS_YAML_FILE)
if err != nil {
impl.Logger.Errorw("error in getting git commit config", "err", err)
return err
}

_, _, err = impl.gitOperationService.CommitValues(context.Background(), requirementsGitConfig)
if err != nil {
impl.Logger.Errorw("error in values commit", "err", err)
return errors.New(timelineStatus.TIMELINE_STATUS_GIT_COMMIT_FAILED.ToString())
}

return nil
}

// createChartProxyAndGetPath parse chart in local directory and returns path of local dir and values.yaml
func (impl *FullModeDeploymentServiceImpl) createChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) {
chartCreateRequest := adapter.ParseChartCreateRequest(installAppVersionRequest.AppName, true)
Expand Down Expand Up @@ -370,7 +324,7 @@ func (impl *FullModeDeploymentServiceImpl) getValuesAndRequirementForGitConfig(i
}

}
values, err := impl.appStoreDeploymentCommonService.GetValuesString(appStoreAppVersion.AppStore.Name, installAppVersionRequest.ValuesOverrideYaml)
values, err := impl.appStoreDeploymentCommonService.GetValuesString(appStoreAppVersion, installAppVersionRequest.ValuesOverrideYaml)
if err != nil {
impl.Logger.Errorw("error in getting values fot installedAppVersionRequest", "err", err)
return nil, nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import (

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

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

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

valuesMap := make(map[string]map[string]interface{})
valuesMap[chartName] = dat
valuesMap[GetChartNameFromAppStoreApplicationVersion(appStoreApplicationVersion)] = dat
valuesByte, err := json.Marshal(valuesMap)
if err != nil {
impl.logger.Errorw("error in marshaling", "err", err)
Expand All @@ -193,23 +193,29 @@ func (impl AppStoreDeploymentCommonServiceImpl) GetValuesString(chartName, value
return string(valuesByte), nil
}

func GetChartNameFromAppStoreApplicationVersion(appStoreApplicationVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) string {
if len(appStoreApplicationVersion.Name) > 0 {
return appStoreApplicationVersion.Name //we get this from chartMetadata in app sync job, so more reliable
} else {
return appStoreApplicationVersion.AppStore.Name
}
}

func (impl AppStoreDeploymentCommonServiceImpl) GetRequirementsString(appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) (string, error) {

dependency := appStoreBean.Dependency{
Name: appStoreAppVersion.AppStore.Name,
Name: GetChartNameFromAppStoreApplicationVersion(appStoreAppVersion),
Version: appStoreAppVersion.Version,
}
if appStoreAppVersion.AppStore.ChartRepo != nil {
dependency.Repository = appStoreAppVersion.AppStore.ChartRepo.Url
} else if appStoreAppVersion.AppStore.DockerArtifactStore != nil {
dependency.Repository = appStoreAppVersion.AppStore.DockerArtifactStore.RegistryURL
repositoryURL, repositoryName, err := sanitizeRepoNameAndURLForOCIRepo(dependency.Repository, dependency.Name)
repositoryURL, repositoryName, err := sanitizeRepoNameAndURLForOCIRepo(appStoreAppVersion.AppStore.DockerArtifactStore.RegistryURL, appStoreAppVersion.AppStore.Name)
if err != nil {
impl.logger.Errorw("error in getting sanitized repository name and url", "repositoryURL", repositoryURL, "repositoryName", repositoryName, "err", err)
return "", err
}
dependency.Repository = repositoryURL
dependency.Name = repositoryName
}

var dependencies []appStoreBean.Dependency
Expand Down