Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/spinnaker] Use "tpl" function to render the content of additional scripts #13045

Merged
merged 3 commits into from
May 21, 2019

Conversation

legal90
Copy link
Contributor

@legal90 legal90 commented Apr 15, 2019

What this PR does / why we need it:

This PR adds tpl fuction into templates for additionalScripts and additionalInitScript.
This allows to use variable interpolation in the body of these scripts. For example:

# custom_values.yaml

halyard:
  additionalScripts:
    create: true
    data:
      00_customize_accounts.sh: |-
        #!/bin/bash
        $HAL_COMMAND config provider kubernetes account edit {{ .Values.kubeConfig.deploymentContext }} \
          --namespaces {{ .Release.Namespace }} \
          --only-spinnaker-managed=true \
          --check-permissions-on-startup=false

Up until now we would have to hard-code the namespace and the account name in the custom script, which is not flexible.

Special notes for your reviewer:

These changes are backward compatible, because tpl works seamlessly with plain strings (which is the expected value there at this moment).
However, since that is a new feature for this chart, I bumped the minor version number.

tpl function is available in Helm >= v2.5.0.

Checklist

  • DCO signed
  • Chart Version bumped

@helm-bot helm-bot added Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 15, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @legal90. Thanks for your PR.

I'm waiting for a helm member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 15, 2019
@legal90
Copy link
Contributor Author

legal90 commented Apr 15, 2019

/assign @viglesiasce

@maorfr
Copy link
Member

maorfr commented Apr 22, 2019

/assign
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 22, 2019
@legal90
Copy link
Contributor Author

legal90 commented Apr 22, 2019

@maorfr Thanks! Do you know what needs to be done with e2e tests to make this PR passed? I see that the test error is not related to this PR changeset.

@maorfr
Copy link
Member

maorfr commented Apr 22, 2019

/test pull-charts-e2e

@maorfr
Copy link
Member

maorfr commented Apr 22, 2019

maybe there is something wrong with the tpl syntax?
look at this for reference:
https://github.com/helm/charts/blob/master/stable/grafana/templates/configmap.yaml#L26

@legal90
Copy link
Contributor Author

legal90 commented Apr 22, 2019

@maorfr Hm.. I don't think so. I verified this tpl syntax from my branch and it works as expected.
But e2e tests are failing with the same error in all other PRs too. For example:

@legal90
Copy link
Contributor Author

legal90 commented Apr 26, 2019

/test pull-charts-e2e

1 similar comment
@maorfr
Copy link
Member

maorfr commented Apr 28, 2019

/test pull-charts-e2e

Copy link
Collaborator

@dwardu89 dwardu89 left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels May 17, 2019
@dwardu89
Copy link
Collaborator

/lgtm cancel

@k8s-ci-robot k8s-ci-robot removed lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels May 17, 2019
@dwardu89
Copy link
Collaborator

Removed LGTM while speaking to @legal90 related to some caveat using the tpl

after switching to `tpl`,  it will blow up if the user has some Go-like stuff in their definitions (`{{  }}`)

That is less-less likely, but some percentage of users might be affected. Let me show the actual example...```

@dwardu89
Copy link
Collaborator

@legal90 can you add a note to the README.md to advising users that are using the older chart versions that this change might require some work with a workaround please?

@legal90
Copy link
Contributor Author

legal90 commented May 17, 2019

Yup, I will add a note about that. 👍

P.s. The actual example is:

  additionalConfigMaps:
    create: true
    data: 
      artifact-template-helm-chart.jinja: |-
        [
          {
            "name": "{{ properties.chart_name }}",
            "version": "{{ properties.chart_version }}",
            "reference": "{{ properties.helm_account }}",
            "type": "helm/chart"
          }
        ]

Since that is a Jinja template for Spinnaker, it should be dumped to a file as it is. After passing that through tpl it will stop working because a stuff betwee {{ }}will be treated as Go template.

@helm-bot helm-bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 17, 2019
@legal90 legal90 changed the title [stable/spinnaker] Use "tpl" function to render the content of additional scripts and configs [stable/spinnaker] Use "tpl" function to render the content of additional scripts May 17, 2019
@legal90
Copy link
Contributor Author

legal90 commented May 17, 2019

@dwardu89 I have changed this PR and left tpl function calls only for rendering additionalScripts and additionalInitScript bodies.
So, I decided to do not include it to CconfigMaps and Secrets to minimize the risk of potential issues like the one described above.

So, I believe using tpl for scripts will be safe since the chance of having {{ }} there is much less.
Is that OK?

@dwardu89
Copy link
Collaborator

/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels May 20, 2019
…onal scripts and init scripts

This allows to use variable interpolation in the body of these scripts.

Signed-off-by: Mikhail Zholobov <legal90@gmail.com>
Signed-off-by: Mikhail Zholobov <legal90@gmail.com>
@k8s-ci-robot k8s-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label May 20, 2019
Signed-off-by: Mikhail Zholobov <legal90@gmail.com>
@helm-bot helm-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 20, 2019
@legal90
Copy link
Contributor Author

legal90 commented May 20, 2019

I've included the README.md changes from PR #13764, just to don't bump the version twice.

@dwardu89
Copy link
Collaborator

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 21, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dwardu89, legal90

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 8299179 into helm:master May 21, 2019
amine7536 pushed a commit to amine7536/charts that referenced this pull request May 21, 2019
…onal scripts (helm#13045)

* [stable/spinnaker] Use "tpl" function to render the content of additional scripts and init scripts

This allows to use variable interpolation in the body of these scripts.

Signed-off-by: Mikhail Zholobov <legal90@gmail.com>

* [stable/spinnaker] Bump chart version

Signed-off-by: Mikhail Zholobov <legal90@gmail.com>

* [stable/spinnaker] Update README.md

Signed-off-by: Mikhail Zholobov <legal90@gmail.com>
@legal90 legal90 deleted the spinnaker branch May 22, 2019 06:35
eyenx pushed a commit to eyenx/charts that referenced this pull request May 28, 2019
…onal scripts (helm#13045)

* [stable/spinnaker] Use "tpl" function to render the content of additional scripts and init scripts

This allows to use variable interpolation in the body of these scripts.

Signed-off-by: Mikhail Zholobov <legal90@gmail.com>

* [stable/spinnaker] Bump chart version

Signed-off-by: Mikhail Zholobov <legal90@gmail.com>

* [stable/spinnaker] Update README.md

Signed-off-by: Mikhail Zholobov <legal90@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). lgtm Indicates that a PR is ready to be merged. ok-to-test size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants