Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applied radix-app crd to the namespace in promote pipeline #930

Merged
merged 2 commits into from
Sep 20, 2023
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
13 changes: 10 additions & 3 deletions pipeline-runner/steps/build_acr.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func createACRBuildJob(rr *v1.RadixRegistration, pipelineInfo *model.PipelineInf
if isUsingBuildKit(pipelineInfo) {
for _, buildContainer := range buildContainers {
annotations[fmt.Sprintf("container.apparmor.security.beta.kubernetes.io/%s", buildContainer.Name)] = "unconfined"
// annotations[fmt.Sprintf("container.seccomp.security.alpha.kubernetes.io/%s", buildContainer.Name)] = "unconfined"
}
buildPodSecurityContext = &pipelineInfo.PipelineArguments.BuildKitPodSecurityContext
}
Expand Down Expand Up @@ -326,8 +325,16 @@ func getBuildahContainerCommand(containerImageRegistry, secretArgsString, contex
"-c",
fmt.Sprintf("/usr/bin/buildah login --username ${BUILDAH_USERNAME} --password ${BUILDAH_PASSWORD} %s "+
"&& /usr/bin/buildah build --storage-driver=vfs --isolation=chroot "+
"--jobs 0 %s --file %s%s --tag %s --tag %s --tag %s %s "+
"&& /usr/bin/buildah push --storage-driver=vfs --all %s", containerImageRegistry, secretArgsString, context, dockerFileName, imageTag, clusterTypeImageTag, clusterNameImageTag, context, imageTag),
"--jobs 0 %s --file %s%s "+
"--tag %s --tag %s --tag %s "+
"%s "+
"&& /usr/bin/buildah push --storage-driver=vfs --all %s "+
"&& /usr/bin/buildah push --storage-driver=vfs --all %s "+
"&& /usr/bin/buildah push --storage-driver=vfs --all %s ",
containerImageRegistry, secretArgsString, context, dockerFileName,
imageTag, clusterTypeImageTag, clusterNameImageTag,
context,
imageTag, clusterTypeImageTag, clusterNameImageTag),
}
}

Expand Down
22 changes: 11 additions & 11 deletions pipeline-runner/steps/promotion.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (cli *PromoteStepImplementation) Run(pipelineInfo *model.PipelineInfo) erro
radixDeployment.Labels[kube.RadixJobNameLabel] = pipelineInfo.PipelineArguments.JobName
radixDeployment.Spec.Environment = pipelineInfo.PipelineArguments.ToEnvironment

err = mergeWithRadixApplication(radixApplication, radixDeployment, pipelineInfo.PipelineArguments.ToEnvironment)
err = mergeWithRadixApplication(radixApplication, radixDeployment, pipelineInfo.PipelineArguments.ToEnvironment, pipelineInfo.ComponentImages)
if err != nil {
return err
}
Expand Down Expand Up @@ -160,22 +160,22 @@ func areArgumentsValid(arguments model.PipelineArguments) error {
return nil
}

func mergeWithRadixApplication(radixConfig *v1.RadixApplication, radixDeployment *v1.RadixDeployment, environment string) error {
func mergeWithRadixApplication(radixConfig *v1.RadixApplication, radixDeployment *v1.RadixDeployment, environment string, componentImages map[string]pipeline.ComponentImage) error {
defaultEnvVars := getDefaultEnvVarsFromRadixDeployment(radixDeployment)
if err := mergeComponentsWithRadixApplication(radixConfig, radixDeployment, environment, defaultEnvVars); err != nil {
if err := mergeComponentsWithRadixApplication(radixConfig, radixDeployment, environment, defaultEnvVars, componentImages); err != nil {
return err
}

if err := mergeJobComponentsWithRadixApplication(radixConfig, radixDeployment, environment, defaultEnvVars); err != nil {
if err := mergeJobComponentsWithRadixApplication(radixConfig, radixDeployment, environment, defaultEnvVars, componentImages); err != nil {
return err
}

return nil
}

func mergeJobComponentsWithRadixApplication(radixConfig *v1.RadixApplication, radixDeployment *v1.RadixDeployment, environment string, defaultEnvVars v1.EnvVarsMap) error {
func mergeJobComponentsWithRadixApplication(radixConfig *v1.RadixApplication, radixDeployment *v1.RadixDeployment, environment string, defaultEnvVars v1.EnvVarsMap, componentImages map[string]pipeline.ComponentImage) error {
newEnvJobs, err := deployment.
NewJobComponentsBuilder(radixConfig, environment, make(map[string]pipeline.ComponentImage), defaultEnvVars).
NewJobComponentsBuilder(radixConfig, environment, componentImages, defaultEnvVars).
JobComponents()
if err != nil {
return err
Expand All @@ -190,7 +190,7 @@ func mergeJobComponentsWithRadixApplication(radixConfig *v1.RadixApplication, ra
if !found {
return NonExistingComponentName(radixConfig.GetName(), job.Name)
}
//Environment variables, SecretRefs are taken from current configuration
// Environment variables, SecretRefs are taken from current configuration
newEnvJob.Secrets = job.Secrets
newEnvJob.Image = job.Image
radixDeployment.Spec.Jobs[idx] = newEnvJob
Expand All @@ -199,10 +199,10 @@ func mergeJobComponentsWithRadixApplication(radixConfig *v1.RadixApplication, ra
return nil
}

func mergeComponentsWithRadixApplication(radixConfig *v1.RadixApplication, radixDeployment *v1.RadixDeployment, environment string, defaultEnvVars v1.EnvVarsMap) error {
newEnvComponents, err := deployment.GetRadixComponentsForEnv(radixConfig, environment, make(map[string]pipeline.ComponentImage), defaultEnvVars)
func mergeComponentsWithRadixApplication(radixConfig *v1.RadixApplication, radixDeployment *v1.RadixDeployment, environment string, defaultEnvVars v1.EnvVarsMap, componentImages map[string]pipeline.ComponentImage) error {
newEnvComponents, err := deployment.GetRadixComponentsForEnv(radixConfig, environment, componentImages, defaultEnvVars)
if err != nil {
return nil
return err
}

newEnvComponentsMap := make(map[string]v1.RadixDeployComponent)
Expand All @@ -215,7 +215,7 @@ func mergeComponentsWithRadixApplication(radixConfig *v1.RadixApplication, radix
if !found {
return NonExistingComponentName(radixConfig.GetName(), component.Name)
}
//Environment variables, SecretRefs are taken from current configuration
// Environment variables, SecretRefs are taken from current configuration
newEnvComponent.Secrets = component.Secrets
newEnvComponent.Image = component.Image
radixDeployment.Spec.Components[idx] = newEnvComponent
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func GetSupportedPipelines() []Definition {
}},
{v1.Promote, []StepType{
PreparePipelinesStep,
ApplyConfigStep,
RunPipelinesStep,
PromoteStep}},
{v1.Deploy, []StepType{
Expand Down