Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

waypoint.hcl: "labels" variable and selector functions #2065

Merged
merged 12 commits into from
Aug 23, 2021

Conversation

mitchellh
Copy link
Contributor

This PR introduces the labels HCL variable that is a mapping of the finalized label set for an operation. "Finalized" here means: it has merged all the labels from various sources and this is the final set that will be stored in the database. This variable has multiple uses:

  • It can be used to set configuration. For example, you might want to set annotations on Kubernetes resource based on Waypoint labels.
  • It can be used to make contextual decisions. For example, you can change the namespace of a Kubernetes deployment based on some set of labels.

To support these use cases, this PR also introduces the selectormatch and selectorlookup functions. Please see the docs/examples for their usage.

@mitchellh mitchellh requested a review from a team August 17, 2021 21:50
hclCtx, labels, err := cc.labels(hclCtx, app)
if err != nil {
return nil, err
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note for reviewers: the main reason I did it this way here is because I know we're going to introduce label filters and so on into choosing what plugin to use and various other things. So I set it up so that we already have the labels at the beginning of an operation (rather than say... figuring this out purely in the config package) so we can make those decisions for future features.

@mitchellh
Copy link
Contributor Author

Note also, the docs here are focused on the labels var but we do plan on doing a much bigger labels focused docs sweep.

Copy link
Member

@briancain briancain left a comment

Choose a reason for hiding this comment

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

🏷️ 👍🏻

Copy link
Contributor

@krantzinator krantzinator left a comment

Choose a reason for hiding this comment

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

Sick.

@mitchellh mitchellh merged commit 28ef3ea into main Aug 23, 2021
@mitchellh mitchellh deleted the feature/hcl-labels branch August 23, 2021 19:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants