From fe668c68bb6a69dfcdc2b15cc6e978fd779111a2 Mon Sep 17 00:00:00 2001 From: Saurabh Lohe <105858985+slohe1@users.noreply.github.com> Date: Fri, 14 Jul 2023 16:30:58 +0530 Subject: [PATCH] OPSEXP-2116 repository service named template alfresco-connector-ms365 (#71) --- charts/alfresco-connector-ms365/Chart.yaml | 2 +- charts/alfresco-connector-ms365/README.md | 3 ++- .../templates/config-connector-ms365.yaml | 11 ++++----- .../templates/deployment-connector-ms365.yaml | 12 +++++++++- .../tests/configmap-connector-ms365_test.yaml | 24 ++++++++++++------- .../deployment-connector-ms365_test.yaml | 12 ++++++++++ charts/alfresco-connector-ms365/values.yaml | 2 ++ 7 files changed, 48 insertions(+), 18 deletions(-) diff --git a/charts/alfresco-connector-ms365/Chart.yaml b/charts/alfresco-connector-ms365/Chart.yaml index 22b7b41e..d2491579 100644 --- a/charts/alfresco-connector-ms365/Chart.yaml +++ b/charts/alfresco-connector-ms365/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: alfresco-connector-ms365 description: A Helm chart for deploying Alfresco connector ms365 service type: application -version: 0.1.0 +version: 0.2.0 appVersion: "2.0.0" dependencies: - name: alfresco-common diff --git a/charts/alfresco-connector-ms365/README.md b/charts/alfresco-connector-ms365/README.md index 32db72c5..f8f2070c 100644 --- a/charts/alfresco-connector-ms365/README.md +++ b/charts/alfresco-connector-ms365/README.md @@ -1,6 +1,6 @@ # alfresco-connector-ms365 -![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.0.0](https://img.shields.io/badge/AppVersion-2.0.0-informational?style=flat-square) +![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.0.0](https://img.shields.io/badge/AppVersion-2.0.0-informational?style=flat-square) A Helm chart for deploying Alfresco connector ms365 service @@ -33,6 +33,7 @@ A Helm chart for deploying Alfresco connector ms365 service | readinessProbe.periodSeconds | int | `60` | | | readinessProbe.timeoutSeconds | int | `10` | | | replicaCount | int | `2` | | +| repository.existingConfigMap | string | `nil` | a pre-existing configmap which provides expected configuration for ms365 | | repository.host | string | `"acs-alfresco-cs-repository"` | ACS repository host | | repository.port | int | `80` | ACS repository port | | resources.limits.cpu | string | `"2"` | | diff --git a/charts/alfresco-connector-ms365/templates/config-connector-ms365.yaml b/charts/alfresco-connector-ms365/templates/config-connector-ms365.yaml index 02d0b8dd..44cf8ada 100644 --- a/charts/alfresco-connector-ms365/templates/config-connector-ms365.yaml +++ b/charts/alfresco-connector-ms365/templates/config-connector-ms365.yaml @@ -1,4 +1,6 @@ # Defines the properties required by the alfresco-connector-ms365 container +{{- if not .Values.repository.existingConfigMap -}} +--- apiVersion: v1 kind: ConfigMap metadata: @@ -6,9 +8,6 @@ metadata: labels: {{- include "alfresco-connector-ms365.labels" . | nindent 4 }} data: - {{- $alfbaseurl := printf "-Dalfresco.base-url=http://%s:%d" .Values.repository.host (int .Values.repository.port ) -}} - {{- $environment := .Values.environment | default dict }} - JAVA_OPTS: {{ tpl (printf "%s %s" ($environment.JAVA_OPTS | default "") $alfbaseurl) $ | trim | quote }} - {{- range $key, $val := omit $environment "JAVA_OPTS" }} - {{ $key }}: {{ $val | quote }} - {{- end }} + {{- $alfbaseurl := printf "http://%s:%d" .Values.repository.host (int .Values.repository.port ) }} + REPO_URL: {{ $alfbaseurl }} +{{- end }} diff --git a/charts/alfresco-connector-ms365/templates/deployment-connector-ms365.yaml b/charts/alfresco-connector-ms365/templates/deployment-connector-ms365.yaml index a5acd5f1..68cdb899 100644 --- a/charts/alfresco-connector-ms365/templates/deployment-connector-ms365.yaml +++ b/charts/alfresco-connector-ms365/templates/deployment-connector-ms365.yaml @@ -17,7 +17,9 @@ spec: template: metadata: annotations: + {{- if not .Values.repository.existingConfigMap }} checksum/config: {{ include (print $.Template.BasePath "/config-connector-ms365.yaml") . | sha256sum }} + {{- end }} labels: {{- include "alfresco-connector-ms365.selectorLabels" . | nindent 8 }} spec: @@ -62,7 +64,15 @@ spec: {{- include "component-security-context" .Values | indent 8 }} envFrom: - configMapRef: - name: {{ template "alfresco-connector-ms365.fullname" . }} + name: {{ .Values.repository.existingConfigMap | default (print (include "alfresco-connector-ms365.fullname" .)) }} + env: + {{- range $key, $value := (omit .Values.environment "JAVA_OPTS") }} + - name: {{ $key }} + value: {{ $value }} + {{- end }} + - name: JAVA_OPTS + value: >- + {{ (printf "%s %s" (.Values.environment.JAVA_OPTS | default "") "-Dalfresco.base-url=$REPO_URL") }} ports: - containerPort: {{ .Values.image.internalPort }} resources: {{- toYaml .Values.resources | nindent 12 }} diff --git a/charts/alfresco-connector-ms365/tests/configmap-connector-ms365_test.yaml b/charts/alfresco-connector-ms365/tests/configmap-connector-ms365_test.yaml index 02861138..80293acc 100644 --- a/charts/alfresco-connector-ms365/tests/configmap-connector-ms365_test.yaml +++ b/charts/alfresco-connector-ms365/tests/configmap-connector-ms365_test.yaml @@ -3,12 +3,18 @@ suite: test connector-ms365 deployment templates: - config-connector-ms365.yaml tests: - - it: should render just the URL in JAVA_OPTS - values: &testvalues - set: - repository.host: acs-alfresco-cs-repository - repository.port: 80 - asserts: - - equal: - path: data.JAVA_OPTS - value: -Dalfresco.base-url=http://acs-alfresco-cs-repository:80 + - it: should not render a configmap + set: + repository: + existingConfigMap: myns/mycm + asserts: + - hasDocuments: + count: 0 + template: config-connector-ms365.yaml + + - it: should render a default config + asserts: + - equal: + path: data.REPO_URL + value: http://acs-alfresco-cs-repository:80 + template: config-connector-ms365.yaml diff --git a/charts/alfresco-connector-ms365/tests/deployment-connector-ms365_test.yaml b/charts/alfresco-connector-ms365/tests/deployment-connector-ms365_test.yaml index d9fa8ff1..d0d9d27d 100644 --- a/charts/alfresco-connector-ms365/tests/deployment-connector-ms365_test.yaml +++ b/charts/alfresco-connector-ms365/tests/deployment-connector-ms365_test.yaml @@ -26,3 +26,15 @@ tests: cpu: "2" memory: "1000Mi" template: deployment-connector-ms365.yaml + + - it: should leverage provided exisintg configmap + set: + repository: + existingConfigMap: service/test + asserts: + - contains: + path: spec.template.spec.containers[0].envFrom + content: + configMapRef: + name: service/test + template: deployment-connector-ms365.yaml diff --git a/charts/alfresco-connector-ms365/values.yaml b/charts/alfresco-connector-ms365/values.yaml index 66bdc0ac..73ac36e1 100644 --- a/charts/alfresco-connector-ms365/values.yaml +++ b/charts/alfresco-connector-ms365/values.yaml @@ -43,3 +43,5 @@ repository: host: acs-alfresco-cs-repository # -- ACS repository port port: 80 + # -- a pre-existing configmap which provides expected configuration for ms365 + existingConfigMap: null