diff --git a/helm/minio/templates/_helper_create_policy.txt b/helm/minio/templates/_helper_create_policy.txt index e5f2edb6a..d565b161e 100644 --- a/helm/minio/templates/_helper_create_policy.txt +++ b/helm/minio/templates/_helper_create_policy.txt @@ -43,17 +43,19 @@ checkPolicyExists() { return $? } -# createPolicy($name) +# createPolicy($name, $filename) createPolicy () { NAME=$1 + FILENAME=$2 # Create the name if it does not exist + echo "Checking policy: $NAME (in /config/$FILENAME.json)" if ! checkPolicyExists $NAME ; then echo "Creating policy '$NAME'" else echo "Policy '$NAME' already exists." fi - ${MC} admin policy add myminio $NAME /config/$NAME.json + ${MC} admin policy add myminio $NAME /config/$FILENAME.json } @@ -67,7 +69,7 @@ connectToMinio $scheme {{ if .Values.policies }} # Create the policies -{{- range .Values.policies }} -createPolicy {{ .name }} +{{- range $idx, $policy := .Values.policies }} +createPolicy {{ $policy.name }} policy_{{ $idx }} {{- end }} {{- end }} \ No newline at end of file diff --git a/helm/minio/templates/configmap.yaml b/helm/minio/templates/configmap.yaml index 29fc70540..95a7c6038 100644 --- a/helm/minio/templates/configmap.yaml +++ b/helm/minio/templates/configmap.yaml @@ -15,8 +15,9 @@ data: {{ include (print $.Template.BasePath "/_helper_create_user.txt") . | indent 4 }} add-policy: |- {{ include (print $.Template.BasePath "/_helper_create_policy.txt") . | indent 4 }} -{{- range .Values.policies }} - {{ .name }}.json: |- +{{- range $idx, $policy := .Values.policies }} + # {{ $policy.name }} + policy_{{ $idx }}.json: |- {{ include (print $.Template.BasePath "/_helper_policy.tpl") . | indent 4 }} {{ end }} custom-command: |-