Skip to content

Commit

Permalink
OPSEXP-1862: align all non-secret config to using alfresco-common rea…
Browse files Browse the repository at this point in the history
…d.cm helpers (#96)
  • Loading branch information
alxgomz authored Aug 10, 2023
1 parent a1a7579 commit 2021907
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 52 deletions.
2 changes: 1 addition & 1 deletion charts/alfresco-repository/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: alfresco-repository
description: Alfresco content repository Helm chart
type: application
version: 0.1.0-alpha.6
version: 0.1.0-alpha.7
appVersion: 23.1.0-A21
dependencies:
- name: alfresco-common
Expand Down
2 changes: 1 addition & 1 deletion charts/alfresco-repository/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# alfresco-repository

![Version: 0.1.0-alpha.6](https://img.shields.io/badge/Version-0.1.0--alpha.6-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 23.1.0-A21](https://img.shields.io/badge/AppVersion-23.1.0--A21-informational?style=flat-square)
![Version: 0.1.0-alpha.7](https://img.shields.io/badge/Version-0.1.0--alpha.7-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 23.1.0-A21](https://img.shields.io/badge/AppVersion-23.1.0--A21-informational?style=flat-square)

Alfresco content repository Helm chart

Expand Down
13 changes: 13 additions & 0 deletions charts/alfresco-repository/templates/_helpers-message-broker.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{/*
Validate ActiveMQ is a failover transport URL
Usage: include "alfresco-repository.mq.url.valid" "URL"
*/}}
{{- define "alfresco-repository.mq.url.valid" -}}
{{- if hasPrefix "failover:(" . }}
{{- . }}
{{- else -}}
{{- printf "failover:(%s)" . }}
{{- end }}
{{- end -}}
17 changes: 0 additions & 17 deletions charts/alfresco-repository/templates/configmap-message-broker.yaml

This file was deleted.

6 changes: 4 additions & 2 deletions charts/alfresco-repository/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ data:
CATALINA_OPTS: >-
{{- with .Values.configuration }}
-Ddeployment.method=HELM_CHART
-Ddb.url=jdbc:{{ .db.url }}
{{- $db_url := include "alfresco-common.read.cm.then.value" (dict "ns" $.Release.Namespace "key" "url" "context" .db) }}
-Ddb.url=jdbc:{{ $db_url }}
-Ddb.username=${DATABASE_USERNAME}
-Ddb.password=${DATABASE_PASSWORD}
-Ddb.driver={{ include "alfresco-common.db.driver" .db }}
Expand All @@ -22,7 +23,8 @@ data:
-Dmetadata-keystore.metadata.algorithm=DESede
-Dmetadata-keystore.password=mp6yc0UD9e
-Dmetadata-keystore.metadata.password=oKIWzVdEdA
-Dmessaging.broker.url="$BROKER_URL"
{{- $mq_url := include "alfresco-common.reqRead.cm.then.value" (dict "ns" $.Release.Namespace "key" "url" "context" .messageBroker) }}
-Dmessaging.broker.url={{ include "alfresco-repository.mq.url.valid" $mq_url | quote }}
-Dmessaging.broker.username="$BROKER_USERNAME"
-Dmessaging.broker.password="$BROKER_PASSWORD"
{{- $search_flavor := include "alfresco-common.read.cm.then.value" (dict "ns" $.Release.Namespace "key" "flavor" "context" .search) }}
Expand Down
9 changes: 0 additions & 9 deletions charts/alfresco-repository/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,13 @@ spec:
{{- $dbsecret := "" }}
{{- $mqsecretCtx := dict }}
{{- $mqsecret := "" }}
{{- $mqconfigCtx := dict }}
{{- $mqconfig := "" }}
{{- $searchsecretCtx := dict }}
{{- $searchsecret := "" }}
{{- with .Values.configuration }}
{{- $dbsecretCtx = dict "Values" (dict "nameOverride" "secret-database") "Chart" $.Chart "Release" $.Release }}
{{- $dbsecret = coalesce .db.existingSecret.name (include "alfresco-repository.fullname" $dbsecretCtx) }}
{{- $mqsecretCtx = dict "Values" (dict "nameOverride" "secret-mq") "Chart" $.Chart "Release" $.Release }}
{{- $mqsecret = coalesce .messageBroker.existingSecret.name (include "alfresco-repository.fullname" $mqsecretCtx) }}
{{- $mqconfigCtx = dict "Values" (dict "nameOverride" "configmap-mq") "Chart" $.Chart "Release" $.Release }}
{{- $mqconfig = coalesce .messageBroker.existingConfigMap.name (include "alfresco-repository.fullname" $mqconfigCtx) }}
{{- $searchsecretCtx = dict "Values" (dict "nameOverride" "secret-search") "Chart" $.Chart "Release" $.Release }}
{{- $searchsecret = coalesce .search.existingSecret.name (include "alfresco-repository.fullname" $searchsecretCtx) }}
{{- end }}
Expand Down Expand Up @@ -127,11 +123,6 @@ spec:
name: {{ $mqsecret }}
key: {{ .Values.configuration.messageBroker.existingSecret.keys.password }}
optional: true
- name: BROKER_URL
valueFrom:
configMapKeyRef:
name: {{ $mqconfig }}
key: {{ .Values.configuration.messageBroker.existingConfigMap.keys.url }}
{{- $optsCtx := dict "Values" (dict "nameOverride" "alfresco-opts") "Chart" .Chart "Release" .Release }}
envFrom:
- configMapRef:
Expand Down
49 changes: 27 additions & 22 deletions charts/alfresco-repository/tests/message-broker_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,17 @@ suite: test Message Queue Broker
templates:
- secret-message-broker.yaml
- deployment.yaml
- configmap-message-broker.yaml
- configmap.yaml
values:
- values/test_values.yaml
tests:
- it: should render ActiveMQ minimal config
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BROKER_URL
valueFrom:
configMapKeyRef:
name: RELEASE-NAME-configmap-mq
key: BROKER_URL
template: deployment.yaml
- equal:
path: data.BROKER_URL
value: failover:(tcp://localhost:61616)
template: configmap-message-broker.yaml
- matchRegex:
path: data.CATALINA_OPTS
pattern: |-
(^\s*|[^\s]\s+)-Dmessaging.broker.url="failover:\(tcp://localhost:61616\)"($|\s)
template: configmap.yaml
- equal:
path: spec.template.metadata.annotations['checksum.config.alfresco.org/messageBroker']
value: &cfgsum c2939932894f879e156e0ccaebb43552058663dbbedd75c74afd20a86662e054
Expand All @@ -36,20 +28,33 @@ tests:
keys:
username: mquser
password: mqpass
existingConfigMap:
name: mqConfigmap
keys:
url: myurl
url: ssl://amqs:61617
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BROKER_URL
name: BROKER_USERNAME
valueFrom:
secretKeyRef:
name: mqSecret
key: mquser
optional: true
template: deployment.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: BROKER_PASSWORD
valueFrom:
configMapKeyRef:
name: mqConfigmap
key: myurl
secretKeyRef:
name: mqSecret
key: mqpass
optional: true
template: deployment.yaml
- matchRegex:
path: data.CATALINA_OPTS
pattern: |-
(^\s*|[^\s]\s+)-Dmessaging.broker.url="failover:\(ssl://amqs:61617\)"($|\s)
template: configmap.yaml
- hasDocuments:
count: 0
template: secret-message-broker.yaml
Expand Down

0 comments on commit 2021907

Please sign in to comment.