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: Release Template #439

Merged
merged 1 commit into from
Jan 21, 2019
Merged

feat: Release Template #439

merged 1 commit into from
Jan 21, 2019

Conversation

mumoshu
Copy link
Collaborator

@mumoshu mumoshu commented Jan 21, 2019

This feature is supposed to help advanced use-cases like Conventional Directory Structure explained in several issues like #428.

Newly added configuration keys templates, missingFileHandler, and the ability to defer executing template expressions in values, secrets, namespace, and chart of releases allows you to abstract away repetitions into a reusable template:

templates:
  default: &default
    missingFileHandler: Warn
    namespace: "{{`{{ .Release.Name }}`}}"
    chart: stable/{{`{{ .Release.Name }}`}}
    values:
    - config/{{`{{ .Release.Name }}`}}/values.yaml
    - config/{{`{{ .Release.Name }}`}}/{{`{{ .Environment.Name }}`}}.yaml
    secrets:
    - config/{{`{{ .Release.Name }}`}}/secrets.yaml
    - config/{{`{{ .Release.Name }}`}}/{{`{{ .Environment.Name }}`}}-secrets.yaml

releases:
- name: envoy
  <<: *default
- name: metricbeat
  <<: *default
# and so on..

See the updated documentation for more details.

Resolves #428

This feature is supposed to help advanced use-cases like Conventional Directory Structure explained in several issues like roboll#428.

Newly added configuration keys `templates`, `missingFileHandler`, and the ability to defer executing template expressions in `values`, `secrets`, `namespace`, and `chart` of releases allows you to abstract away repetitions into a reusable template:

```yaml
templates:
  default: &default
    missingFileHandler: Warn
    values:
    - config/{{`{{ .Release.Name }}`}}/values.yaml
    - config/{{`{{ .Release.Name }}`}}/{{`{{ .Environment.Name }}`}}.yaml
    secrets:
    - config/{{`{{ .Release.Name }}`}}/secrets.yaml
    - config/{{`{{ .Release.Name }}`}}/{{`{{ .Environment.Name }}`}}-secrets.yaml

releases:
- name: envoy
  namespace: "{{`{{ .Release.Name }}`}}"
  chart: stable/{{`{{ .Release.Name }}`}}
  <<: *default
```

See the updated documentation for more details.

Resolves roboll#428
@goruha
Copy link

goruha commented Jan 21, 2019

@mumoshu That's cool

@mumoshu
Copy link
Collaborator Author

mumoshu commented Jan 21, 2019

Thanks! Let's see how this works in the wild.

@mumoshu mumoshu merged commit f813ac2 into roboll:master Jan 21, 2019
@mumoshu mumoshu deleted the release-template branch January 21, 2019 16:19
@sstarcher
Copy link
Contributor

Thanks, I'll check this out.

@sstarcher
Copy link
Contributor

sstarcher commented Jan 21, 2019

Just tested it out it's working great, but I do now get 50 messages of "skippping blah" per run.
One of my helmfile went from 175 lines to 125 lines. A pretty solid reduction. If we had first class support for the template instead of using the anchors it could reduce my file another 17 lines.

@sstarcher
Copy link
Contributor

The repositories, templates, and environments block now takes about about 1/3rd of my file weighting in at 45 lines that is essentially duplicated between half a dozen helmfiles.

@mumoshu
Copy link
Collaborator Author

mumoshu commented Jan 21, 2019

Glad it worked 👍

Regarding the "skipping blah" logs, perhaps you'd need a better log-level for it, something other than Warn or Error - Would it be Debug so that helmfile won't print it at the default log-level of Info?

@mumoshu
Copy link
Collaborator Author

mumoshu commented Jan 21, 2019

The repositories, templates, and environments block now takes about about 1/3rd of my file weighting in at 45 lines that is essentially duplicated between half a dozen helmfiles.

Nice. Then we need "includes" for that, right? :) #380

@mumoshu
Copy link
Collaborator Author

mumoshu commented Jan 21, 2019

And probably use a "global variable"(#398) across the helmfiles to locate the "library" helmfile that should be included to all of em.

@sstarcher
Copy link
Contributor

@mumoshu ya, something like debug would work great is that already support? I glanced at the code and it was not immediately apparent.

@mumoshu
Copy link
Collaborator Author

mumoshu commented Jan 21, 2019 via email

@sstarcher
Copy link
Contributor

@mumoshu excellent thanks I'll think more about the globals.

mumoshu added a commit to mumoshu/helmfile that referenced this pull request Jan 22, 2019
- Fix panics when `missingFileHandler` is not defined
- Fix `missingFileHandler: Error` had been writing errors at the Warn level
- Add `Info` and `Debug` as valid values

Ref roboll#439 (comment)
@mumoshu mumoshu mentioned this pull request Jan 22, 2019
@mumoshu
Copy link
Collaborator Author

mumoshu commented Jan 22, 2019

#440 adds missingFileHandler: Debug

mumoshu added a commit that referenced this pull request Jan 22, 2019
- Fix panics when `missingFileHandler` is not defined
- Fix `missingFileHandler: Error` had been writing errors at the Warn level
- Add `Info` and `Debug` as valid values

Ref #439 (comment)
mumoshu added a commit to mumoshu/helmfile that referenced this pull request Jan 22, 2019
There was a regression introduced by roboll#439 that broke the first-pass rendering completely. This fixes that.
mumoshu added a commit that referenced this pull request Jan 22, 2019
There was a regression introduced by #439 that broke the first-pass rendering completely. This fixes that.
@georgevella
Copy link

Sorry to bring this PR back to life, but got a question about this feature. Any particular reason why the version field is not templated the same way as chart, namespace, etc. ?

@sstarcher
Copy link
Contributor

several fields are not templated such as labels, but that feature could be added.

@mumoshu
Copy link
Collaborator Author

mumoshu commented Mar 29, 2019

@georgevella Would you mind creating an issue to track that? Thanks!

@mumoshu
Copy link
Collaborator Author

mumoshu commented Mar 29, 2019

Just for reference, templating for labels is tracked in #446

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

Successfully merging this pull request may close these issues.

4 participants