provisioning-configmap.yaml 2.39 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
{{- /*
Copyright VMware, Inc.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if .Values.provisioning.enabled }}
{{- $fullname := printf "%s-provisioning" (include "common.names.fullname" .) }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ $fullname }}
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
    app.kubernetes.io/component: minio-provisioning
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
data:
  {{- range $bucket := .Values.provisioning.buckets }}
  {{- if $bucket.lifecycle }}
  bucket-{{ $bucket.name }}.json: |
    {
      "Rules": [
        {{- range $idx, $lifecycle := $bucket.lifecycle }}
        {{- if not (eq $idx 0) }}
        ,
        {{- end }}
        {
          "ID": "{{ $lifecycle.id }}",
          "Status": "{{ ternary "Disabled" "Enabled" (and (not (empty $lifecycle.disabled)) $lifecycle.disabled) }}",
          {{- if $lifecycle.expiry }}
          "Expiration": {
            {{- with $lifecycle.expiry.date }}
            "Date": "{{ . }}"
            {{- end }}
            {{- with $lifecycle.expiry.days }}
            "Days": {{ . }}
            {{- end }}
          }
          {{- with $lifecycle.expiry.nonconcurrentDays }}
          ,
          "NoncurrentVersionExpiration": {
            "NoncurrentDays": {{ . }}
          }
          {{- end }}
          {{- with $lifecycle.prefix }}
          ,
          "Filter": {
            "Prefix": "{{ . }}"
          }
          {{- end }}
        }
        {{- end }}
        {{- end }}
      ]
    }
  {{- end }}
  {{- end }}
  {{- range $policy := .Values.provisioning.policies }}
  policy-{{ $policy.name }}.json: |
      {{- $statementsLength := sub (len $policy.statements) 1 }}
      {
        "Version": "2012-10-17",
        "Statement": [
          {{- range $i, $statement := $policy.statements }}
          {
            "Effect": "{{ default "Deny" $statement.effect }}"{{ if $statement.actions }},
            "Action": {{ toJson $statement.actions }}{{end}}{{ if $statement.resources }},
            "Resource": {{ toJson $statement.resources }}{{end}}
          }{{ if lt $i $statementsLength }},{{end }}
          {{- end }}
        ]
      }
  {{- end }}
{{- end }}