diff --git a/controllers/authorino_controller.go b/controllers/authorino_controller.go index 0797af68..b380ed3f 100644 --- a/controllers/authorino_controller.go +++ b/controllers/authorino_controller.go @@ -113,7 +113,7 @@ func (r *AuthorinoReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( } else if existingDeployment == nil { // Creates a new deployment resource to deploy the new authorino instance newDeployment := r.buildAuthorinoDeployment(authorinoInstance) - if err := r.Client.Create(context.TODO(), newDeployment); err != nil { + if err := r.Client.Create(ctx, newDeployment); err != nil { return ctrl.Result{}, r.wrapErrorWithStatusUpdate( logger, authorinoInstance, r.setStatusFailed(statusUnableToCreateDeployment), fmt.Errorf("failed to create %s Deployment resource, err: %v", newDeployment.Name, err), @@ -259,7 +259,7 @@ func (r *AuthorinoReconciler) buildAuthorinoDeployment(authorino *api.Authorino) volumes = append(volumes, authorinoResources.GetTlsVolume(authorinoTlsCertVolumeName, secretName)) } - // if an external OIDC server is enable mounts a volume to the container + // if an external OIDC server is enabled mounts a volume to the container // by using the secret with the certs if enabled := authorino.Spec.OIDCServer.Tls.Enabled; enabled == nil || *enabled { secretName := authorino.Spec.OIDCServer.Tls.CertSecret.Name diff --git a/controllers/authorino_controller_test.go b/controllers/authorino_controller_test.go index e2f3efd1..150983ba 100644 --- a/controllers/authorino_controller_test.go +++ b/controllers/authorino_controller_test.go @@ -119,8 +119,9 @@ var _ = Describe("Authorino controller", func() { image := DefaultAuthorinoImage existContainer := false - Expect(deployment.Spec.Replicas).Should(Equal(&replicas)) - Expect(deployment.Labels).Should(Equal(map[string]string{"thisLabel": "willPropagate"})) + Expect(deployment.Spec.Replicas).To(Equal(&replicas)) + Expect(deployment.Labels).To(Equal(map[string]string{"thisLabel": "willPropagate"})) + Expect(deployment.Spec.Template.Labels).Should(HaveKeyWithValue("thisLabel", "willPropagate")) for _, container := range deployment.Spec.Template.Spec.Containers { if container.Name == authorinoContainerName { Expect(container.Image).Should(Equal(image)) diff --git a/pkg/resources/k8s_deployment.go b/pkg/resources/k8s_deployment.go index 837875a4..69ab2732 100644 --- a/pkg/resources/k8s_deployment.go +++ b/pkg/resources/k8s_deployment.go @@ -9,6 +9,9 @@ import ( func GetDeployment(name, namespace, saName string, replicas *int32, containers []k8score.Container, vol []k8score.Volume, labels map[string]string) *k8sapps.Deployment { objMeta := getObjectMeta(namespace, name, labels) authorinoLabels := labelsForAuthorino(name) + for key, value := range labels { + authorinoLabels[key] = value + } return &k8sapps.Deployment{ ObjectMeta: objMeta,