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

overwrite only backstage and init-dynamic-plugins image. fix for https://issues.redhat.com/browse/RHIDP-1701 #279

Merged
2 changes: 1 addition & 1 deletion api/v1alpha1/backstage_types.go
Expand Up @@ -180,7 +180,7 @@ type Env struct {
type RuntimeConfig struct {
// Name of ConfigMap containing Backstage runtime objects configuration
BackstageConfigName string `json:"backstageConfig,omitempty"`
// Name of ConfigMap containing LocalDb (P|ostgreSQL) runtime objects configuration
// Name of ConfigMap containing LocalDb (PostgreSQL) runtime objects configuration
gazarenkov marked this conversation as resolved.
Show resolved Hide resolved
LocalDbConfigName string `json:"localDbConfig,omitempty"`
}

Expand Down
4 changes: 3 additions & 1 deletion controllers/backstage_controller_test.go
rm3l marked this conversation as resolved.
Show resolved Hide resolved
Expand Up @@ -1315,7 +1315,9 @@ plugins: []
By("Checking that the image was set on all containers in the Pod Spec")
visitContainers(&found.Spec.Template, func(container *corev1.Container) {
By(fmt.Sprintf("Checking Image in the Backstage Deployment - container: %q", container.Name), func() {
Expect(container.Image).Should(Equal(imageName))
if container.Image == _defaultBackstageMainContainerName || container.Image == _defaultBackstageInitContainerName {
gazarenkov marked this conversation as resolved.
Show resolved Hide resolved
Expect(container.Image).Should(Equal(imageName))
}
})
})

Expand Down
17 changes: 10 additions & 7 deletions controllers/backstage_deployment.go
Expand Up @@ -195,10 +195,7 @@ func (r *BackstageReconciler) validateAndUpdatePsqlSecretRef(backstage bs.Backst

func (r *BackstageReconciler) setDefaultDeploymentImage(deployment *appsv1.Deployment) {
if envBackstageImage != "" {
visitContainers(&deployment.Spec.Template, func(container *v1.Container) {
container.Image = envBackstageImage

})
setBackstageImage(deployment, envBackstageImage)
}
}

Expand All @@ -212,9 +209,7 @@ func (r *BackstageReconciler) applyApplicationParamsFromCR(backstage bs.Backstag
if backstage.Spec.Application != nil {
deployment.Spec.Replicas = backstage.Spec.Application.Replicas
if backstage.Spec.Application.Image != nil {
visitContainers(&deployment.Spec.Template, func(container *v1.Container) {
container.Image = *backstage.Spec.Application.Image
})
setBackstageImage(deployment, *backstage.Spec.Application.Image)
}
if backstage.Spec.Application.ImagePullSecrets != nil { // use image pull secrets from the CR spec
deployment.Spec.Template.Spec.ImagePullSecrets = nil
Expand All @@ -236,3 +231,11 @@ func getDefaultObjName(backstage bs.Backstage) string {
func getDefaultDbObjName(backstage bs.Backstage) string {
return fmt.Sprintf("backstage-psql-%s", backstage.Name)
}

func setBackstageImage(deployment *appsv1.Deployment, imageName string) {
visitContainers(&deployment.Spec.Template, func(container *v1.Container) {
if container.Image == _defaultBackstageMainContainerName || container.Image == _defaultBackstageInitContainerName {
gazarenkov marked this conversation as resolved.
Show resolved Hide resolved
container.Image = imageName
}
})
}