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

Feature: add filebase64 function #11791

Merged

Conversation

conorevans
Copy link
Contributor

Signed-off-by: Conor Evans coevans@tcd.ie

Closes #11522

As noted in that issue, Terraform implements this function. About a month ago, the MakeFileFunc in Terraform deviated from hashicorp/go-cty-funcs which Nomad is using and which this PR continues to use. If the code change in Terraform is relevant here, perhaps it should be copied over to hashicorp/go-cty-funcs, but I'll leave that in your hands.

I copied the Doc largely from Terraform, removing some of the content that was Terraform-focused. If it needs to be updated, let me know or make the changes yourself as you see fit. Docs are pretty tricky to get right and you maintainers will know much better than me how you'd like to phrase it.

I didn't add a test here, mostly because there is no existing functions_test file with a Test Table I could easily plug in to, and the Terraform test didn't transfer over. Unfortunately there's also no test in hashicorp/go-cty-funcs. If you want to add one, please do so as you see fit.

@hashicorp-cla
Copy link

hashicorp-cla commented Jan 6, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

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

LGTM!

Sorry about the long delay in reviewing this @conorevans. I've rebased this on main and added a changelog entry. It'll get merged once our docs preview renders and we'll get this out in Nomad 1.3.2. Thanks for your patience!

Bench test verifying this works as intended:

job "httpd" {
...
      env {
        DATA_BASE64 = filebase64("world.txt")
      }
...
}
$ echo 'hello' > world.txt
$ nomad job run ./httpd.nomad
$ nomad job inspect httpd | jq '.Job.TaskGroups[0].Tasks[0].Env'
{
  "DATA_BASE64": "aGVsbG8K"
}

Signed-off-by: Conor Evans <coevans@tcd.ie>
@tgross
Copy link
Member

tgross commented Jun 6, 2022

@tgross tgross merged commit 2a01807 into hashicorp:main Jun 6, 2022
Nomad - Community Issues Triage automation moved this from In Progress to Done Jun 6, 2022
@github-actions
Copy link

github-actions bot commented Oct 8, 2022

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Development

Successfully merging this pull request may close these issues.

Support filebase64 function with Noamd
3 participants