Skip to content

Commit

Permalink
Fix wrong resource name for broker url and make named template for re…
Browse files Browse the repository at this point in the history
…source names
  • Loading branch information
gionn committed Jan 9, 2024
1 parent cae1557 commit db22b0f
Show file tree
Hide file tree
Showing 11 changed files with 272 additions and 235 deletions.
2 changes: 1 addition & 1 deletion charts/alfresco-ai-transformer/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: alfresco-ai-transformer
description: A Helm chart for deploying Alfresco ai transformer service
type: application
version: 1.0.0-alpha.3
version: 1.0.0-alpha.4
appVersion: 3.0.1
dependencies:
- name: alfresco-common
Expand Down
2 changes: 1 addition & 1 deletion charts/alfresco-ai-transformer/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# alfresco-ai-transformer

![Version: 1.0.0-alpha.3](https://img.shields.io/badge/Version-1.0.0--alpha.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.0.1](https://img.shields.io/badge/AppVersion-3.0.1-informational?style=flat-square)
![Version: 1.0.0-alpha.4](https://img.shields.io/badge/Version-1.0.0--alpha.4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.0.1](https://img.shields.io/badge/AppVersion-3.0.1-informational?style=flat-square)

A Helm chart for deploying Alfresco ai transformer service

Expand Down
24 changes: 24 additions & 0 deletions charts/alfresco-ai-transformer/templates/_helpers-name.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- define "alfresco-ai-transformer.config-ai-aws.name" -}}
{{- $scope := (dict "Values" (dict "nameOverride" "aws-comprehend" ) "Chart" .Chart "Release" .Release) }}
{{- include "alfresco-ai-transformer.fullname" $scope }}
{{- end }}

{{- define "alfresco-ai-transformer.config-ai-mq.name" -}}
{{- $scope := (dict "Values" (dict "nameOverride" "ai-mq" ) "Chart" .Chart "Release" .Release) }}
{{- include "alfresco-ai-transformer.fullname" $scope }}
{{- end }}

{{- define "alfresco-ai-transformer.config-ai-sfs.name" -}}
{{- $scope := (dict "Values" (dict "nameOverride" "ai-sfs" ) "Chart" .Chart "Release" .Release) }}
{{- include "alfresco-ai-transformer.fullname" $scope }}
{{- end }}

{{- define "alfresco-ai-transformer.secret-ai-aws.name" -}}
{{- $scope := (dict "Values" (dict "nameOverride" "aws-comprehend" ) "Chart" .Chart "Release" .Release) }}
{{- include "alfresco-ai-transformer.fullname" $scope }}
{{- end }}

