diff --git a/class/defaults.yml b/class/defaults.yml index e12fd8c..b3be471 100644 --- a/class/defaults.yml +++ b/class/defaults.yml @@ -5,7 +5,7 @@ parameters: operator: registry: quay.io repository: projectsyn/lieutenant-operator - version: '1.10.1' + version: '1.11.1' api: registry: docker.io repository: projectsyn/lieutenant-api @@ -18,6 +18,7 @@ parameters: operator: manifest_version: v${lieutenant:images:operator:version} manifest_url: https://raw.githubusercontent.com/projectsyn/lieutenant-operator/${lieutenant:operator:manifest_version}/config + lieutenant_api_url: https://${lieutenant:api:ingress:host} common_labels: 'app.kubernetes.io/name': 'lieutenant-operator' 'app.kubernetes.io/part-of': 'project-syn' diff --git a/component/operator.jsonnet b/component/operator.jsonnet index 86aa8a3..c96c05b 100644 --- a/component/operator.jsonnet +++ b/component/operator.jsonnet @@ -23,6 +23,7 @@ local default_env = DEFAULT_GLOBAL_GIT_REPO_URL: params.operator.default_global_git_repo, LIEUTENANT_DELETE_PROTECTION: params.operator.deletion_protection, SKIP_VAULT_SETUP: !params.operator.vault.enabled, + LIEUTENANT_API_URL: params.operator.lieutenant_api_url, } + if params.operator.vault.enabled then { @@ -68,6 +69,10 @@ local objects = [ if c.name == 'lieutenant-operator' then c { image: image, + args: [ + '-lieutenant-api-url', + '$(LIEUTENANT_API_URL)', + ], env: common.MergeEnvVars( super.env, com.envList(default_env + params.operator.env) diff --git a/docs/modules/ROOT/pages/references/parameters.adoc b/docs/modules/ROOT/pages/references/parameters.adoc index d69e4ae..cc267ca 100644 --- a/docs/modules/ROOT/pages/references/parameters.adoc +++ b/docs/modules/ROOT/pages/references/parameters.adoc @@ -77,6 +77,15 @@ If a dict is given as the value, the component will render it as `valueFrom:`. TIP: Environment variables configured in this parameter have precedence over environment variables generated from other component parameters. +== `operator.lieutenant_api_url` + +[horizontal] +type:: string +default:: `https://${lieutenant:api:ingress:host}` + +Make the Lieutenant Operator aware of where the API is publicly reachable. +By default, the API ingress hostname is used, with a `https://` prefix. + == `operator.vault.enabled` [horizontal] diff --git a/tests/golden/defaults/lieutenant/lieutenant/00_crds/syn.tools_clusters.yaml b/tests/golden/defaults/lieutenant/lieutenant/00_crds/syn.tools_clusters.yaml index 7535b9d..c331c50 100644 --- a/tests/golden/defaults/lieutenant/lieutenant/00_crds/syn.tools_clusters.yaml +++ b/tests/golden/defaults/lieutenant/lieutenant/00_crds/syn.tools_clusters.yaml @@ -74,6 +74,10 @@ spec: description: DisplayName of cluster which could be different from metadata.name. Allows cluster renaming should it be needed. type: string + enableCompilePipeline: + description: EnableCompilePipeline determines whether the gitops compile + pipeline should be set up for this cluster + type: boolean facts: additionalProperties: type: string diff --git a/tests/golden/defaults/lieutenant/lieutenant/00_crds/syn.tools_tenants.yaml b/tests/golden/defaults/lieutenant/lieutenant/00_crds/syn.tools_tenants.yaml index b0987b3..e3199eb 100644 --- a/tests/golden/defaults/lieutenant/lieutenant/00_crds/syn.tools_tenants.yaml +++ b/tests/golden/defaults/lieutenant/lieutenant/00_crds/syn.tools_tenants.yaml @@ -77,6 +77,10 @@ spec: description: DisplayName of cluster which could be different from metadata.name. Allows cluster renaming should it be needed. type: string + enableCompilePipeline: + description: EnableCompilePipeline determines whether the gitops + compile pipeline should be set up for this cluster + type: boolean facts: additionalProperties: type: string @@ -291,6 +295,22 @@ spec: description: TokenLifetime set the token lifetime type: string type: object + compilePipeline: + description: CompilePipeline contains the configuration for the automatically + configured compile pipelines on this tenant + properties: + enabled: + description: Enabled enables or disables the compile pipeline + for this tenant + type: boolean + pipelineFiles: + additionalProperties: + type: string + description: Pipelines contains a map of filenames and file contents, + specifying files which are added to the GitRepoTemplate in order + to set up the automatically configured compile pipeline + type: object + type: object creationPolicy: description: |- CreationPolicy defines how the external resources should be treated upon CR creation. @@ -501,6 +521,18 @@ spec: type: object status: description: TenantStatus defines the observed state of Tenant + properties: + compilePipeline: + description: CompilePipeline contains the status of the automatically + configured compile pipelines on this tenant + properties: + clusters: + description: Clusters contains the list of all clusters for which + the automatically configured compile pipeline is enabled + items: + type: string + type: array + type: object type: object type: object served: true diff --git a/tests/golden/defaults/lieutenant/lieutenant/00_crds/syn.tools_tenanttemplates.yaml b/tests/golden/defaults/lieutenant/lieutenant/00_crds/syn.tools_tenanttemplates.yaml index 56273db..116d329 100644 --- a/tests/golden/defaults/lieutenant/lieutenant/00_crds/syn.tools_tenanttemplates.yaml +++ b/tests/golden/defaults/lieutenant/lieutenant/00_crds/syn.tools_tenanttemplates.yaml @@ -77,6 +77,10 @@ spec: description: DisplayName of cluster which could be different from metadata.name. Allows cluster renaming should it be needed. type: string + enableCompilePipeline: + description: EnableCompilePipeline determines whether the gitops + compile pipeline should be set up for this cluster + type: boolean facts: additionalProperties: type: string @@ -291,6 +295,22 @@ spec: description: TokenLifetime set the token lifetime type: string type: object + compilePipeline: + description: CompilePipeline contains the configuration for the automatically + configured compile pipelines on this tenant + properties: + enabled: + description: Enabled enables or disables the compile pipeline + for this tenant + type: boolean + pipelineFiles: + additionalProperties: + type: string + description: Pipelines contains a map of filenames and file contents, + specifying files which are added to the GitRepoTemplate in order + to set up the automatically configured compile pipeline + type: object + type: object creationPolicy: description: |- CreationPolicy defines how the external resources should be treated upon CR creation. diff --git a/tests/golden/defaults/lieutenant/lieutenant/10_operator/deployment.yaml b/tests/golden/defaults/lieutenant/lieutenant/10_operator/deployment.yaml index 3091552..702b963 100644 --- a/tests/golden/defaults/lieutenant/lieutenant/10_operator/deployment.yaml +++ b/tests/golden/defaults/lieutenant/lieutenant/10_operator/deployment.yaml @@ -22,11 +22,16 @@ spec: control-plane: controller-manager spec: containers: - - env: + - args: + - -lieutenant-api-url + - $(LIEUTENANT_API_URL) + env: - name: DEFAULT_DELETION_POLICY value: Archive - name: DEFAULT_GLOBAL_GIT_REPO_URL value: https://github.com/projectsyn/getting-started-commodore-defaults + - name: LIEUTENANT_API_URL + value: https://lieutenant.todo - name: LIEUTENANT_DELETE_PROTECTION value: 'false' - name: OPERATOR_NAME @@ -47,7 +52,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: quay.io/projectsyn/lieutenant-operator:1.10.1 + image: quay.io/projectsyn/lieutenant-operator:1.11.1 livenessProbe: httpGet: path: /healthz diff --git a/tests/unit/operator_test.go b/tests/unit/operator_test.go index 0d48903..648382a 100644 --- a/tests/unit/operator_test.go +++ b/tests/unit/operator_test.go @@ -26,7 +26,7 @@ func Test_OperatorDeployment(t *testing.T) { require.NotEmpty(t, deploy.Spec.Template.Spec.Containers) assert.Len(t, deploy.Spec.Template.Spec.Containers, 1) c := deploy.Spec.Template.Spec.Containers[0] - assert.Len(t, c.Env, 10) + assert.Len(t, c.Env, 11) } func Test_OperatorRBAC(t *testing.T) {