From cdd017a3c10d1ffdc222249beaa20a813149925b Mon Sep 17 00:00:00 2001 From: Peter Braun Date: Mon, 20 May 2019 17:39:15 +0200 Subject: [PATCH] make integreatly version available to webapp --- deploy/template/tutorial-web-app.yml | 2 ++ pkg/handlers/webhandler.go | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/deploy/template/tutorial-web-app.yml b/deploy/template/tutorial-web-app.yml index 49c1eef..dc441e9 100644 --- a/deploy/template/tutorial-web-app.yml +++ b/deploy/template/tutorial-web-app.yml @@ -68,6 +68,8 @@ objects: value: ${SSO_ROUTE} - name: WALKTHROUGH_LOCATIONS value: ${WALKTHROUGH_LOCATIONS} + - name: INTEGREATLY_VERSION + value: ${INTEGREATLY_VERSION} image: quay.io/integreatly/tutorial-web-app:2.10.3 imagePullPolicy: Always name: tutorial-web-app diff --git a/pkg/handlers/webhandler.go b/pkg/handlers/webhandler.go index 5c75cb2..4ed8cbe 100644 --- a/pkg/handlers/webhandler.go +++ b/pkg/handlers/webhandler.go @@ -20,12 +20,14 @@ import ( ) const ( - WebappVersion = "master" - WTLocations = "WALKTHROUGH_LOCATIONS" - WTLocationsDefault = "https://github.com/integr8ly/tutorial-web-app-walkthroughs#v1.6.4" + WebappVersion = "master" + WTLocations = "WALKTHROUGH_LOCATIONS" + IntegreatlyVersion = "INTEGREATLY_VERSION" + WTLocationsDefault = "https://github.com/integr8ly/tutorial-web-app-walkthroughs#v1.6.4" + IntegreatlyVersionDefault = "not set" ) -var webappParams = [...]string{"OPENSHIFT_OAUTHCLIENT_ID", "OPENSHIFT_HOST", "SSO_ROUTE", WTLocations} +var webappParams = [...]string{"OPENSHIFT_OAUTHCLIENT_ID", "OPENSHIFT_HOST", "SSO_ROUTE", IntegreatlyVersion, WTLocations} func NewWebHandler(m *metrics.Metrics, osClient openshift.OSClientInterface, factory ClientFactory, cruder SdkCruder) AppHandler { return AppHandler{ @@ -105,6 +107,8 @@ func (h *AppHandler) reconcile(cr *v1alpha1.WebApp) error { // if WALKTHROUGH_LOCATIONS is not defined then use the default value if param == WTLocations { updated, dc.Spec.Template.Spec.Containers[0] = updateOrCreateEnvVar(dc.Spec.Template.Spec.Containers[0], param, WTLocationsDefault) + } else if param == IntegreatlyVersion { + updated, dc.Spec.Template.Spec.Containers[0] = updateOrCreateEnvVar(dc.Spec.Template.Spec.Containers[0], param, IntegreatlyVersionDefault) } else { //key does not exist in CR, ensure it is not present in the DC updated, dc.Spec.Template.Spec.Containers[0] = deleteEnvVar(dc.Spec.Template.Spec.Containers[0], param)