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

[stable/k8s-resources]: introduce enabled flag #619

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

eshepelyuk
Copy link
Contributor

@eshepelyuk eshepelyuk commented Oct 21, 2024

Description

In case when values.yaml is not static, but generated, using tools like helmfile, or KCL or any other. It's often needed to dynamically enable / disable some resources based on certain conditions. For example using Helm like syntax

values.gotmpl.yaml
{{- $condition1 := .... -}}
{{- $condition2 := .... -}}
ServiceAccounts:
  {{- if $condition1 }}
  - fullnameOverride: sa1
    annotations: 
      foo: bar1
  {{- end }}
  {{- if $condition2 }}
  - fullnameOverride: sa2
    annotations: 
      foo: bar2
  {{- end }}
  {{- if or $condition1 $condition2 }}
  - fullnameOverride: sa3
    annotations: 
      foo: bar3
  {{- end }
  - fullnameOverride: sa4
    annotations: 
      foo: bar4

With this PR the above fragment could be rewritten like below, resulting in more readable and concise code.

values.gotmpl.yaml
{{- $condition1 := .... -}}
{{- $condition2 := .... -}}
ServiceAccounts:
  - fullnameOverride: sa1
    enabled: {{- $condition1 -}}
    annotations: 
      foo: bar1
  - fullnameOverride: sa2
    enabled: {{- $condition2 -}}
    annotations: 
      foo: bar2
  - fullnameOverride: sa3
    enabled: {{- or $condition1 $condition2 -}}
    annotations: 
      foo: bar3
  - fullnameOverride: sa4
    annotations: 
      foo: bar4

Checklist

  • Title of the PR starts with chart name (e.g. [stable/mychartname])
  • I have read the contribution instructions, bumped chart version and regenerated the docs
  • Github actions are passing

@eshepelyuk eshepelyuk marked this pull request as ready for review October 21, 2024 14:16
@eshepelyuk eshepelyuk requested a review from a team as a code owner October 21, 2024 14:16
@max-rocket-internet
Copy link
Member

Maybe some explanation as to why this is needed?

@eshepelyuk
Copy link
Contributor Author

Maybe some explanation as to why this is needed?

Added description to a PR as requested.

Copy link
Member

@max-rocket-internet max-rocket-internet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation @eshepelyuk, looks good!

@max-rocket-internet max-rocket-internet merged commit dc13add into deliveryhero:master Oct 22, 2024
11 checks passed
fekaiser pushed a commit to gastromatic/delivery-hero-helm-charts that referenced this pull request Oct 23, 2024
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.

2 participants