Skip to content

Support template as annotation for fencing id#32

Open
marjuscako wants to merge 1 commit intokvaps:masterfrom
marjuscako:master
Open

Support template as annotation for fencing id#32
marjuscako wants to merge 1 commit intokvaps:masterfrom
marjuscako:master

Conversation

@marjuscako
Copy link

@marjuscako marjuscako 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>
@marjuscako
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