From 75131e64cd89517ad21dd2a14a173b33840c6103 Mon Sep 17 00:00:00 2001 From: Ruben Romero Montes Date: Mon, 18 Mar 2019 21:09:10 +0100 Subject: [PATCH] Remove constants from commonConfig Signed-off-by: Ruben Romero Montes --- config/common.yaml | 50 ++++---- config/dbs/h2.yaml | 6 +- config/dbs/mysql.yaml | 6 +- config/dbs/postgresql.yaml | 6 +- config/envs/rhdm-authoring-ha.yaml | 40 +++--- config/envs/rhdm-production-immutable.yaml | 6 +- config/envs/rhpam-authoring-ha.yaml | 40 +++--- config/envs/rhpam-production-immutable.yaml | 6 +- .../redhat/catalog-source.yaml | 120 ------------------ deploy/crds/kieapp.crd.yaml | 120 ------------------ deploy/examples/common_config.yaml | 8 -- deploy/examples/server_h2.yaml | 2 +- deploy/examples/server_postgresql.yaml | 2 +- pkg/apis/app/v1/kieapp_types.go | 29 +++-- pkg/apis/app/v1/zz_generated.deepcopy.go | 19 ++- pkg/controller/kieapp/constants/constants.go | 22 +++- pkg/controller/kieapp/defaults/defaults.go | 43 ++++--- .../kieapp/defaults/defaults_test.go | 8 +- pkg/controller/kieapp/kieapp_controller.go | 6 +- 19 files changed, 166 insertions(+), 373 deletions(-) diff --git a/config/common.yaml b/config/common.yaml index c16796158..56ef74d0d 100644 --- a/config/common.yaml +++ b/config/common.yaml @@ -18,7 +18,7 @@ console: from: kind: ImageStreamTag namespace: openshift - name: "[[.Product]][[.Version]]-[[.Console.ImageName]]-openshift:[[.ImageTag]]" + name: "[[.Constants.Product]][[.Version]]-[[.Console.ImageName]]-openshift:[[.ImageTag]]" - type: ConfigChange replicas: [[.Console.Replicas]] selector: @@ -32,11 +32,11 @@ console: application: "[[.ApplicationName]]" service: "[[.ApplicationName]]-[[.Console.Name]]" spec: - serviceAccountName: "[[.ApplicationName]]-[[.Product]]svc" + serviceAccountName: "[[.ApplicationName]]-[[.Constants.Product]]svc" terminationGracePeriodSeconds: 60 containers: - name: "[[.ApplicationName]]-[[.Console.Name]]" - image: "[[.Product]][[.Version]]-[[.Console.ImageName]]-openshift" + image: "[[.Constants.Product]][[.Version]]-[[.Console.ImageName]]-openshift" imagePullPolicy: Always resources: limits: @@ -199,13 +199,13 @@ console: ## RoleMapping config END # Auth config END volumeMounts: - - name: "[[.ApplicationName]]-[[.Console.Name]]-keystore-volume" + - name: "[[.ApplicationName]]-[[.Console.Name]]-[[.Constants.KeystoreVolumeSuffix]]" mountPath: "/etc/businesscentral-secret-volume" readOnly: true - name: "[[.ApplicationName]]-[[.Console.Name]]-pvol" mountPath: "/opt/eap/standalone/data/kie" volumes: - - name: "[[.ApplicationName]]-[[.Console.Name]]-keystore-volume" + - name: "[[.ApplicationName]]-[[.Console.Name]]-[[.Constants.KeystoreVolumeSuffix]]" secret: secretName: "[[.Console.KeystoreSecret]]" - name: "[[.ApplicationName]]-[[.Console.Name]]-pvol" @@ -310,7 +310,7 @@ smartRouter: from: kind: ImageStreamTag namespace: "openshift" - name: "[[.Product]][[.Version]]-smartrouter-openshift:[[.ImageTag]]" + name: "[[.Constants.Product]][[.Version]]-smartrouter-openshift:[[.ImageTag]]" - type: ConfigChange replicas: [[.SmartRouter.Replicas]] selector: @@ -327,7 +327,7 @@ smartRouter: terminationGracePeriodSeconds: 60 containers: - name: "[[.ApplicationName]]-smartrouter" - image: "[[.Product]][[.Version]]-smartrouter-openshift" + image: "[[.Constants.Product]][[.Version]]-smartrouter-openshift" imagePullPolicy: Always resources: limits: @@ -364,20 +364,20 @@ smartRouter: - name: KIE_SERVER_CONTROLLER_PROTOCOL value: "http" - name: KIE_SERVER_ROUTER_REPO - value: "/opt/[[.Product]]-smartrouter/data" + value: "/opt/[[.Constants.Product]]-smartrouter/data" - name: KIE_SERVER_ROUTER_CONFIG_WATCHER_ENABLED value: "true" volumeMounts: - name: "[[.ApplicationName]]-smartrouter" - mountPath: "/opt/[[.Product]]-smartrouter/data" - - name: smartrouter-keystore-volume + mountPath: "/opt/[[.Constants.Product]]-smartrouter/data" + - name: smartrouter-[[.Constants.KeystoreVolumeSuffix]] mountPath: "/etc/smartrouter-secret-volume" readOnly: true volumes: - name: "[[.ApplicationName]]-smartrouter" persistentVolumeClaim: claimName: "[[.ApplicationName]]-smartrouter-claim" - - name: smartrouter-keystore-volume + - name: smartrouter-[[.Constants.KeystoreVolumeSuffix]] secret: secretName: "[[.SmartRouter.KeystoreSecret]]" services: @@ -459,11 +459,11 @@ servers: service: "[[.KieName]]" deploymentConfig: "[[.KieName]]" spec: - serviceAccountName: "[[$.ApplicationName]]-[[$.Product]]svc" + serviceAccountName: "[[$.ApplicationName]]-[[$.Constants.Product]]svc" terminationGracePeriodSeconds: 60 containers: - name: "[[.KieName]]" - image: "[[$.Product]][[$.Version]]-kieserver-openshift" + image: "[[$.Constants.Product]][[$.Version]]-kieserver-openshift" imagePullPolicy: Always env: - name: KIE_ADMIN_USER @@ -496,15 +496,15 @@ servers: fieldPath: status.podIP - name: KIE_SERVER_ID value: "[[.KieName]]" - - name: "[[$.MavenRepo]]_MAVEN_REPO_USERNAME" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_USERNAME" value: mavenUser - - name: "[[$.MavenRepo]]_MAVEN_REPO_PASSWORD" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_PASSWORD" value: "[[$.MavenPassword]]" - - name: "[[$.MavenRepo]]_MAVEN_REPO_SERVICE" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_SERVICE" value: "[[$.ApplicationName]]-[[$.Console.Name]]" - name: MAVEN_REPOS - value: "[[$.MavenRepo]],EXTERNAL" - - name: "[[$.MavenRepo]]_MAVEN_REPO_PATH" + value: "[[$.Constants.MavenRepo]],EXTERNAL" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_PATH" value: /maven2/ - name: KIE_SERVER_BYPASS_AUTH_USER value: "false" @@ -642,10 +642,10 @@ servers: protocol: TCP volumeMounts: - mountPath: /etc/kieserver-secret-volume - name: kieserver-keystore-volume + name: kieserver-[[$.Constants.KeystoreVolumeSuffix]] readOnly: true volumes: - - name: kieserver-keystore-volume + - name: kieserver-[[$.Constants.KeystoreVolumeSuffix]] secret: secretName: "[[.KeystoreSecret]]" ## KIE server deployment config END @@ -720,7 +720,7 @@ servers: others: - roles: - metadata: - name: "[[.ApplicationName]]-[[.Product]]svc-edit" + name: "[[.ApplicationName]]-[[.Constants.Product]]svc-edit" rules: - apiGroups: - "" @@ -740,18 +740,18 @@ others: serviceAccounts: - metadata: - name: "[[.ApplicationName]]-[[.Product]]svc" + name: "[[.ApplicationName]]-[[.Constants.Product]]svc" labels: app: "[[.ApplicationName]]" application: "[[.ApplicationName]]" rolebindings: - metadata: - name: "[[.ApplicationName]]-[[.Product]]svc-edit" + name: "[[.ApplicationName]]-[[.Constants.Product]]svc-edit" subjects: - kind: ServiceAccount - name: "[[.ApplicationName]]-[[.Product]]svc" + name: "[[.ApplicationName]]-[[.Constants.Product]]svc" roleRef: kind: Role - name: "[[.ApplicationName]]-[[.Product]]svc-edit" + name: "[[.ApplicationName]]-[[.Constants.Product]]svc-edit" # Other required resources END diff --git a/config/dbs/h2.yaml b/config/dbs/h2.yaml index 01a669394..8db665d1d 100644 --- a/config/dbs/h2.yaml +++ b/config/dbs/h2.yaml @@ -14,12 +14,12 @@ servers: containers: - name: "[[.KieName]]" volumeMounts: - - name: "[[.KieName]]-h2-pvol" + - name: "[[.KieName]]-h2-[[$.Constants.DatabaseVolumeSuffix]]" mountPath: "/opt/eap/standalone/data" ## [[ if ne .Database.Size "" ]] volumes: ## H2 volume settings BEGIN - - name: "[[.KieName]]-h2-pvol" + - name: "[[.KieName]]-h2-[[$.Constants.DatabaseVolumeSuffix]]" persistentVolumeClaim: claimName: "[[.KieName]]-h2-claim" ## KIE server deployment config END @@ -41,7 +41,7 @@ servers: ## [[ else ]] volumes: ## H2 volume settings BEGIN - - name: "[[.KieName]]-h2-pvol" + - name: "[[.KieName]]-h2-[[$.Constants.DatabaseVolumeSuffix]]" emptyDir: {} ## [[ end ]] #[[end]] diff --git a/config/dbs/mysql.yaml b/config/dbs/mysql.yaml index 68cdd63d3..f8e89e5b5 100644 --- a/config/dbs/mysql.yaml +++ b/config/dbs/mysql.yaml @@ -104,10 +104,10 @@ servers: value: "rhpam7" volumeMounts: - mountPath: "/var/lib/mysql/data" - name: "[[.KieName]]-mysql-pvol" + name: "[[.KieName]]-mysql-[[$.Constants.DatabaseVolumeSuffix]]" ## [[ if ne .Database.Size "" ]] volumes: - - name: "[[.KieName]]-mysql-pvol" + - name: "[[.KieName]]-mysql-[[$.Constants.DatabaseVolumeSuffix]]" persistentVolumeClaim: claimName: "[[.KieName]]-mysql-claim" ## MySQL persistent volume claim BEGIN @@ -127,7 +127,7 @@ servers: ## MySQL persistent volume claim END ## [[ else ]] volumes: - - name: "[[.KieName]]-mysql-pvol" + - name: "[[.KieName]]-mysql-[[$.Constants.DatabaseVolumeSuffix]]" emptyDir: {} ## [[ end ]] ## MySQL deployment END diff --git a/config/dbs/postgresql.yaml b/config/dbs/postgresql.yaml index c8de662d7..37c43d18e 100644 --- a/config/dbs/postgresql.yaml +++ b/config/dbs/postgresql.yaml @@ -103,10 +103,10 @@ servers: value: "100" volumeMounts: - mountPath: "/var/lib/pgsql/data" - name: "[[.KieName]]-postgresql-pvol" + name: "[[.KieName]]-postgresql-[[$.Constants.DatabaseVolumeSuffix]]" ## [[ if ne .Database.Size "" ]] volumes: - - name: "[[.KieName]]-postgresql-pvol" + - name: "[[.KieName]]-postgresql-[[$.Constants.DatabaseVolumeSuffix]]" persistentVolumeClaim: claimName: "[[.KieName]]-postgresql-claim" ## PostgreSQL deployment config END @@ -127,7 +127,7 @@ servers: ## PostgreSQL persistent volume claim END ## [[ else ]] volumes: - - name: "[[.KieName]]-postgresql-pvol" + - name: "[[.KieName]]-postgresql-[[$.Constants.DatabaseVolumeSuffix]]" emptyDir: {} ## [[ end ]] services: diff --git a/config/envs/rhdm-authoring-ha.yaml b/config/envs/rhdm-authoring-ha.yaml index da7ddc389..62c9f1df8 100644 --- a/config/envs/rhdm-authoring-ha.yaml +++ b/config/envs/rhdm-authoring-ha.yaml @@ -31,7 +31,7 @@ console: protocol: TCP env: - name: APPFORMER_ELASTIC_HOST - value: "[[.ApplicationName]]-[[.Product]]index" + value: "[[.ApplicationName]]-[[.Constants.Product]]index" - name: APPFORMER_JMS_BROKER_ADDRESS value: "[[.ApplicationName]]-amq-tcp" - name: APPFORMER_JMS_BROKER_USER @@ -60,7 +60,7 @@ smartRouter: others: - persistentVolumeClaims: - metadata: - name: "[[.ApplicationName]]-[[.Product]]index-claim" + name: "[[.ApplicationName]]-[[.Constants.Product]]index-claim" labels: app: "[[.ApplicationName]]" application: "[[.ApplicationName]]" @@ -73,11 +73,11 @@ others: deploymentConfigs: - metadata: - name: "[[.ApplicationName]]-[[.Product]]index" + name: "[[.ApplicationName]]-[[.Constants.Product]]index" labels: app: "[[.ApplicationName]]" application: "[[.ApplicationName]]" - service: "[[.ApplicationName]]-[[.Product]]index" + service: "[[.ApplicationName]]-[[.Constants.Product]]index" spec: strategy: type: Recreate @@ -86,30 +86,30 @@ others: imageChangeParams: automatic: true containerNames: - - "[[.ApplicationName]]-[[.Product]]index" + - "[[.ApplicationName]]-[[.Constants.Product]]index" from: kind: ImageStreamTag namespace: "openshift" - name: "[[.Product]][[.Version]]-[[.Console.ImageName]]-indexing-openshift:[[.ImageTag]]" + name: "[[.Constants.Product]][[.Version]]-[[.Console.ImageName]]-indexing-openshift:[[.ImageTag]]" - type: ConfigChange replicas: 1 selector: - deploymentConfig: "[[.ApplicationName]]-[[.Product]]index" + deploymentConfig: "[[.ApplicationName]]-[[.Constants.Product]]index" template: metadata: - name: "[[.ApplicationName]]-[[.Product]]index" + name: "[[.ApplicationName]]-[[.Constants.Product]]index" labels: - deploymentConfig: "[[.ApplicationName]]-[[.Product]]index" + deploymentConfig: "[[.ApplicationName]]-[[.Constants.Product]]index" app: "[[.ApplicationName]]" application: "[[.ApplicationName]]" spec: terminationGracePeriodSeconds: 60 containers: - - name: "[[.ApplicationName]]-[[.Product]]index" - image: "[[.Product]][[.Version]]-[[.Console.ImageName]]-indexing-openshift" + - name: "[[.ApplicationName]]-[[.Constants.Product]]index" + image: "[[.Constants.Product]][[.Version]]-[[.Console.ImageName]]-indexing-openshift" imagePullPolicy: Always volumeMounts: - - name: "[[.ApplicationName]]-[[.Product]]index-pvol" + - name: "[[.ApplicationName]]-[[.Constants.Product]]index-pvol" mountPath: "/opt/elasticsearch/data" livenessProbe: tcpSocket: @@ -131,9 +131,9 @@ others: containerPort: 9200 protocol: TCP volumes: - - name: "[[.ApplicationName]]-[[.Product]]index-pvol" + - name: "[[.ApplicationName]]-[[.Constants.Product]]index-pvol" persistentVolumeClaim: - claimName: "[[.ApplicationName]]-[[.Product]]index-claim" + claimName: "[[.ApplicationName]]-[[.Constants.Product]]index-claim" - metadata: labels: @@ -238,20 +238,20 @@ others: port: 9300 targetPort: 9300 selector: - deploymentConfig: "[[.ApplicationName]]-[[.Product]]index" + deploymentConfig: "[[.ApplicationName]]-[[.Constants.Product]]index" metadata: - name: "[[.ApplicationName]]-[[.Product]]index" + name: "[[.ApplicationName]]-[[.Constants.Product]]index" labels: app: "[[.ApplicationName]]" application: "[[.ApplicationName]]" - service: "[[.ApplicationName]]-[[.Product]]index" + service: "[[.ApplicationName]]-[[.Constants.Product]]index" annotations: description: All the Decision Central Indexing Elasticsearch ports. routes: - - id: "[[.ApplicationName]]-[[.Product]]index-http" + - id: "[[.ApplicationName]]-[[.Constants.Product]]index-http" metadata: - name: "[[.ApplicationName]]-[[.Product]]index" + name: "[[.ApplicationName]]-[[.Constants.Product]]index" labels: app: "[[.ApplicationName]]" application: "[[.ApplicationName]]" @@ -260,7 +260,7 @@ others: spec: host: "" to: - name: "[[.ApplicationName]]-[[.Product]]index" + name: "[[.ApplicationName]]-[[.Constants.Product]]index" port: targetPort: rest ## ES/AMQ END diff --git a/config/envs/rhdm-production-immutable.yaml b/config/envs/rhdm-production-immutable.yaml index 0c2d62ea1..b7d7cad58 100644 --- a/config/envs/rhdm-production-immutable.yaml +++ b/config/envs/rhdm-production-immutable.yaml @@ -27,11 +27,11 @@ servers: value: "true" - name: KIE_SERVER_STARTUP_STRATEGY value: LocalContainersStartupStrategy - - name: "[[$.MavenRepo]]_MAVEN_REPO_USERNAME" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_USERNAME" value: "" - - name: "[[$.MavenRepo]]_MAVEN_REPO_PASSWORD" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_PASSWORD" value: "" - - name: "[[$.MavenRepo]]_MAVEN_REPO_SERVICE" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_SERVICE" value: "" - name: MAVEN_REPOS value: "EXTERNAL" diff --git a/config/envs/rhpam-authoring-ha.yaml b/config/envs/rhpam-authoring-ha.yaml index 312fc50bb..bfc47a4ec 100644 --- a/config/envs/rhpam-authoring-ha.yaml +++ b/config/envs/rhpam-authoring-ha.yaml @@ -31,7 +31,7 @@ console: protocol: TCP env: - name: APPFORMER_ELASTIC_HOST - value: "[[.ApplicationName]]-[[.Product]]index" + value: "[[.ApplicationName]]-[[.Constants.Product]]index" - name: APPFORMER_JMS_BROKER_ADDRESS value: "[[.ApplicationName]]-amq-tcp" - name: APPFORMER_JMS_BROKER_USER @@ -60,7 +60,7 @@ smartRouter: others: - persistentVolumeClaims: - metadata: - name: "[[.ApplicationName]]-[[.Product]]index-claim" + name: "[[.ApplicationName]]-[[.Constants.Product]]index-claim" labels: app: "[[.ApplicationName]]" application: "[[.ApplicationName]]" @@ -73,10 +73,10 @@ others: deploymentConfigs: - metadata: - name: "[[.ApplicationName]]-[[.Product]]index" + name: "[[.ApplicationName]]-[[.Constants.Product]]index" labels: app: "[[.ApplicationName]]" - service: "[[.ApplicationName]]-[[.Product]]index" + service: "[[.ApplicationName]]-[[.Constants.Product]]index" spec: strategy: type: Recreate @@ -85,30 +85,30 @@ others: imageChangeParams: automatic: true containerNames: - - "[[.ApplicationName]]-[[.Product]]index" + - "[[.ApplicationName]]-[[.Constants.Product]]index" from: kind: ImageStreamTag namespace: "openshift" - name: "[[.Product]][[.Version]]-[[.Console.ImageName]]-indexing-openshift:[[.ImageTag]]" + name: "[[.Constants.Product]][[.Version]]-[[.Console.ImageName]]-indexing-openshift:[[.ImageTag]]" - type: ConfigChange replicas: 1 selector: - deploymentConfig: "[[.ApplicationName]]-[[.Product]]index" + deploymentConfig: "[[.ApplicationName]]-[[.Constants.Product]]index" template: metadata: - name: "[[.ApplicationName]]-[[.Product]]index" + name: "[[.ApplicationName]]-[[.Constants.Product]]index" labels: - deploymentConfig: "[[.ApplicationName]]-[[.Product]]index" + deploymentConfig: "[[.ApplicationName]]-[[.Constants.Product]]index" app: "[[.ApplicationName]]" application: "[[.ApplicationName]]" spec: terminationGracePeriodSeconds: 60 containers: - - name: "[[.ApplicationName]]-[[.Product]]index" - image: "[[.Product]][[.Version]]-[[.Console.ImageName]]-indexing-openshift" + - name: "[[.ApplicationName]]-[[.Constants.Product]]index" + image: "[[.Constants.Product]][[.Version]]-[[.Console.ImageName]]-indexing-openshift" imagePullPolicy: Always volumeMounts: - - name: "[[.ApplicationName]]-[[.Product]]index-pvol" + - name: "[[.ApplicationName]]-[[.Constants.Product]]index-pvol" mountPath: "/opt/elasticsearch/data" livenessProbe: tcpSocket: @@ -130,9 +130,9 @@ others: containerPort: 9200 protocol: TCP volumes: - - name: "[[.ApplicationName]]-[[.Product]]index-pvol" + - name: "[[.ApplicationName]]-[[.Constants.Product]]index-pvol" persistentVolumeClaim: - claimName: "[[.ApplicationName]]-[[.Product]]index-claim" + claimName: "[[.ApplicationName]]-[[.Constants.Product]]index-claim" - metadata: labels: @@ -237,20 +237,20 @@ others: port: 9300 targetPort: 9300 selector: - deploymentConfig: "[[.ApplicationName]]-[[.Product]]index" + deploymentConfig: "[[.ApplicationName]]-[[.Constants.Product]]index" metadata: - name: "[[.ApplicationName]]-[[.Product]]index" + name: "[[.ApplicationName]]-[[.Constants.Product]]index" labels: app: "[[.ApplicationName]]" application: "[[.ApplicationName]]" - service: "[[.ApplicationName]]-[[.Product]]index" + service: "[[.ApplicationName]]-[[.Constants.Product]]index" annotations: description: All the Business Central Indexing Elasticsearch ports. routes: - - id: "[[.ApplicationName]]-[[.Product]]index-http" + - id: "[[.ApplicationName]]-[[.Constants.Product]]index-http" metadata: - name: "[[.ApplicationName]]-[[.Product]]index" + name: "[[.ApplicationName]]-[[.Constants.Product]]index" labels: app: "[[.ApplicationName]]" application: "[[.ApplicationName]]" @@ -259,7 +259,7 @@ others: spec: host: "" to: - name: "[[.ApplicationName]]-[[.Product]]index" + name: "[[.ApplicationName]]-[[.Constants.Product]]index" port: targetPort: rest diff --git a/config/envs/rhpam-production-immutable.yaml b/config/envs/rhpam-production-immutable.yaml index 05cd2657e..7c39c1cc8 100644 --- a/config/envs/rhpam-production-immutable.yaml +++ b/config/envs/rhpam-production-immutable.yaml @@ -27,11 +27,11 @@ servers: value: "true" - name: KIE_SERVER_STARTUP_STRATEGY value: LocalContainersStartupStrategy - - name: "[[$.MavenRepo]]_MAVEN_REPO_USERNAME" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_USERNAME" value: "" - - name: "[[$.MavenRepo]]_MAVEN_REPO_PASSWORD" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_PASSWORD" value: "" - - name: "[[$.MavenRepo]]_MAVEN_REPO_SERVICE" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_SERVICE" value: "" - name: MAVEN_REPOS value: "EXTERNAL" diff --git a/deploy/catalog_resources/redhat/catalog-source.yaml b/deploy/catalog_resources/redhat/catalog-source.yaml index 75a03ed7c..ec215e6db 100644 --- a/deploy/catalog_resources/redhat/catalog-source.yaml +++ b/deploy/catalog_resources/redhat/catalog-source.yaml @@ -264,12 +264,6 @@ items: imageTag: type: string description: The tag to use for the application images. - product: - type: string - description: The name of the product to deploy. - enum: - - rhdm - - rhpam keyStorePassword: type: string description: The password to use for keystore generation. @@ -282,123 +276,9 @@ items: serverPassword: type: string description: The password to use for the executionUser. - mavenRepo: - type: string - description: The prefix to use for the maven env variables. mavenPassword: type: string description: The password to use for the mavenUser. - auth: - type: object - description: Authentication integration configuration - properties: - sso: - type: object - description: RH-SSO integration configuration - properties: - url: - type: string - description: RH-SSO URL - realm: - type: string - description: RH-SSO Realm name - adminUser: - type: string - description: RH-SSO Realm Admin Username used to create the Client if it doesn't exist - adminPassword: - type: string - format: password - description: RH-SSO Realm Admin Password used to create the Client - disableSSLCertValidation: - type: boolean - description: RH-SSO Disable SSL Certificate Validation - principalAttribute: - type: string - description: RH-SSO Principal Attribute to use as username - ldap: - type: object - description: LDAP integration configuration - properties: - url: - type: string - description: LDAP Endpoint to connect for authentication - bindDN: - type: string - description: Bind DN used for authentication - bindCredential: - type: string - format: password - description: LDAP Credentials used for authentication - jaasSecurityDomain: - type: string - description: The JMX ObjectName of the JaasSecurityDomain used to decrypt the password. - baseCtxDN: - type: string - description: LDAP Base DN of the top-level context to begin the user search. - baseFilter: - type: string - description: DAP search filter used to locate the context of the user to authenticate. The input username or userDN obtained from the login module callback is substituted into the filter anywhere a {0} expression is used. A common example for the search filter is (uid={0}). - searchScope: - type: string - enum: - - SUBTREE_SCOPE - - OBJECT_SCOPE - - ONELEVEL_SCOPE - description: The search scope to use. - searchTimeLimit: - type: integer - format: int32 - description: The timeout in milliseconds for user or role searches. - distinguishedNameAttribute: - type: string - description: The name of the attribute in the user entry that contains the DN of the user. This may be necessary if the DN of the user itself contains special characters, backslash for example, that prevent correct user mapping. If the attribute does not exist, the entry’s DN is used. - parseUsername: - type: boolean - description: A flag indicating if the DN is to be parsed for the username. If set to true, the DN is parsed for the username. If set to false the DN is not parsed for the username. This option is used together with usernameBeginString and usernameEndString. - usernameBeginString: - type: string - description: Defines the String which is to be removed from the start of the DN to reveal the username. This option is used together with usernameEndString and only taken into account if parseUsername is set to true. - usernameEndString: - type: string - description: Defines the String which is to be removed from the end of the DN to reveal the username. This option is used together with usernameBeginString and only taken into account if parseUsername is set to true. - roleAttributeID: - type: string - description: Name of the attribute containing the user roles. - rolesCtxDN: - type: string - description: The fixed DN of the context to search for user roles. This is not the DN where the actual roles are, but the DN where the objects containing the user roles are. For example, in a Microsoft Active Directory server, this is the DN where the user account is. - roleFilter: - type: string - description: A search filter used to locate the roles associated with the authenticated user. The input username or userDN obtained from the login module callback is substituted into the filter anywhere a {0} expression is used. The authenticated userDN is substituted into the filter anywhere a {1} is used. An example search filter that matches on the input username is (member={0}). An alternative that matches on the authenticated userDN is (member={1}). - roleRecursion: - type: integer - format: int16 - description: The number of levels of recursion the role search will go below a matching context. Disable recursion by setting this to 0. - defaultRole: - type: string - description: A role included for all authenticated users - roleNameAttributeID: - type: string - description: Name of the attribute within the roleCtxDN context which contains the role name. If the roleAttributeIsDN property is set to true, this property is used to find the role object’s name attribute. - parseRoleNameFromDN: - type: boolean - description: A flag indicating if the DN returned by a query contains the roleNameAttributeID. If set to true, the DN is checked for the roleNameAttributeID. If set to false, the DN is not checked for the roleNameAttributeID. This flag can improve the performance of LDAP queries. - roleAttributeIsDN: - type: boolean - description: Whether or not the roleAttributeID contains the fully-qualified DN of a role object. If false, the role name is taken from the value of the roleNameAttributeId attribute of the context name. Certain directory schemas, such as Microsoft Active Directory, require this attribute to be set to true. - referralUserAttributeIDToCheck: - type: string - description: If you are not using referrals, you can ignore this option. When using referrals, this option denotes the attribute name which contains users defined for a certain role, for example member, if the role object is inside the referral. Users are checked against the content of this attribute name. If this option is not set, the check will always fail, so role objects cannot be stored in a referral tree. - roleMapper: - type: object - description: RoleMapper configuration - properties: - rolesProperties: - type: string - description: When present, the RoleMapping Login Module will be configured to use the provided file. This property defines the fully-qualified file path and name of a properties file or resource which maps roles to replacement roles. The format is original_role=role1,role2,role3 - replaceRole: - type: boolean - description: Whether to add to the current roles, or replace the current roles with the mapped ones. Replaces if set to true. objects: type: object description: Configuration of the RHPAM components diff --git a/deploy/crds/kieapp.crd.yaml b/deploy/crds/kieapp.crd.yaml index 362be7c70..9d10aa6cb 100644 --- a/deploy/crds/kieapp.crd.yaml +++ b/deploy/crds/kieapp.crd.yaml @@ -47,12 +47,6 @@ spec: imageTag: type: string description: The tag to use for the application images. - product: - type: string - description: The name of the product to deploy. - enum: - - rhdm - - rhpam keyStorePassword: type: string description: The password to use for keystore generation. @@ -65,123 +59,9 @@ spec: serverPassword: type: string description: The password to use for the executionUser. - mavenRepo: - type: string - description: The prefix to use for the maven env variables. mavenPassword: type: string description: The password to use for the mavenUser. - auth: - type: object - description: Authentication integration configuration - properties: - sso: - type: object - description: RH-SSO integration configuration - properties: - url: - type: string - description: RH-SSO URL - realm: - type: string - description: RH-SSO Realm name - adminUser: - type: string - description: RH-SSO Realm Admin Username used to create the Client if it doesn't exist - adminPassword: - type: string - format: password - description: RH-SSO Realm Admin Password used to create the Client - disableSSLCertValidation: - type: boolean - description: RH-SSO Disable SSL Certificate Validation - principalAttribute: - type: string - description: RH-SSO Principal Attribute to use as username - ldap: - type: object - description: LDAP integration configuration - properties: - url: - type: string - description: LDAP Endpoint to connect for authentication - bindDN: - type: string - description: Bind DN used for authentication - bindCredential: - type: string - format: password - description: LDAP Credentials used for authentication - jaasSecurityDomain: - type: string - description: The JMX ObjectName of the JaasSecurityDomain used to decrypt the password. - baseCtxDN: - type: string - description: LDAP Base DN of the top-level context to begin the user search. - baseFilter: - type: string - description: DAP search filter used to locate the context of the user to authenticate. The input username or userDN obtained from the login module callback is substituted into the filter anywhere a {0} expression is used. A common example for the search filter is (uid={0}). - searchScope: - type: string - enum: - - SUBTREE_SCOPE - - OBJECT_SCOPE - - ONELEVEL_SCOPE - description: The search scope to use. - searchTimeLimit: - type: integer - format: int32 - description: The timeout in milliseconds for user or role searches. - distinguishedNameAttribute: - type: string - description: The name of the attribute in the user entry that contains the DN of the user. This may be necessary if the DN of the user itself contains special characters, backslash for example, that prevent correct user mapping. If the attribute does not exist, the entry’s DN is used. - parseUsername: - type: boolean - description: A flag indicating if the DN is to be parsed for the username. If set to true, the DN is parsed for the username. If set to false the DN is not parsed for the username. This option is used together with usernameBeginString and usernameEndString. - usernameBeginString: - type: string - description: Defines the String which is to be removed from the start of the DN to reveal the username. This option is used together with usernameEndString and only taken into account if parseUsername is set to true. - usernameEndString: - type: string - description: Defines the String which is to be removed from the end of the DN to reveal the username. This option is used together with usernameBeginString and only taken into account if parseUsername is set to true. - roleAttributeID: - type: string - description: Name of the attribute containing the user roles. - rolesCtxDN: - type: string - description: The fixed DN of the context to search for user roles. This is not the DN where the actual roles are, but the DN where the objects containing the user roles are. For example, in a Microsoft Active Directory server, this is the DN where the user account is. - roleFilter: - type: string - description: A search filter used to locate the roles associated with the authenticated user. The input username or userDN obtained from the login module callback is substituted into the filter anywhere a {0} expression is used. The authenticated userDN is substituted into the filter anywhere a {1} is used. An example search filter that matches on the input username is (member={0}). An alternative that matches on the authenticated userDN is (member={1}). - roleRecursion: - type: integer - format: int16 - description: The number of levels of recursion the role search will go below a matching context. Disable recursion by setting this to 0. - defaultRole: - type: string - description: A role included for all authenticated users - roleNameAttributeID: - type: string - description: Name of the attribute within the roleCtxDN context which contains the role name. If the roleAttributeIsDN property is set to true, this property is used to find the role object’s name attribute. - parseRoleNameFromDN: - type: boolean - description: A flag indicating if the DN returned by a query contains the roleNameAttributeID. If set to true, the DN is checked for the roleNameAttributeID. If set to false, the DN is not checked for the roleNameAttributeID. This flag can improve the performance of LDAP queries. - roleAttributeIsDN: - type: boolean - description: Whether or not the roleAttributeID contains the fully-qualified DN of a role object. If false, the role name is taken from the value of the roleNameAttributeId attribute of the context name. Certain directory schemas, such as Microsoft Active Directory, require this attribute to be set to true. - referralUserAttributeIDToCheck: - type: string - description: If you are not using referrals, you can ignore this option. When using referrals, this option denotes the attribute name which contains users defined for a certain role, for example member, if the role object is inside the referral. Users are checked against the content of this attribute name. If this option is not set, the check will always fail, so role objects cannot be stored in a referral tree. - roleMapper: - type: object - description: RoleMapper configuration - properties: - rolesProperties: - type: string - description: When present, the RoleMapping Login Module will be configured to use the provided file. This property defines the fully-qualified file path and name of a properties file or resource which maps roles to replacement roles. The format is original_role=role1,role2,role3 - replaceRole: - type: boolean - description: Whether to add to the current roles, or replace the current roles with the mapped ones. Replaces if set to true. objects: type: object description: Configuration of the RHPAM components diff --git a/deploy/examples/common_config.yaml b/deploy/examples/common_config.yaml index 4f40c8e81..10a53def5 100644 --- a/deploy/examples/common_config.yaml +++ b/deploy/examples/common_config.yaml @@ -9,11 +9,3 @@ spec: applicationName: other adminPassword: example imageTag: 1.0-stage - mavenRepo: INTERNAL - product: rhpam - auth: - sso: - url: https://rh-sso.example.com - realm: rhpam - adminUser: admin - adminPassword: secret diff --git a/deploy/examples/server_h2.yaml b/deploy/examples/server_h2.yaml index f78d2c9d7..6ff95814c 100644 --- a/deploy/examples/server_h2.yaml +++ b/deploy/examples/server_h2.yaml @@ -1,7 +1,7 @@ apiVersion: app.kiegroup.org/v1 kind: KieApp metadata: - name: server-mysqldb + name: server-h2 spec: environment: rhpam-trial objects: diff --git a/deploy/examples/server_postgresql.yaml b/deploy/examples/server_postgresql.yaml index 8d83ed598..0170695d1 100644 --- a/deploy/examples/server_postgresql.yaml +++ b/deploy/examples/server_postgresql.yaml @@ -1,7 +1,7 @@ apiVersion: app.kiegroup.org/v1 kind: KieApp metadata: - name: server-mysqldb + name: server-postgresql spec: environment: rhpam-trial objects: diff --git a/pkg/apis/app/v1/kieapp_types.go b/pkg/apis/app/v1/kieapp_types.go index b772b4138..ac73e132e 100644 --- a/pkg/apis/app/v1/kieapp_types.go +++ b/pkg/apis/app/v1/kieapp_types.go @@ -305,6 +305,16 @@ type EnvTemplate struct { Console ConsoleTemplate `json:"console,omitempty"` Servers []ServerTemplate `json:"servers,omitempty"` SmartRouter SmartRouterTemplate `json:"smartRouter,omitempty"` + Auth AuthTemplate `json:"auth,omitempty"` + Constants TemplateConstants `json:"constants,omitempty"` +} + +// TemplateConstants constant values that are used within the different configuration templates +type TemplateConstants struct { + Product string `json:"product,omitempty"` + MavenRepo string `json:"mavenRepo,omitempty"` + KeystoreVolumeSuffix string `json:"keystoreVolumeSuffix"` + DatabaseVolumeSuffix string `json:"databaseVolumeSuffix"` } // ConsoleTemplate contains all the variables used in the yaml templates @@ -359,17 +369,14 @@ type BuildTemplate struct { } type CommonConfig struct { - ApplicationName string `json:"applicationName,omitempty"` - Auth AuthTemplate `json:"auth,omitempty"` - Version string `json:"version,omitempty"` - ImageTag string `json:"imageTag,omitempty"` - Product string `json:"product,omitempty"` - KeyStorePassword string `json:"keyStorePassword,omitempty"` - AdminPassword string `json:"adminPassword,omitempty"` - ControllerPassword string `json:"controllerPassword,omitempty"` - ServerPassword string `json:"serverPassword,omitempty"` - MavenRepo string `json:"mavenRepo,omitempty"` - MavenPassword string `json:"mavenPassword,omitempty"` + ApplicationName string `json:"applicationName,omitempty"` + Version string `json:"version,omitempty"` + ImageTag string `json:"imageTag,omitempty"` + KeyStorePassword string `json:"keyStorePassword,omitempty"` + AdminPassword string `json:"adminPassword,omitempty"` + ControllerPassword string `json:"controllerPassword,omitempty"` + ServerPassword string `json:"serverPassword,omitempty"` + MavenPassword string `json:"mavenPassword,omitempty"` } // AuthTemplate Authentication definition used in the template diff --git a/pkg/apis/app/v1/zz_generated.deepcopy.go b/pkg/apis/app/v1/zz_generated.deepcopy.go index 39547a976..fdad149ed 100644 --- a/pkg/apis/app/v1/zz_generated.deepcopy.go +++ b/pkg/apis/app/v1/zz_generated.deepcopy.go @@ -86,7 +86,6 @@ func (in *BuildTemplate) DeepCopy() *BuildTemplate { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CommonConfig) DeepCopyInto(out *CommonConfig) { *out = *in - out.Auth = in.Auth return } @@ -258,6 +257,8 @@ func (in *EnvTemplate) DeepCopyInto(out *EnvTemplate) { } } out.SmartRouter = in.SmartRouter + out.Auth = in.Auth + out.Constants = in.Constants return } @@ -789,6 +790,22 @@ func (in *SmartRouterTemplate) DeepCopy() *SmartRouterTemplate { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TemplateConstants) DeepCopyInto(out *TemplateConstants) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TemplateConstants. +func (in *TemplateConstants) DeepCopy() *TemplateConstants { + if in == nil { + return nil + } + out := new(TemplateConstants) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WebhookSecret) DeepCopyInto(out *WebhookSecret) { *out = *in diff --git a/pkg/controller/kieapp/constants/constants.go b/pkg/controller/kieapp/constants/constants.go index bd4313ed7..d0eba107c 100644 --- a/pkg/controller/kieapp/constants/constants.go +++ b/pkg/controller/kieapp/constants/constants.go @@ -37,6 +37,10 @@ const ( DefaultKieDeployments = 1 // KeystoreSecret is the default format for keystore secret names KeystoreSecret = "%s-app-secret" + // KeystoreVolumeSuffix Suffix for the keystore volumes and volumeMounts name + KeystoreVolumeSuffix = "keystore-volume" + // DatabaseVolumeSuffix Suffix to use for any database volume and volumeMounts + DatabaseVolumeSuffix = "pvol" // DefaultDatabaseSize Default Database Persistence size DefaultDatabaseSize = "1Gi" ) @@ -45,7 +49,7 @@ var rhpamAppConstants = v1.AppConstants{Product: RhpamPrefix, Prefix: "rhpamcent var rhpamMonitorAppConstants = v1.AppConstants{Product: RhpamPrefix, Prefix: "rhpamcentrmon", ImageName: "businesscentral-monitoring", MavenRepo: "RHPAMCENTR", ConsoleProbePage: "kie-wb.jsp"} var rhdmAppConstants = v1.AppConstants{Product: RhdmPrefix, Prefix: "rhdmcentr", ImageName: "decisioncentral", MavenRepo: "RHDMCENTR", ConsoleProbePage: "kie-wb.jsp"} -var ReplicasTrial = v1.ReplicaConstants{ +var replicasTrial = v1.ReplicaConstants{ Console: v1.Replicas{Replicas: 1, DenyScale: true}, Server: v1.Replicas{Replicas: 1}, SmartRouter: v1.Replicas{Replicas: 1}, @@ -77,11 +81,17 @@ var databaseRhpamTrial = &v1.DatabaseObject{Type: v1.DatabaseH2, Size: ""} var EnvironmentConstants = map[v1.EnvironmentType]*v1.EnvironmentConstants{ v1.RhpamProduction: &v1.EnvironmentConstants{App: rhpamMonitorAppConstants, Replica: replicasRhpamProduction, Database: databaseRhpamProduction}, v1.RhpamProductionImmutable: &v1.EnvironmentConstants{App: rhpamMonitorAppConstants, Replica: replicasRhpamProductionImmutable, Database: databaseRhpamProductionImmutable}, - v1.RhpamTrial: &v1.EnvironmentConstants{App: rhpamAppConstants, Replica: ReplicasTrial, Database: databaseRhpamTrial}, - v1.RhpamAuthoring: &v1.EnvironmentConstants{App: rhpamAppConstants, Replica: ReplicasTrial, Database: databaseRhpamAuthoring}, + v1.RhpamTrial: &v1.EnvironmentConstants{App: rhpamAppConstants, Replica: replicasTrial, Database: databaseRhpamTrial}, + v1.RhpamAuthoring: &v1.EnvironmentConstants{App: rhpamAppConstants, Replica: replicasTrial, Database: databaseRhpamAuthoring}, v1.RhpamAuthoringHA: &v1.EnvironmentConstants{App: rhpamAppConstants, Replica: replicasAuthoringHA, Database: databaseRhpamAuthoringHA}, - v1.RhdmTrial: &v1.EnvironmentConstants{App: rhdmAppConstants, Replica: ReplicasTrial}, - v1.RhdmAuthoring: &v1.EnvironmentConstants{App: rhdmAppConstants, Replica: ReplicasTrial}, + v1.RhdmTrial: &v1.EnvironmentConstants{App: rhdmAppConstants, Replica: replicasTrial}, + v1.RhdmAuthoring: &v1.EnvironmentConstants{App: rhdmAppConstants, Replica: replicasTrial}, v1.RhdmAuthoringHA: &v1.EnvironmentConstants{App: rhdmAppConstants, Replica: replicasAuthoringHA}, - v1.RhdmProductionImmutable: &v1.EnvironmentConstants{App: rhdmAppConstants, Replica: ReplicasTrial}, + v1.RhdmProductionImmutable: &v1.EnvironmentConstants{App: rhdmAppConstants, Replica: replicasTrial}, +} + +// TemplateConstants set of constant values to use in templates +var TemplateConstants = v1.TemplateConstants{ + KeystoreVolumeSuffix: KeystoreVolumeSuffix, + DatabaseVolumeSuffix: DatabaseVolumeSuffix, } diff --git a/pkg/controller/kieapp/defaults/defaults.go b/pkg/controller/kieapp/defaults/defaults.go index dd1bc131a..dcc665a5d 100644 --- a/pkg/controller/kieapp/defaults/defaults.go +++ b/pkg/controller/kieapp/defaults/defaults.go @@ -130,6 +130,7 @@ func getEnvTemplate(cr *v1.KieApp) (v1.EnvTemplate, error) { Console: getConsoleTemplate(cr), Servers: serversConfig, SmartRouter: getSmartRouterTemplate(cr), + Constants: *getTemplateConstants(cr.Spec.Environment), } if err := configureAuth(cr, &envTemplate); err != nil { log.Error("unable to setup authentication: ", err) @@ -139,6 +140,15 @@ func getEnvTemplate(cr *v1.KieApp) (v1.EnvTemplate, error) { return envTemplate, nil } +func getTemplateConstants(env v1.EnvironmentType) *v1.TemplateConstants { + c := constants.TemplateConstants.DeepCopy() + if envConstants, found := constants.EnvironmentConstants[env]; found { + c.Product = envConstants.App.Product + c.MavenRepo = envConstants.App.MavenRepo + } + return c +} + func getConsoleTemplate(cr *v1.KieApp) v1.ConsoleTemplate { envConstants, hasEnv := constants.EnvironmentConstants[cr.Spec.Environment] template := v1.ConsoleTemplate{} @@ -239,6 +249,7 @@ func getServersConfig(cr *v1.KieApp, commonConfig *v1.CommonConfig) ([]v1.Server cr.Spec.Objects.Servers = []v1.KieServerSet{{}} } cr.Spec.Objects.Servers = serverSortBlanks(cr.Spec.Objects.Servers) + product := GetProduct(cr.Spec.Environment) usedNames := map[string]bool{} unsetNames := 0 for index := range cr.Spec.Objects.Servers { @@ -264,7 +275,7 @@ func getServersConfig(cr *v1.KieApp, commonConfig *v1.CommonConfig) ([]v1.Server usedNames[name] = true template := v1.ServerTemplate{ KieName: name, - Build: getBuildConfig(commonConfig, serverSet.Build), + Build: getBuildConfig(product, commonConfig, serverSet.Build), KeystoreSecret: serverSet.KeystoreSecret, } if serverSet.Build != nil { @@ -277,7 +288,7 @@ func getServersConfig(cr *v1.KieApp, commonConfig *v1.CommonConfig) ([]v1.Server Namespace: "", } } else { - template.From = getDefaultKieServerImage(commonConfig, serverSet.From) + template.From = getDefaultKieServerImage(product, commonConfig, serverSet.From) } // Set replicas @@ -382,7 +393,7 @@ func getKieSetIndex(arrayIdx, deploymentsIdx int) string { return name.String() } -func getBuildConfig(config *v1.CommonConfig, build *v1.KieAppBuildObject) v1.BuildTemplate { +func getBuildConfig(product string, config *v1.CommonConfig, build *v1.KieAppBuildObject) v1.BuildTemplate { if build == nil { return v1.BuildTemplate{} } @@ -394,15 +405,15 @@ func getBuildConfig(config *v1.CommonConfig, build *v1.KieAppBuildObject) v1.Bui MavenMirrorURL: build.MavenMirrorURL, ArtifactDir: build.ArtifactDir, } - buildTemplate.From = getDefaultKieServerImage(config, build.From) + buildTemplate.From = getDefaultKieServerImage(product, config, build.From) return buildTemplate } -func getDefaultKieServerImage(config *v1.CommonConfig, from *corev1.ObjectReference) corev1.ObjectReference { +func getDefaultKieServerImage(product string, config *v1.CommonConfig, from *corev1.ObjectReference) corev1.ObjectReference { if from != nil { return *from } - imageName := fmt.Sprintf("%s%s-kieserver-openshift:%s", config.Product, config.Version, constants.ImageStreamTag) + imageName := fmt.Sprintf("%s%s-kieserver-openshift:%s", product, config.Version, constants.ImageStreamTag) return corev1.ObjectReference{ Kind: "ImageStreamTag", Name: imageName, @@ -571,12 +582,6 @@ func UseEmbeddedFiles(service v1.PlatformService) (opName string, depNameSpace s // setAppConstants sets the application-related constants to use in the template processing func setAppConstants(spec *v1.KieAppSpec) { - env := spec.Environment - envConstants, hasEnv := constants.EnvironmentConstants[env] - if !hasEnv { - return - } - appConstants := envConstants.App if len(spec.CommonConfig.Version) == 0 { pattern := regexp.MustCompile("[0-9]+") spec.CommonConfig.Version = strings.Join(pattern.FindAllString(constants.ProductVersion, -1), "") @@ -584,12 +589,6 @@ func setAppConstants(spec *v1.KieAppSpec) { if len(spec.CommonConfig.ImageTag) == 0 { spec.CommonConfig.ImageTag = constants.ImageStreamTag } - if len(spec.CommonConfig.Product) == 0 { - spec.CommonConfig.Product = appConstants.Product - } - if len(spec.CommonConfig.MavenRepo) == 0 { - spec.CommonConfig.MavenRepo = appConstants.MavenRepo - } } // Pint returns a pointer to an integer @@ -601,3 +600,11 @@ func Pint(i int) *int { func Pint32(i int32) *int32 { return &i } + +func GetProduct(env v1.EnvironmentType) (product string) { + envConstants := constants.EnvironmentConstants[env] + if envConstants != nil { + product = envConstants.App.Product + } + return +} diff --git a/pkg/controller/kieapp/defaults/defaults_test.go b/pkg/controller/kieapp/defaults/defaults_test.go index a937e5730..6ded996fe 100644 --- a/pkg/controller/kieapp/defaults/defaults_test.go +++ b/pkg/controller/kieapp/defaults/defaults_test.go @@ -432,7 +432,7 @@ func TestConstructConsoleObject(t *testing.T) { env = ConsolidateObjects(env, cr) assert.Equal(t, fmt.Sprintf("%s-rhpamcentr", name), env.Console.DeploymentConfigs[0].Name) - assert.Equal(t, constants.ReplicasTrial.Console.Replicas, env.Console.DeploymentConfigs[0].Spec.Replicas) + assert.Equal(t, int32(1), env.Console.DeploymentConfigs[0].Spec.Replicas) re := regexp.MustCompile("[0-9]+") assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift:%s", strings.Join(re.FindAllString(constants.ProductVersion, -1), ""), constants.ImageStreamTag), env.Console.DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) for i := range sampleEnv { @@ -448,7 +448,7 @@ func TestConstructSmartRouterObject(t *testing.T) { env = ConsolidateObjects(env, cr) assert.Equal(t, fmt.Sprintf("%s-smartrouter", name), env.SmartRouter.DeploymentConfigs[0].Name) - assert.Equal(t, constants.ReplicasTrial.SmartRouter.Replicas, env.SmartRouter.DeploymentConfigs[0].Spec.Replicas) + assert.Equal(t, int32(1), env.SmartRouter.DeploymentConfigs[0].Spec.Replicas) re := regexp.MustCompile("[0-9]+") assert.Equal(t, fmt.Sprintf("rhpam%s-smartrouter-openshift:%s", strings.Join(re.FindAllString(constants.ProductVersion, -1), ""), constants.ImageStreamTag), env.SmartRouter.DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) for i := range sampleEnv { @@ -465,7 +465,7 @@ func TestConstructServerObject(t *testing.T) { env = ConsolidateObjects(env, cr) assert.Equal(t, fmt.Sprintf("%s-kieserver", name), env.Servers[0].DeploymentConfigs[0].Name) - assert.Equal(t, constants.ReplicasTrial.Server.Replicas, env.Servers[0].DeploymentConfigs[0].Spec.Replicas) + assert.Equal(t, int32(1), env.Servers[0].DeploymentConfigs[0].Spec.Replicas) re := regexp.MustCompile("[0-9]+") assert.Equal(t, fmt.Sprintf("rhpam%s-kieserver-openshift:%s", strings.Join(re.FindAllString(constants.ProductVersion, -1), ""), constants.ImageStreamTag), env.Servers[0].DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) for i := range sampleEnv { @@ -506,7 +506,7 @@ func TestSetReplicas(t *testing.T) { assert.Nil(t, err) env = ConsolidateObjects(env, cr) - assert.Equal(t, constants.ReplicasTrial.Console.Replicas, env.Console.DeploymentConfigs[0].Spec.Replicas, "Replicas scaling should be denied and use default instead") + assert.Equal(t, int32(1), env.Console.DeploymentConfigs[0].Spec.Replicas, "Replicas scaling should be denied and use default instead") assert.Equal(t, *replicas, env.SmartRouter.DeploymentConfigs[0].Spec.Replicas) for i, s := range env.Servers { if i == 0 { diff --git a/pkg/controller/kieapp/kieapp_controller.go b/pkg/controller/kieapp/kieapp_controller.go index f97feff36..74f500a6d 100644 --- a/pkg/controller/kieapp/kieapp_controller.go +++ b/pkg/controller/kieapp/kieapp_controller.go @@ -266,14 +266,15 @@ func (reconciler *Reconciler) createLocalImageTag(tagRefName string, cr *v1.KieA if len(result) == 1 { result = append(result, "latest") } + product := defaults.GetProduct(cr.Spec.Environment) tagName := fmt.Sprintf("%s:%s", result[0], result[1]) version := []byte(cr.Spec.CommonConfig.Version) imageName := tagName - regContext := fmt.Sprintf("%s-%s", cr.Spec.CommonConfig.Product, string(version[0])) + regContext := fmt.Sprintf("%s-%s", product, string(version[0])) registryAddress := cr.Spec.ImageRegistry.Registry if strings.Contains(result[0], "indexing-openshift") { - regContext = fmt.Sprintf("%s-7-tech-preview", cr.Spec.CommonConfig.Product) + regContext = fmt.Sprintf("%s-7-tech-preview", product) } else if strings.Contains(result[0], "amq-broker-7") { registryAddress = constants.ImageRegistry regContext = "amq-broker-7" @@ -335,7 +336,6 @@ func (reconciler *Reconciler) dcUpdateCheck(current, new oappsv1.DeploymentConfi log.Debug("Changes detected in 'Resource' config.", " OLD - ", cContainer.Resources, " NEW - ", nContainer.Resources) update = true } - if update { dcnew := new err := controllerutil.SetControllerReference(cr, &dcnew, reconciler.Service.GetScheme())