{{- define "alfresco-ai-transformer.secret-ai-mq.name" -}}
{{- $scope := (dict "Values" (dict "nameOverride" "ai-mq" ) "Chart" .Chart "Release" .Release) }}
{{- include "alfresco-ai-transformer.fullname" $scope }}
{{- end }}
3 changes: 1 addition & 2 deletions charts/alfresco-ai-transformer/templates/config-aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
{{- $cmCtx := dict "Values" (dict "nameOverride" "aws-comprehend") "Chart" .Chart "Release" .Release }}
name: {{ template "alfresco-ai-transformer.fullname" $cmCtx }}
name: {{ template "alfresco-ai-transformer.config-ai-aws.name" . }}
labels:
{{- include "alfresco-ai-transformer.labels" . | nindent 4 }}
data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
{{- $mqCtx := dict "Values" (dict "nameOverride" "ai-mq") "Chart" .Chart "Release" .Release }}
name: {{ template "alfresco-ai-transformer.fullname" $mqCtx }}
name: {{ template "alfresco-ai-transformer.config-ai-mq.name" . }}
labels:
{{- include "alfresco-ai-transformer.labels" $ | nindent 4 }}
{{- include "alfresco-ai-transformer.labels" . | nindent 4 }}
data:
{{- $reqmsg := "Please provide a valid broker URL with messageBroker.url or as a configmap key using messageBroker.existingConfigMap" }}
{{ template "alfresco-common.activemq.cm" (required $reqmsg .Values.messageBroker.url) }}
Expand Down
3 changes: 1 addition & 2 deletions charts/alfresco-ai-transformer/templates/config-sfs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
{{- $cmCtx := dict "Values" (dict "nameOverride" "ai-sfs") "Chart" .Chart "Release" .Release }}
name: {{ template "alfresco-ai-transformer.fullname" $cmCtx }}
name: {{ template "alfresco-ai-transformer.config-ai-sfs.name" . }}
labels:
{{- include "alfresco-ai-transformer.labels" . | nindent 4 }}
data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,7 @@ spec:
- configMapRef:
name: {{ template "alfresco-ai-transformer.fullname" . }}
env:
{{- $mqSecretCtx := dict "Values" (dict "nameOverride" "ai-mq") "Chart" $.Chart "Release" $.Release }}
{{- $mqSecret := coalesce .Values.messageBroker.existingSecret.name (include "alfresco-ai-transformer.fullname" $mqSecretCtx) }}
{{- $awsSecretCtx := dict "Values" (dict "nameOverride" "aws-comprehend") "Chart" $.Chart "Release" $.Release }}
{{- $awsSecret := coalesce .Values.aws.existingSecret.name (include "alfresco-ai-transformer.fullname" $awsSecretCtx) }}
{{- $awsCmCtx := dict "Values" (dict "nameOverride" "aws-comprehend") "Chart" $.Chart "Release" $.Release }}
{{- $awsCm := coalesce .Values.aws.existingConfigMap.name (include "alfresco-ai-transformer.fullname" $awsCmCtx) }}
{{- $mqCmCtx := dict "Values" (dict "nameOverride" "ai-mq") "Chart" $.Chart "Release" $.Release }}
{{- $mqCm := coalesce .Values.messageBroker.existingSecret.name (include "alfresco-ai-transformer.fullname" $mqCmCtx) }}
{{- $sfsCmCtx := dict "Values" (dict "nameOverride" "ai-sfs") "Chart" .Chart "Release" .Release }}
{{- $sfsCm := coalesce .Values.sfs.existingConfigMap.name (include "alfresco-ai-transformer.fullname" $sfsCmCtx) }}
{{- $mqSecret := coalesce .Values.messageBroker.existingSecret.name (include "alfresco-ai-transformer.secret-ai-mq.name" .) }}
- name: BROKER_USERNAME
valueFrom:
secretKeyRef:
Expand All @@ -53,13 +44,14 @@ spec:
- name: BROKER_URL
valueFrom:
configMapKeyRef:
name: {{ $mqCm }}
name: {{ coalesce .Values.messageBroker.existingConfigMap.name (include "alfresco-ai-transformer.config-ai-mq.name" .) }}
key: {{ .Values.messageBroker.existingConfigMap.keys.url }}
- name: FILE_STORE_URL
valueFrom:
configMapKeyRef:
name: {{ $sfsCm }}
name: {{ coalesce .Values.sfs.existingConfigMap.name (include "alfresco-ai-transformer.config-ai-sfs.name" .) }}
key: {{ .Values.sfs.existingConfigMap.keys.url }}
{{- $awsSecret := coalesce .Values.aws.existingSecret.name (include "alfresco-ai-transformer.secret-ai-aws.name" .) }}
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
Expand All @@ -70,6 +62,7 @@ spec:
secretKeyRef:
name: {{ $awsSecret }}
key: {{ .Values.aws.existingSecret.keys.secretAccessKey }}
{{- $awsCm := coalesce .Values.aws.existingConfigMap.name (include "alfresco-ai-transformer.config-ai-aws.name" .) }}
- name: AWS_REGION
valueFrom:
configMapKeyRef:
Expand Down
3 changes: 1 addition & 2 deletions charts/alfresco-ai-transformer/templates/secret-aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
apiVersion: v1
kind: Secret
metadata:
{{- $secretCtx := dict "Values" (dict "nameOverride" "aws-comprehend") "Chart" .Chart "Release" .Release }}
name: {{ template "alfresco-ai-transformer.fullname" $secretCtx }}
name: {{ template "alfresco-ai-transformer.secret-ai-aws.name" . }}
labels:
{{- include "alfresco-ai-transformer.labels" . | nindent 4 }}
type: Opaque
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
apiVersion: v1
kind: Secret
metadata:
{{- $mqCtx := dict "Values" (dict "nameOverride" "ai-mq") "Chart" .Chart "Release" .Release }}
name: {{ template "alfresco-ai-transformer.fullname" $mqCtx }}
name: {{ template "alfresco-ai-transformer.secret-ai-mq.name" . }}
labels:
{{- include "alfresco-ai-transformer.labels" $ | nindent 4 }}
type: Opaque
Expand Down
117 changes: 60 additions & 57 deletions charts/alfresco-ai-transformer/tests/confimap_test.yaml
Original file line number Diff line number Diff line change
@@ -1,60 +1,63 @@
suite: test ai-transformer configmap
templates:
- config-message-broker.yaml
- config-ai-transformer.yaml
- config-aws.yaml
- config-sfs.yaml
- config-message-broker.yaml
- config-ai-transformer.yaml
- config-aws.yaml
- config-sfs.yaml
tests:
- it: should fail due to missing values
template: config-message-broker.yaml
set:
sfs:
url: htts://some-file-store.infra.local:8080
asserts:
- failedTemplate:
errorMessage: >-
Please provide a valid broker URL with messageBroker.url or as a configmap key using messageBroker.existingConfigMap
- it: should fail due to missing values
set:
messageBroker:
url: nio://activemq:61616
asserts:
- failedTemplate:
errorMessage: You must provide a base URL for the filestore service as sfs.url
template: config-sfs.yaml
- it: should render default configmaps based on values
values: &testvalues
- values/test_values.yaml
template: config-aws.yaml
asserts:
- equal:
path: data.JAVA_OPTS
value: -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80
template: config-ai-transformer.yaml
- equal:
path: data.FILE_STORE_URL
value: http://acs-alfresco-transform-service/alfresco/api/-default-/private/sfs/versions/1/file/
template: config-sfs.yaml
- equal:
path: data.BROKER_URL
value: failover:(nio://activemq:61616)
template: config-message-broker.yaml
- equal:
path: data.AWS_REGION
value: null
- equal:
path: data.AWS_S3_BUCKET
value: null
- equal:
path: data.AWS_COMPREHEND_ROLE_ARN
value: null
- it: should not render components configmaps
values: *testvalues
set:
aws:
existingConfigMap:
name: myaws
template: config-aws.yaml
asserts:
- hasDocuments:
count: 0
- it: should fail due to missing values
template: config-message-broker.yaml
set:
sfs:
url: htts://some-file-store.infra.local:8080
asserts:
- failedTemplate:
errorMessage: >-
Please provide a valid broker URL with messageBroker.url or as a configmap key using messageBroker.existingConfigMap
- it: should fail due to missing values
set:
messageBroker:
url: nio://activemq:61616
asserts:
- failedTemplate:
errorMessage: You must provide a base URL for the filestore service as sfs.url
template: config-sfs.yaml

- it: should render default configmaps based on values
values: &testvalues
- values/test_values.yaml
template: config-aws.yaml
asserts:
- equal:
path: data.JAVA_OPTS
value: -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80
template: config-ai-transformer.yaml
- equal:
path: data.FILE_STORE_URL
value: http://acs-alfresco-transform-service/alfresco/api/-default-/private/sfs/versions/1/file/
template: config-sfs.yaml
- equal:
path: data.BROKER_URL
value: failover:(nio://activemq:61616)
template: config-message-broker.yaml
- equal:
path: data.AWS_REGION
value: null
- equal:
path: data.AWS_S3_BUCKET
value: null
- equal:
path: data.AWS_COMPREHEND_ROLE_ARN
value: null

- it: should not render components configmaps
values: *testvalues
set:
aws:
existingConfigMap:
name: myaws
template: config-aws.yaml
asserts:
- hasDocuments:
count: 0
Loading

0 comments on commit db22b0f

Please sign in to comment.