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: allow using external variables in export and env list #1112

Merged
merged 2 commits into from
Jul 30, 2024

Conversation

sabeechen
Copy link
Contributor

Using std.extVar in an inline environment's definition will cause tk env list and tk export ... --recursive to fail.

An example use case (what I'm writing this to support), is when you have inline environments whose namespace needs to be set at runtime, such as a review environment whos namespace is dynamic eg:

{
    prod: {
        apiVersion: 'tanka.dev/v1alpha1',
        kind: 'Environment',
        metadata: {
            name: 'prod',
        },
        spec: {
            namespace: 'prod',
            applyStrategy: 'server',
        },
    },
    review: {
        apiVersion: 'tanka.dev/v1alpha1',
        kind: 'Environment',
        metadata: {
            name: 'review',
        },
        spec: {
            namespace: std.extVar('reviewNamespace'),
            applyStrategy: 'server',
        },
    }
}

Tanka has a bunch of different ways one could work around this, but its very convenient to be able to specify the default namespace so succinctly.

  • For tk export ... --recursive the JsonnetOpts were already parsed and just needed to be plumbed through to where environments are discovered.
  • For tk env list, the ext-str and tla-str arguments needed to be added to the command.

@sabeechen sabeechen requested a review from a team as a code owner July 24, 2024 22:03
@CLAassistant
Copy link

CLAassistant commented Jul 24, 2024

CLA assistant check
All committers have signed the CLA.

@sabeechen sabeechen changed the title Allows using variables in export and env list Allows using external variables in export and env list Jul 27, 2024
@zerok zerok changed the title Allows using external variables in export and env list feat: Allows using external variables in export and env list Jul 29, 2024
@zerok zerok changed the title feat: Allows using external variables in export and env list feat: Allow using external variables in export and env list Jul 29, 2024
Copy link
Contributor

@zerok zerok left a comment

Choose a reason for hiding this comment

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

Thank you 🙂 Makes sense and look good! Can you please just fix that one linting issues?

cmd/tk/export.go Outdated Show resolved Hide resolved
@zerok zerok changed the title feat: Allow using external variables in export and env list feat: allow using external variables in export and env list Jul 29, 2024
Co-authored-by: Horst Gutmann <[email protected]>
@sabeechen
Copy link
Contributor Author

Thanks for the review!

@zerok zerok merged commit 80ffbfd into grafana:main Jul 30, 2024
9 checks passed
@zerok
Copy link
Contributor

zerok commented Jul 30, 2024

Thank you for working on this 🙂

@sabeechen
Copy link
Contributor Author

Awesome! I've made a fork of tanka that my org is currently using as a workaround so its not like we're hurting, but is there a way to know when when this will be included in a standard release?

@zerok
Copy link
Contributor

zerok commented Jul 31, 2024

I wanted to cut a new release some time this week if time permits 🙂

@zerok
Copy link
Contributor

zerok commented Aug 1, 2024

v0.28.0 is out now 😄 https://github.com/grafana/tanka/releases/tag/v0.28.0

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.

3 participants