Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Accept dictionaries/maps too in releases: #893

Open
rustycl0ck opened this issue Oct 16, 2019 · 1 comment
Open

feat: Accept dictionaries/maps too in releases: #893

rustycl0ck opened this issue Oct 16, 2019 · 1 comment

Comments

@rustycl0ck
Copy link

It would become a lot easier to reuse the releases with minor changes if the releases could be a collection of maps/dictionaries instead of lists. For example, it would allow the use of yaml anchors or maybe other templating engines (go templates or jsonnet or anything) to reuse the contents of a previous release with minor changes.

Current:

releases:
  - name: vault                            
    namespace: vault                       
    labels:                                  
      foo: bar
    chart: roboll/vault-secret-manager     
    version: ~1.24.1                       
    missingFileHandler: Warn 
    values:
      - vault.yaml
      - address: https://vault.example.com
      - image:
          tag: {{ requiredEnv "IMAGE_TAG" | quote }}
        db:
          username: {{ requiredEnv "DB_USERNAME" }}
          password: {{ requiredEnv "DB_PASSWORD" }}
        proxy:
          domain: '{{ requiredEnv "PLATFORM_ID" }}.my-domain.com'
          scheme: '{{ env "SCHEME" | default "https" }}'
    set:
    - name: foo.config
      file: path/to/file
    - name: bar[0]
      values:
      - 1
      - 2
    - name: namespace
      value: {{ .Namespace }}
    secrets:
      - vault_secret.yaml
  - name: myvault
    namespace: myvault                       
    labels:                                  
      foo: bar
    chart: roboll/vault-secret-manager     
    version: ~1.24.1                       
    missingFileHandler: Warn 
    values:
      - vault.yaml
      - address: https://vault.example.com
      - image:
          tag: {{ requiredEnv "IMAGE_TAG" | quote }}
        db:
          username: {{ requiredEnv "DB_USERNAME" }}
          password: {{ requiredEnv "DB_PASSWORD" }}
        proxy:
          domain: '{{ requiredEnv "PLATFORM_ID" }}.my-domain.com'
          scheme: '{{ env "SCHEME" | default "https" }}'
    set:
    - name: foo.config
      file: path/to/file
    - name: bar[0]
      values:
      - 1
      - 2
    - name: namespace
      value: {{ .Namespace }}
    secrets:
      - myvault_secret.yaml

Expected:

  releases:
-   - name: vault
+   vault: &vaultRelease
+     name: vault
      namespace: vault
      labels:
        foo: bar
      chart: roboll/vault-secret-manager
      version: ~1.24.1
      missingFileHandler: Warn
      values:
        - vault.yaml
        - address: https://vault.example.com
        - image:
            tag: {{ requiredEnv "IMAGE_TAG" | quote }}
          db:
            username: {{ requiredEnv "DB_USERNAME" }}
            password: {{ requiredEnv "DB_PASSWORD" }}
          proxy:
            domain: '{{ requiredEnv "PLATFORM_ID" }}.my-domain.com'
            scheme: '{{ env "SCHEME" | default "https" }}'
      set:
      - name: foo.config
        file: path/to/file
      - name: bar[0]
        values:
        - 1
        - 2
      - name: namespace
        value: {{ .Namespace }}
      secrets:
        - vault_secret.yaml
-   - name: myvault
-     namespace: myvault
-     labels:
-       foo: bar
-     chart: roboll/vault-secret-manager
-     version: ~1.24.1
-     missingFileHandler: Warn
-     values:
-       - vault.yaml
-       - address: https://vault.example.com
-       - image:
-           tag: {{ requiredEnv "IMAGE_TAG" | quote }}
-         db:
-           username: {{ requiredEnv "DB_USERNAME" }}
-           password: {{ requiredEnv "DB_PASSWORD" }}
-         proxy:
-           domain: '{{ requiredEnv "PLATFORM_ID" }}.my-domain.com'
-           scheme: '{{ env "SCHEME" | default "https" }}'
-     set:
-     - name: foo.config
-       file: path/to/file
-     - name: bar[0]
-       values:
-       - 1
-       - 2
-     - name: namespace
-       value: {{ .Namespace }}
-     secrets:
-       - myvault_secret.yaml
+   myvault:
+     <<: *vaultRelease
+     name: myvault
+     namespace: myvault
+     secrets:
+       - myvault_secret.yaml

Not the best example, but should be enough to get the idea.

@aegershman
Copy link
Contributor

I'm not a maintainer, and I'm not that good at golang, but I predict this would be tricky (or impossible?) to parse that yaml into a struct since keys such as myvault can't be dynamically defined as a top-level key. If the repetition is bad enough you might get some lift out of pre-processing the helmfile.yml with a tool like ytt... which I know, that's what everybody loves to hear, "use more yaml templating!", but it could be worth investigating? Will back off, don't mean to hijack your thread & maybe a maintainer has better insights / could offer a better solution, just putting out (unsolicited) feedback 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants