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

How to add dynamic hooks from file #2019

Closed
i053322 opened this issue Dec 15, 2021 · 1 comment
Closed

How to add dynamic hooks from file #2019

i053322 opened this issue Dec 15, 2021 · 1 comment

Comments

@i053322
Copy link

i053322 commented Dec 15, 2021

helmfile.yaml

bases:
  - common-helmfile.yaml

# defer the template rendering to happen only after the values are loaded.
---

releases:
  - name: controller
    values:
      - values/controller-yaml
    hooks:
{{ .Values.hooks }}`

common-helmfile.yaml

environments:
  default:
    values:
      - values/common-values.yaml
      
common-values.yaml
key:value

I want to add dynamic hooks from file and I don't want to add it in the common-values.yaml
I tried to add another base but I need that two bases will be installed the default and the new one

bases:
  - common-helmfile.yaml
  - hooks-helmfile.yaml
# defer the template rendering to happen only after the values are loaded.
---

releases:
  - name: controller
    values:
      - values/controller-yaml
    hooks:
{{ .Values.hooks }}`

hooks-helmfile.yaml

environments:
  default: / i tried also to change the name and to inject it with the helmfile and it didn't work
    values:
      - values/hooks-values.yaml

hooks.-values.yaml
c:d

helmfile --file ./helmfile/helmfile.yaml sync
I got an error
template: stringTemplate:22:10: executing "stringTemplate" at <.Values.hooks>: map has no entry for key "hooks"

I tried also to change the hooks

hooks:

  • values/hooks-values.yaml

and I got an error
line 22: cannot unmarshal !!str values/... into event.Hook

I tried also to change the base

bases:
  - test-helmfile.yaml
  - common-helmfile.yaml

and to add new file

test-helmfile.yaml

environments:
  dev:
    values:
    - values/common-values.yaml
    - values/hooks-values.yaml

it is only working when I remove the common-helmfile.yaml and it didn't find the env.

@mumoshu
Copy link
Collaborator

mumoshu commented Jan 15, 2022

@i053322 I think you're trying to dump YAML dict without marshaling it into YAML.

    hooks:
{{ .Values.hooks }}`

This is no good. You should instead say:

    hooks:
{{ .Values.hooks | toYaml | indent 6}}`

or something like that.

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

No branches or pull requests

2 participants