-
Notifications
You must be signed in to change notification settings - Fork 58
Inject metadata into HCL templates #737
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
base: main
Are you sure you want to change the base?
Conversation
618f76a
to
08a01c3
Compare
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.
Great work on this @allisonlarson! One minor question: what about the old code that was setting the meta
attributes? That's redundant now so can we remove it?
// the values with any existing meta block or attribute. If the parsing fails, | ||
// or the HCL is invalid, the original job is returned unmodified so that the | ||
// errors can be caught later during job parsing. |
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.
I like that we're giving up here so that we avoid having to reimplement all the logic the parser already has. 👍
@tgross Correct, it should be redundant! I had left it as-is in the case of a fallback, but it makes more sense to remove it completely. |
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!
Description
Currently, nomad-pack injects metadata about the pack into the json definition of the job and not the HCL. When a pack job is managed outside of nomad-pack, like in the UI, the job loses its reference to the pack and is unable to be managed with nomad-pack until the job is completely removed.
This change takes the rendered HCL and injects the metadata into the job/meta block, instead of just the json. It will merge with the defined meta attribute or block if it exists. In the case that it cannot successfully parse the HCL, the original job will be returned. If the job is has multiple meta attributes/blocks defined, it will merge with one and return the other untouched. This is invalid, but will be caught in the next step of the process, which is parsing the templates in nomad. The approach is to inject these values with as little change to the underlying job as possible, and allow any existing invalid HCL to still be passed through and caught in nomad during the parsing step.
Reminders
CHANGELOG.md
entryChanges to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.