From a90d651030c90cad303f6e7112060a00204dd97e Mon Sep 17 00:00:00 2001 From: Flavius Lacatusu Date: Wed, 28 Apr 2021 20:34:39 +0200 Subject: [PATCH] fix: Add common selector for che-dashboard Signed-off-by: Flavius Lacatusu --- pkg/deploy/dashboard/dashboard.go | 2 +- pkg/deploy/dashboard/dashboard_test.go | 6 +++--- pkg/deploy/dashboard/deployment_dashboard.go | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/deploy/dashboard/dashboard.go b/pkg/deploy/dashboard/dashboard.go index 822d68e54..0461b316b 100644 --- a/pkg/deploy/dashboard/dashboard.go +++ b/pkg/deploy/dashboard/dashboard.go @@ -18,7 +18,7 @@ import ( const ( // DashboardComponent which is supposed to be used for the naming related objects - DashboardComponent = "dashboard" + DashboardComponent = "che-dashboard" ) type Dashboard struct { diff --git a/pkg/deploy/dashboard/dashboard_test.go b/pkg/deploy/dashboard/dashboard_test.go index 06ce993e3..315ab8cbf 100644 --- a/pkg/deploy/dashboard/dashboard_test.go +++ b/pkg/deploy/dashboard/dashboard_test.go @@ -60,21 +60,21 @@ func TestDashboardAll(t *testing.T) { // check service service := &corev1.Service{} - err = cli.Get(context.TODO(), types.NamespacedName{Name: "dashboard", Namespace: "eclipse-che"}, service) + err = cli.Get(context.TODO(), types.NamespacedName{Name: DashboardComponent, Namespace: "eclipse-che"}, service) if err != nil { t.Fatalf("Service not found: %v", err) } // check endpoint route := &routev1.Route{} - err = cli.Get(context.TODO(), types.NamespacedName{Name: "dashboard", Namespace: "eclipse-che"}, route) + err = cli.Get(context.TODO(), types.NamespacedName{Name: DashboardComponent, Namespace: "eclipse-che"}, route) if err != nil { t.Fatalf("Route not found: %v", err) } // check deployment deployment := &appsv1.Deployment{} - err = cli.Get(context.TODO(), types.NamespacedName{Name: "dashboard", Namespace: "eclipse-che"}, deployment) + err = cli.Get(context.TODO(), types.NamespacedName{Name: DashboardComponent, Namespace: "eclipse-che"}, deployment) if err != nil { t.Fatalf("Deployment not found: %v", err) } diff --git a/pkg/deploy/dashboard/deployment_dashboard.go b/pkg/deploy/dashboard/deployment_dashboard.go index 3e4850876..55a9cc906 100644 --- a/pkg/deploy/dashboard/deployment_dashboard.go +++ b/pkg/deploy/dashboard/deployment_dashboard.go @@ -24,7 +24,8 @@ import ( func (p *Dashboard) getDashboardDeploymentSpec() (*appsv1.Deployment, error) { terminationGracePeriodSeconds := int64(30) - labels := deploy.GetLabels(p.deployContext.CheCluster, DashboardComponent) + labels, labelsSelector := deploy.GetLabelsAndSelector(p.deployContext.CheCluster, DashboardComponent) + dashboardImageAndTag := util.GetValue(p.deployContext.CheCluster.Spec.Server.DashboardImage, deploy.DefaultDashboardImage(p.deployContext.CheCluster)) pullPolicy := corev1.PullPolicy(util.GetValue(p.deployContext.CheCluster.Spec.Server.DashboardImagePullPolicy, deploy.DefaultPullPolicyFromDockerImage(dashboardImageAndTag))) @@ -39,7 +40,7 @@ func (p *Dashboard) getDashboardDeploymentSpec() (*appsv1.Deployment, error) { Labels: labels, }, Spec: appsv1.DeploymentSpec{ - Selector: &metav1.LabelSelector{MatchLabels: labels}, + Selector: &metav1.LabelSelector{MatchLabels: labelsSelector}, Strategy: appsv1.DeploymentStrategy{ Type: appsv1.RollingUpdateDeploymentStrategyType, },