From 678849685143f224d03a5416d7e68afc83a88af3 Mon Sep 17 00:00:00 2001 From: thenav56 Date: Mon, 1 Sep 2025 15:28:48 +0545 Subject: [PATCH] feat: allow object for extraManifests --- .../templates/extraManifests.yaml | 18 ++- toggle-django-helm/tests/values-3.yaml | 144 ++++++++++++++++++ toggle-django-helm/values.yaml | 2 +- 3 files changed, 160 insertions(+), 4 deletions(-) create mode 100644 toggle-django-helm/tests/values-3.yaml diff --git a/toggle-django-helm/templates/extraManifests.yaml b/toggle-django-helm/templates/extraManifests.yaml index 567f7bf..8c613f5 100644 --- a/toggle-django-helm/templates/extraManifests.yaml +++ b/toggle-django-helm/templates/extraManifests.yaml @@ -1,4 +1,16 @@ -{{ range .Values.extraManifests }} +{{- if .Values.extraManifests }} + {{- $extra := .Values.extraManifests }} + {{- if kindIs "map" $extra }} + {{- range $key, $val := $extra }} --- -{{ tpl (toYaml .) $ }} -{{ end }} +{{ tpl (toYaml $val) $ }} + {{- end }} + {{- else if kindIs "slice" $extra }} + {{- range $val := $extra }} +--- +{{ tpl (toYaml $val) $ }} + {{- end }} + {{- else }} + {{- fail "Values.extraManifests must be a map or an array of objects" }} + {{- end }} +{{- end }} diff --git a/toggle-django-helm/tests/values-3.yaml b/toggle-django-helm/tests/values-3.yaml new file mode 100644 index 0000000..8f5fd50 --- /dev/null +++ b/toggle-django-helm/tests/values-3.yaml @@ -0,0 +1,144 @@ +environment: ALPHA + +image: + name: ghcr.io/example/example + tag: v1.0.1 + +ingress: + enabled: true + host: myapp.example.com + className: nginx + +redis: + enabled: true + fullnameOverride: my-app-redis + master: + persistence: + storageClass: longhorn + +postgresql: + enabled: true + fullnameOverride: "my-app-postgres" + auth: + postgresPassword: "random-strong-password" + database: "my-app" + primary: + persistence: + storageClass: "longhorn" + size: 2Gi + +minio: + enabled: true + fullnameOverride: my-app-minio + global: + defaultStorageClass: longhorn + apiIngress: + ingressClassName: nginx + hostname: myapp-minio.example.com + auth: + rootPassword: "random-strong-password" + persistence: + size: 2Gi +# NOTE: To change bucket name look at defaultBuckets and provisioning.extraCommands + +api: + resources: + requests: + cpu: "0.2" + +worker: + image: + name: ghcr.io/example/example + tag: v1.0.1 + beat: + resources: + requests: + cpu: "0.1" + flower: + enabled: true + resources: + requests: + cpu: "0.1" + queues: + # NOTE: Make sure keys are lowercase + default: + resources: + requests: + cpu: "0.1" + +env: + ENV_1: VALUE_1 + +secrets: + # Postgres + POSTGRES_DB: "{{ $.Values.postgresql.auth.database }}" + POSTGRES_USER: "postgres" + POSTGRES_PASSWORD: "{{ $.Values.postgresql.auth.postgresPassword }}" + POSTGRES_HOST: "{{ include \"postgresql.v1.primary.fullname\" $.Subcharts.postgresql }}" + POSTGRES_PORT: "{{ include \"postgresql.v1.service.port\" $.Subcharts.postgresql }}" + + # Redis + REDIS_URL: "redis://{{ printf \"%s-master\" (include \"common.names.fullname\" .Subcharts.redis) }}:6379/0" + + # Minio (S3) + AWS_S3_AWS_ENDPOINT_URL: "https://{{ $.Values.minio.apiIngress.hostname }}/" + AWS_S3_ACCESS_KEY_ID: "{{ required \".Values.minio.auth.rootUser\" $.Values.minio.auth.rootUser }}" + AWS_S3_SECRET_ACCESS_KEY: "{{ required \".Values.minio.auth.rootPassword\" $.Values.minio.auth.rootPassword }}" + AWS_S3_REGION: "us-east-1" + # NOTE: To change bucket name look at defaultBuckets and provisioning.extraCommands + AWS_S3_BUCKET_STATIC_NAME: static-data + AWS_S3_BUCKET_MEDIA_NAME: media-data + +extraManifests: + cnpg_backup_schedule: + apiVersion: postgresql.cnpg.io/v1 + kind: ScheduledBackup + metadata: + name: backup-daily + spec: + cluster: + name: pg-cluster + suspend: false # Pause this backup + immediate: true # Create immediate backup when creating this resource + schedule: "0 0 0 * * *" + backupOwnerReference: self + method: plugin + pluginConfiguration: + name: barman-cloud.cloudnative-pg.io + cnpg_object_store: + apiVersion: barmancloud.cnpg.io/v1 + kind: ObjectStore + metadata: + name: aws-s3-store + spec: + retentionPolicy: "30d" + configuration: + destinationPath: "s3://my-db-backup/barman/" + s3Credentials: + accessKeyId: + name: barman-s3-creds + key: ACCESS_KEY_ID + secretAccessKey: + name: barman-s3-creds + key: ACCESS_SECRET_KEY + wal: + compression: gzip + maxParallel: 4 + cnpg_cluster: + apiVersion: postgresql.cnpg.io/v1 + kind: Cluster + metadata: + name: pg-cluster + spec: + instances: 3 + enablePDB: true + storage: + size: 300Mi + monitoring: + enablePodMonitor: true + backup: {} + plugins: + - name: barman-cloud.cloudnative-pg.io + isWALArchiver: true + parameters: + barmanObjectName: aws-s3-store diff --git a/toggle-django-helm/values.yaml b/toggle-django-helm/values.yaml index b2878e8..8e441be 100644 --- a/toggle-django-helm/values.yaml +++ b/toggle-django-helm/values.yaml @@ -253,4 +253,4 @@ secrets: {} # AWS_S3_BUCKET_STATIC_NAME: static-data # AWS_S3_BUCKET_MEDIA_NAME: media-data -extraManifests: [] +# extraManifests: [] or {}