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

Access Node Meta and Attrs in template #2488

Merged
merged 2 commits into from
Mar 28, 2017
Merged

Conversation

dadgar
Copy link
Contributor

@dadgar dadgar commented Mar 27, 2017

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"
}

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"
}
```
@@ -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
Copy link
Member

Choose a reason for hiding this comment

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

EnvMapAll

Copy link
Member

@schmichael schmichael left a 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

@dadgar dadgar merged commit 3750f97 into master Mar 28, 2017
@dadgar dadgar deleted the f-node-values-template branch March 28, 2017 18:10
@nugend
Copy link

nugend commented Mar 29, 2017

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.

@cynicaljoy
Copy link

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
      }

@github-actions
Copy link

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 Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants