Support template as annotation for fencing id #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently the fencing id is set statically in a PodTemplate annotation. With this patch we add support to parse a template from the annotation
fencing/id-template
, in order to calculate dynamically the fencing id based on the node name.The template itself should expect as input only one argument, the node name. For example, if a user specifies the annotation:
it will output the node name in lower case. The template supports all sprig functions of the go-template. The precedence of the fencing id calculation goes as:
fencing/id
annotation in the node exists, then the fencing id will be the value of the annotation.fencing/id
annotation in the PodTemplate exists, then the fencing id will be the value of the annotation.fencing/id-template
annotation in the PodTemplate exists, then the value will be calculated based on this template with input the node name.This patch includes a bump of the Go version, since Go 1.18 does not support the sprig functions with the text/template.