Skip to content

Commit 7795000

Browse files
committed
default version support
1 parent 0f766a8 commit 7795000

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

pkg/configDiff/DeploymentConfigurationService.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,13 @@ func (impl *DeploymentConfigurationServiceImpl) getConfigDataForAppConfiguration
482482
configDataDto := &bean2.DeploymentAndCmCsConfigDto{}
483483
var err error
484484
switch configDataQueryParams.ConfigType {
485+
case bean2.DefaultVersion.ToString():
486+
configDataDto, err = impl.getDeploymentAndCmCsConfigDataForDefaultVersion(ctx, configDataQueryParams)
487+
if err != nil {
488+
impl.logger.Errorw("GetAllConfigData, error in config data for Default version", "configDataQueryParams", configDataQueryParams, "err", err)
489+
return nil, err
490+
}
491+
//no cm or cs to send for default versions
485492
case bean2.PreviousDeployments.ToString():
486493
configDataDto, err = impl.getDeploymentAndCmCsConfigDataForPreviousDeployments(ctx, configDataQueryParams, appId, envId, userHasAdminAccess)
487494
if err != nil {
@@ -498,6 +505,38 @@ func (impl *DeploymentConfigurationServiceImpl) getConfigDataForAppConfiguration
498505
return configDataDto, nil
499506
}
500507

508+
func (impl *DeploymentConfigurationServiceImpl) getDeploymentsConfigForDefaultVersion(ctx context.Context, chartRefId int) (json.RawMessage, error) {
509+
deploymentTemplateRequest := generateManifest.DeploymentTemplateRequest{
510+
ChartRefId: chartRefId,
511+
RequestDataMode: generateManifest.Values,
512+
Type: repository2.DefaultVersions,
513+
}
514+
deploymentTemplateResponse, err := impl.deploymentTemplateService.GetDeploymentTemplate(ctx, deploymentTemplateRequest)
515+
if err != nil {
516+
impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in getting deployment template for ", "deploymentTemplateRequest", deploymentTemplateRequest, "err", err)
517+
return nil, err
518+
}
519+
deploymentJson := json.RawMessage{}
520+
err = deploymentJson.UnmarshalJSON([]byte(deploymentTemplateResponse.Data))
521+
if err != nil {
522+
impl.logger.Errorw("getDeploymentTemplateForEnvLevel, error in unmarshalling string deploymentTemplateResponse data into json Raw message", "data", deploymentTemplateResponse.Data, "err", err)
523+
return nil, err
524+
}
525+
return deploymentJson, nil
526+
}
527+
528+
func (impl *DeploymentConfigurationServiceImpl) getDeploymentAndCmCsConfigDataForDefaultVersion(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams) (*bean2.DeploymentAndCmCsConfigDto, error) {
529+
configData := &bean2.DeploymentAndCmCsConfigDto{}
530+
deploymentTemplateJsonData, err := impl.getDeploymentsConfigForDefaultVersion(ctx, configDataQueryParams.IdentifierId)
531+
if err != nil {
532+
impl.logger.Errorw("GetAllConfigData, error in getting deployment config for default version", "chartRefId", configDataQueryParams.IdentifierId, "err", err)
533+
return nil, err
534+
}
535+
deploymentConfig := bean2.NewDeploymentAndCmCsConfig().WithConfigData(deploymentTemplateJsonData).WithResourceType(bean.DeploymentTemplate)
536+
configData.WithDeploymentTemplateData(deploymentConfig)
537+
return configData, nil
538+
}
539+
501540
func (impl *DeploymentConfigurationServiceImpl) getCmCsEditDataForPublishedOnly(ctx context.Context, configDataQueryParams *bean2.ConfigDataQueryParams, envId,
502541
appId int, clusterId int, userHasAdminAccess bool, systemMetadata *resourceQualifiers.SystemMetadata) (*bean2.DeploymentAndCmCsConfigDto, error) {
503542
configDataDto := &bean2.DeploymentAndCmCsConfigDto{}

pkg/configDiff/bean/bean.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type ConfigState string
1414
const (
1515
PublishedConfigState ConfigState = "PublishedOnly"
1616
PreviousDeployments ConfigState = "PreviousDeployments"
17+
DefaultVersion ConfigState = "DefaultVersion"
1718
)
1819

1920
func (r ConfigState) ToString() string {

0 commit comments

Comments
 (0)