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

Support template as annotation for fencing id #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marjus45
Copy link

@marjus45 marjus45 commented Jun 28, 2024

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:

fencing/id-template: {{ . | lower }}

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:

  1. If the fencing/id annotation in the node exists, then the fencing id will be the value of the annotation.
  2. If the fencing/id annotation in the PodTemplate exists, then the fencing id will be the value of the annotation.
  3. If the fencing/id-template annotation in the PodTemplate exists, then the value will be calculated based on this template with input the node name.
  4. The fencing id will equal to 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.

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:

fencing/id-template: {{ . | lower }}

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:
1. If the fencing/id annotation in the node exists, then the fencing id
   will be the value of the annotation.
2. If the fencing/id annotation in the PodTemplate exists, then the
   fencing id will be the value of the annotation.
3. If the fencing/id-template annotation in the PodTemplate exists, then
   the value will be calculated based on this template with input the
   node name.
4. The fencing id will equal to 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.

Signed-off-by: Marjus Cako <marios.cako@hpe.com>
@marjus45
Copy link
Author

I am open to upgrade also to a later version of Go, e.g., the latest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant