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: provide std.native('helmTemplate') #336

Merged
merged 13 commits into from
Aug 18, 2020
Merged

Conversation

Duologic
Copy link
Member

@Duologic Duologic commented Aug 9, 2020

I've taken the same approach as to how the helm template command is build up:

$ helm template --help
...
Usage:
  helm template [NAME] [CHART] [flags]
...
local helm = import 'github.com/grafana/jsonnet-libs/helm-util/helm.libsonnet';

{
  version:: 'v0.16.0',

  values:: {
    installCRDs: true,
    global: {
      podSecurityPolicy: {
        enabled: true,
        useAppArmor: false,
      },
    },
  },

  chart: helm.template(
    name='cert-manager',
    chart='jetstack/cert-manager',
    conf={
      values: $.values,
      flags: [
        '--version=%s % $.version',
      ],
    },
  ),
}

original PoC: grafana/jsonnet-libs#315

Example:

```
{
  generated:
    std.native('helmTemplate')(
      'cert-manager',
      'charts/jetstack/cert-manager',
      {
        values: {
          installCRDs: true,
          global: {
            podSecurityPolicy: {
              enabled: true,
              useAppArmor: false,
            },
          },
        },
        flags: [
          '--version=v0.13.0',
        ],
      }
    ),
}
```
@Duologic Duologic changed the title feat(helm): provide helmTemplate native function feat: provide std.native('helmTemplate') Aug 10, 2020
@simonswine simonswine self-requested a review August 12, 2020 09:35
@Duologic Duologic marked this pull request as ready for review August 12, 2020 14:58
pkg/helmraiser/helm.go Outdated Show resolved Hide resolved
pkg/helmraiser/helm.go Outdated Show resolved Hide resolved
pkg/helmraiser/helm.go Outdated Show resolved Hide resolved
pkg/helmraiser/helm.go Show resolved Hide resolved
@sh0rez sh0rez added component/jsonnet Everything regarding the jsonnet language component/kubernetes Working with Kubernetes clusters kind/feature Something new should be added labels Aug 12, 2020
@Duologic Duologic requested a review from sh0rez August 12, 2020 16:25
pkg/helmraiser/helm.go Outdated Show resolved Hide resolved

func confToArgs(conf map[string]interface{}) ([]string, []string, error) {
var args []string
var tempFiles []string
Copy link
Member

Choose a reason for hiding this comment

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

You only ever add one file this this, right? No need for a slice then

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm optimizing for future cases where we might want to pass multiple files (it is possible to have multiple --values with helm template) and can easily extend this without having to change this elsewhere. If you don't see value in this, I'll remove it.

pkg/helmraiser/helm.go Outdated Show resolved Hide resolved
@Duologic Duologic requested a review from sh0rez August 13, 2020 08:40
pkg/helmraiser/helm.go Outdated Show resolved Hide resolved
pkg/helmraiser/helm.go Outdated Show resolved Hide resolved
@captncraig
Copy link
Contributor

This is so cool I can't contain my excitement. I'm going to start a pr in deployment_tools that depend on this functionality and trust that it will get merged into a release in the near future.

Duologic and others added 2 commits August 18, 2020 08:54
Even though this isn't the right naming, it is consistent with https://tanka.dev/env-vars

Co-authored-by: sh0rez <me@shorez.de>
Co-authored-by: sh0rez <me@shorez.de>
@Duologic Duologic requested a review from sh0rez August 18, 2020 06:55
Copy link
Member

@sh0rez sh0rez left a comment

Choose a reason for hiding this comment

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

Wow ❤️ 🚀

@Duologic Duologic merged commit 6d99591 into master Aug 18, 2020
@Duologic Duologic deleted the duologic/helmraiser branch August 18, 2020 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/jsonnet Everything regarding the jsonnet language component/kubernetes Working with Kubernetes clusters kind/feature Something new should be added
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants