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

request: support more of the normal jsonnet input flags #353

Closed
ghostsquad opened this issue Aug 20, 2020 · 8 comments
Closed

request: support more of the normal jsonnet input flags #353

ghostsquad opened this issue Aug 20, 2020 · 8 comments
Labels
kind/feature Something new should be added

Comments

@ghostsquad
Copy link

ghostsquad commented Aug 20, 2020

This is a request to have Tanka support some of the other standard flags for use with jsonnet:

--tla-code
--tla-code-file

--tla-str
--tla-str-file

--ext-str-file
--ext-code-file

-J / --jpath

Also, the naming of these should likely be standard between TK and Jsonnet for ease of discovery. I filed a separate issue for that here: #354

@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label kind/feature to this issue, with a confidence of 0.99. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@issue-label-bot issue-label-bot bot added the kind/feature Something new should be added label Aug 20, 2020
@ghostsquad ghostsquad changed the title request: support --tla-code and --tla-str request: support more of the normal jsonnet input flags Aug 20, 2020
@sh0rez
Copy link
Member

sh0rez commented Aug 21, 2020

TLAs have been added by #340. This also changed the flags to match those of jsonnet.

Current flags:

--tla-code
--tla-str

--ext-code
--ext-str

Because Tanka has the model of ranked import paths (https://tanka.dev/libraries/import-paths), I'm not sure if allowing arbitrary jpaths is a good thing here.

Generally vendor, lib and the local environments directory should allow enough flexibility to layout any kind of library hierarchy. It also makes it easy for newcomers to Tanka / developers adopting existing projects to quickly find libraries, because of muscle memory.

WDYT?

@ghostsquad
Copy link
Author

although I would normally agree. If I'm working only on kubernetes, this directory structure makes sense. But I'm using jsonnet for a lot more than that, and as such, I'm actually importing files outside of my kubernetes/environments folder.

I have a global "config", that's used to hold values that are common among a variety of generated configuration files.

For now, I'm simply forced to do ugly relative imports, of which, some start with ../../../../

@davidovich
Copy link
Contributor

I think this is a valid ask, and Tanka could enforce its preferred order, and append the user defined -J paths.

I have a shared base config for CI-CD, and this would allow inclusion even if not in the intended Tanka import order.

@sh0rez sh0rez mentioned this issue Aug 24, 2020
@sh0rez
Copy link
Member

sh0rez commented Sep 1, 2020

TLAs and extVars are implemented, using the same flags as Jsonnet does.

JPATH has its own tracking issue: #365

Closing as there is nothing to do here anymore :)

@lukasmrtvy
Copy link

@sh0rez but --ext-code-file is not implemented..., seems there isnt a way how to dynamically include file, for example use case with sops:

sops exec-file secrets.enc.yaml 'tk show . --ext-code-file secrets={}'

nor

local secrets = import std.extVar('secrets_path'));
sops exec-file secrets.enc.yaml 'tk show . --ext-str secrets_path={}'

can not work.. any workaround?

sops exec-file - execute a command with the decrypted contents as a temporary file

thanks

@davidovich
Copy link
Contributor

@lukasmrtvy Assuming you have a tanka top level function that takes a secrets object in parameter, I am able to inject secrets in Tanka in this manner:

sops exec-file mySecretFile.enc.json 'tk apply --tla-code secrets={secret: import \"{}\"} environment'

Hope that helps.

@danihodovic
Copy link

danihodovic commented Nov 15, 2021

--ext-code-file would be useful for injecting secrets from temporary files.

The following works for top level variables

sops exec-file ../terraform/staging/secrets.enc.yaml \
	"tk apply environments/staging --ext-code secrets='import \"{}\"'" \
	--output-type=json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Something new should be added
Projects
None yet
Development

No branches or pull requests

5 participants