Skip to content

Commit

Permalink
Restored support of magic config branch
Browse files Browse the repository at this point in the history
  • Loading branch information
satr committed Nov 8, 2024
1 parent 8e8e17c commit 27105d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
24 changes: 15 additions & 9 deletions api/applications/applications_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,19 +544,25 @@ func (ah *ApplicationHandler) triggerPipelineBuildOrBuildDeploy(ctx context.Cont
}

log.Ctx(ctx).Info().Msgf("Creating build pipeline jobController for %s on branch %s for commit %s", appName, branch, commitID)

// Check if branch is mapped
ra, err := userAccount.RadixClient.RadixV1().RadixApplications(operatorUtils.GetAppNamespace(appName)).Get(ctx, appName, metav1.GetOptions{})
radixRegistration, err := ah.getUserAccount().RadixClient.RadixV1().RadixRegistrations().Get(ctx, appName, metav1.GetOptions{})
if err != nil {
return nil, err
}
targetEnvironments := applicationconfig.GetTargetEnvironments(branch, ra)
if len(targetEnvironments) == 0 {
return nil, applicationModels.UnmatchedBranchToEnvironment(branch)
}

if len(envName) > 0 && !slice.Any(targetEnvironments, func(targetEnvName string) bool { return targetEnvName == envName }) {
return nil, applicationModels.EnvironmentNotMappedToBranch(envName, branch)
// Check if branch is mapped
if !applicationconfig.IsConfigBranch(branch, radixRegistration) {
ra, err := userAccount.RadixClient.RadixV1().RadixApplications(operatorUtils.GetAppNamespace(appName)).Get(ctx, appName, metav1.GetOptions{})
if err != nil {
return nil, err
}
targetEnvironments := applicationconfig.GetTargetEnvironments(branch, ra)
if len(targetEnvironments) == 0 {
return nil, applicationModels.UnmatchedBranchToEnvironment(branch)
}

if len(envName) > 0 && !slice.Any(targetEnvironments, func(targetEnvName string) bool { return targetEnvName == envName }) {
return nil, applicationModels.EnvironmentNotMappedToBranch(envName, branch)
}
}

jobParameters := pipelineParameters.MapPipelineParametersBuildToJobParameter()
Expand Down
10 changes: 8 additions & 2 deletions swaggerui/html/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6269,6 +6269,12 @@
"x-go-name": "ActiveTo",
"example": "2006-01-02T15:04:05Z"
},
"builtFromBranch": {
"description": "Name of the branch used to build the deployment",
"type": "string",
"x-go-name": "BuiltFromBranch",
"example": "main"
},
"components": {
"description": "Array of components",
"type": "array",
Expand Down Expand Up @@ -6380,7 +6386,7 @@
"builtFromBranch": {
"description": "Name of the branch used to build the deployment",
"type": "string",
"x-go-name": "BuildFromBranch",
"x-go-name": "BuiltFromBranch",
"example": "main"
},
"commitID": {
Expand Down Expand Up @@ -6453,7 +6459,7 @@
"builtFromBranch": {
"description": "Name of the branch used to build the deployment",
"type": "string",
"x-go-name": "BuildFromBranch",
"x-go-name": "BuiltFromBranch",
"example": "main"
},
"commitID": {
Expand Down

0 comments on commit 27105d8

Please sign in to comment.