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
17 changes: 16 additions & 1 deletion api/helm-app/HelmAppService.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/devtron-labs/devtron/pkg/appStore/deployment/repository"
appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository"
"github.com/devtron-labs/devtron/pkg/cluster"
clusterRepository "github.com/devtron-labs/devtron/pkg/cluster/repository"
serverBean "github.com/devtron-labs/devtron/pkg/server/bean"
serverEnvConfig "github.com/devtron-labs/devtron/pkg/server/config"
serverDataStore "github.com/devtron-labs/devtron/pkg/server/store"
Expand Down Expand Up @@ -73,14 +74,15 @@ type HelmAppServiceImpl struct {
pipelineRepository pipelineConfig.PipelineRepository
installedAppRepository repository.InstalledAppRepository
appRepository app.AppRepository
clusterRepository clusterRepository.ClusterRepository
}

func NewHelmAppServiceImpl(Logger *zap.SugaredLogger,
clusterService cluster.ClusterService,
helmAppClient HelmAppClient,
pump connector.Pump, enforcerUtil rbac.EnforcerUtilHelm, serverDataStore *serverDataStore.ServerDataStore,
serverEnvConfig *serverEnvConfig.ServerEnvConfig, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository,
environmentService cluster.EnvironmentService, pipelineRepository pipelineConfig.PipelineRepository, installedAppRepository repository.InstalledAppRepository, appRepository app.AppRepository) *HelmAppServiceImpl {
environmentService cluster.EnvironmentService, pipelineRepository pipelineConfig.PipelineRepository, installedAppRepository repository.InstalledAppRepository, appRepository app.AppRepository, clusterRepository clusterRepository.ClusterRepository) *HelmAppServiceImpl {
return &HelmAppServiceImpl{
logger: Logger,
clusterService: clusterService,
Expand All @@ -94,6 +96,7 @@ func NewHelmAppServiceImpl(Logger *zap.SugaredLogger,
pipelineRepository: pipelineRepository,
installedAppRepository: installedAppRepository,
appRepository: appRepository,
clusterRepository: clusterRepository,
}
}

Expand Down Expand Up @@ -650,6 +653,18 @@ func (impl *HelmAppServiceImpl) TemplateChart(ctx context.Context, templateChart

clusterId := int(*templateChartRequest.ClusterId)

clusterDetail, _ := impl.clusterRepository.FindById(clusterId)

if len(clusterDetail.ErrorInConnecting) > 0 || clusterDetail.Active == false {
clusterNotFoundErr := &util.ApiError{
HttpStatusCode: http.StatusInternalServerError,
Code: "",
UserMessage: fmt.Sprintf("Could not generate manifest output as the Kubernetes cluster %s is unreachable.", clusterDetail.ClusterName),
UserDetailMessage: "",
}
return nil, clusterNotFoundErr
}

installReleaseRequest := &InstallReleaseRequest{
ChartName: appStoreAppVersion.Name,
ChartVersion: appStoreAppVersion.Version,
Expand Down
1 change: 1 addition & 0 deletions pkg/appStore/bean/bean.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type InstallAppVersionDTO struct {
EnvironmentName string `json:"-"`
InstallAppVersionChartDTO *InstallAppVersionChartDTO `json:"-"`
DeploymentAppType string `json:"deploymentAppType"`
AppStoreApplicationVersionId int
}

type InstallAppVersionChartDTO struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) convert(chart *repository.Instal
Password: chartRepo.Password,
},
},
AppStoreApplicationVersionId: installedAppVersion.AppStoreApplicationVersionId,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ func (impl AppStoreDeploymentServiceImpl) installAppPostDbOperation(installAppVe
}

//step 5 create build history first entry for install app version
if len(installAppVersionRequest.GitHash) > 0 {
if len(installAppVersionRequest.GitHash) > 0 || installAppVersionRequest.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_HELM {
err = impl.UpdateInstallAppVersionHistory(installAppVersionRequest)
if err != nil {
impl.logger.Errorw("error on creating history for chart deployment", "error", err)
Expand Down Expand Up @@ -882,7 +882,7 @@ func (impl AppStoreDeploymentServiceImpl) GetDeploymentHistoryInfo(ctx context.C
//var result interface{}
result := &openapi.HelmAppDeploymentManifestDetail{}
var err error
if util2.IsHelmApp(installedApp.AppOfferingMode) {
if util2.IsHelmApp(installedApp.AppOfferingMode) || installedApp.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_HELM {
result, err = impl.appStoreDeploymentHelmService.GetDeploymentHistoryInfo(ctx, installedApp, int32(version))
if err != nil {
impl.logger.Errorw("error while getting deployment history info", "error", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/devtron-labs/devtron/api/bean"
client "github.com/devtron-labs/devtron/api/helm-app"
openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient"
openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient"
application2 "github.com/devtron-labs/devtron/client/argocdServer/application"
"github.com/devtron-labs/devtron/internal/constants"
repository3 "github.com/devtron-labs/devtron/internal/sql/repository"
Expand Down Expand Up @@ -54,14 +55,14 @@ type AppStoreDeploymentArgoCdServiceImpl struct {
gitFactory *util.GitFactory
argoUserService argo.ArgoUserService
appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService
helmAppService client.HelmAppService
gitOpsConfigRepository repository3.GitOpsConfigRepository
}

func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService,
acdClient application2.ServiceClient, chartGroupDeploymentRepository repository.ChartGroupDeploymentRepository,
installedAppRepository repository.InstalledAppRepository, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, chartTemplateService util.ChartTemplateService,
gitFactory *util.GitFactory, argoUserService argo.ArgoUserService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService,
gitOpsConfigRepository repository3.GitOpsConfigRepository) *AppStoreDeploymentArgoCdServiceImpl {
gitFactory *util.GitFactory, argoUserService argo.ArgoUserService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, helmAppService client.HelmAppService, gitOpsConfigRepository repository3.GitOpsConfigRepository) *AppStoreDeploymentArgoCdServiceImpl {
return &AppStoreDeploymentArgoCdServiceImpl{
Logger: logger,
appStoreDeploymentFullModeService: appStoreDeploymentFullModeService,
Expand All @@ -73,6 +74,7 @@ func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreD
gitFactory: gitFactory,
argoUserService: argoUserService,
appStoreDeploymentCommonService: appStoreDeploymentCommonService,
helmAppService: helmAppService,
gitOpsConfigRepository: gitOpsConfigRepository,
}
}
Expand Down Expand Up @@ -325,6 +327,30 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) GetDeploymentHistoryInfo(ctx con
return nil, err
}
values.ValuesYaml = &versionHistory.ValuesYamlRaw

envId := int32(installedApp.EnvironmentId)
clusterId := int32(installedApp.ClusterId)
appStoreVersionId := int32(installedApp.AppStoreApplicationVersionId)

manifestRequest := openapi2.TemplateChartRequest{
EnvironmentId: &envId,
ClusterId: &clusterId,
Namespace: &installedApp.Namespace,
ReleaseName: &installedApp.AppName,
AppStoreApplicationVersionId: &appStoreVersionId,
ValuesYaml: values.ValuesYaml,
}

templateChart, manifestErr := impl.helmAppService.TemplateChart(ctx, &manifestRequest)

manifest := templateChart.GetManifest()

if manifestErr != nil {
impl.Logger.Errorw("error in genetating manifest for argocd app", "err", manifestErr)
} else {
values.Manifest = &manifest
}

return values, err
}

Expand Down