-
Notifications
You must be signed in to change notification settings - Fork 169
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(jsonnet): expose Environment at runtime #163
Conversation
This change allows to use the parsed `spec.json` contents at runtime: ```jsonnet local tk = import "tk"; { env: tk.env, } ``` It also introduces a Tanka native API extension (`import "tk"`), which serves as a wrapper for all `std.extVar` and `std.nativeFunc` we use, so that we can make breaking changes to those internals, without affecting the public API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good @sh0rez, just a few small comments / questions. The new Eval function looks like it should be functionally equivalent although I'm a bit nervous about it. Is there existing code coverage there?
pkg/jsonnet/importer.go
Outdated
} | ||
} | ||
|
||
// Import implements the functionality offered by the ExtendedImporter | ||
func (i *ExtendedImporter) Import(importedFrom, importedPath string) (contents jsonnet.Contents, foundAt string, err error) { | ||
// check if an interceptor handles this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you help me understand this better? Is the idea that you can only have one interceptor and one postprocessor for a given import at a time? I'd like to see some stronger godocs around these interceptors and processors since the ordering is important (i.e., if two interceptors operate on yaml, only the first will ever be used).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This change allows to use the parsed
spec.json
contents at runtime:It also introduces a Tanka native API extension (
import "tk"
), which serves asa wrapper for all
std.extVar
andstd.nativeFunc
we use, so that we can makebreaking changes to those internals, without affecting the public API.
metadata.name
of the Environment is the CLI argument and not the actual name. This is fixed in #131 but not merged yetFixes #161