-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Access Node Meta and Attrs in template #2488
Conversation
This PR allows accessing the Node's attributes and metadata as in a template. ``` template { data = "{{ env \"attr.unique.network.ip-address\" }}" destination = "local/out" } ```
client/driver/env/env.go
Outdated
@@ -287,6 +287,20 @@ func (t *TaskEnvironment) EnvMap() map[string]string { | |||
return m | |||
} | |||
|
|||
// EnvMap returns the environment variables that will be set as well as node |
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.
EnvMapAll
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.
Don't forget a changelog entry
Could a docs clarification around meta be made? It's a little unclear at the moment when something is a node meta value vs a runtime meta value. |
leaving a comment here in hopes it helps somebody...had a case where I wanted to conditionally declare an environment variable if a meta key was a specific value, here's my solution: template {
env = true
destination = "local/dynamic.env"
data = <<EOF
{{ $val := env "meta.sometimes_exists_sometimes_doesnt" }}
{{ if eq $val "magic-value" }}HELLO_WORLD=true{{ end }}
EOF
} |
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. |
This PR allows accessing the Node's attributes and metadata as in a
template.