-
Notifications
You must be signed in to change notification settings - Fork 52
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
[docs] Add documentation for nomad-pack template functions #494
base: main
Are you sure you want to change the base?
Conversation
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.
couple lil things, but otherwise LGTM!
##### Example | ||
|
||
``` | ||
[[ $cs := ( customSpew | withDisableCapacities true ) ]][[ $cs.Sdump . ]] |
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.
should be a toStringList
example
##### Example | ||
|
||
``` | ||
|
||
``` | ||
|
||
##### Output | ||
|
||
``` | ||
``` |
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.
empty example/output for nomadRegions
|
||
#### `fileContents` <a id="fileContents"></a> | ||
|
||
Imports the contents of a file on the local file system into the template at runtime. |
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 it be clarified that the files are relative to the directory where nomad-pack is invoked? I'm pretty sure they aren't relative to the job as that isn't working for me (which is frustrating, because thats where I'd expect them to be).
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.
The fileContents
function is part of the job meta-templating and is run while building the job spec itself. Should you want to import files while processing the jobspec , you should consider the HCL2 file
function, which would work more like you expect; but requires that the file to include always travel with the job spec.
I think this is also missing the functions defined [here]https://github.com/hashicorp/nomad-pack/blob/3c0178a561b360906c591718edb25ae25ae9d964/internal/pkg/variable/parser/template_context.go#L159( for variable retrieval. |
##### Example | ||
|
||
``` | ||
[[ $cs := ( customSpew | withMaxDepth true ) ]][[ $cs.Sdump . ]] |
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.
Max Depth should be an integer
[[ $cs := ( customSpew | withMaxDepth 5) ]][[ $cs.Sdump . ]]
##### Example | ||
|
||
``` | ||
[[ $cs := ( customSpew | withDisableMethods true ) ]][[ $cs.Sdump . ]] |
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.
withDisableMethods sets s.DisableMethods to true. So only "true" is not allowed (want 1 got 2). So it should be:
[[ $cs := ( customSpew | withDisableMethods ) ]][[ $cs.Sdump . ]]
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.
Same with all the following, which use "true" as parameter
Could this get merged and then improved at a later date? |
This PR starts chipping away at the Pack documentation tech debt by documenting the template helper functions that Pack provides to the template context.