Variable substitution: `Octopus.Template.Each.Index` & Math expression

Dears

A) the documentation does not include an example for Octopus.Template.Each.Index → I think it would be helpful.

B) The documentation states that it is a ‘Zero-based index of the iteration count’ . Unfortunately I have a use case where I am forced to go with a One-base index → is there a way to wrap ‘Octopus.Template.Each.Index’ into an expression that allows me to add +1 to the index?

I guess

#{each Node in Nodes}
cluster_formation.classic_config.nodes.#{Octopus.Template.Each.Index+1} = rabbit@#{Node}
#{/each}

will not work, right?

Hi @henkepa1874

Hopefully I can answer your questions below. I’m not too familiar with the Template class, so I’ll try my best.

A) I’ll look into if we have some documentation on this. Since most of us here in support haven’t used, or even heard of this before, it wouldn’t surprise me if we don’t have anything native for this. I suspect this won’t be covered as most customers probably won’t have come across it. I’ll ask around and look into this.

B) Probably the best bet to target a +1 index would be to store the index in a separate variable and add to it. The current way in your example, as you mentioned, won’t likely work due to the “+1” being in the parameter selector.

Let me know how the index selection goes, and I’ll ask internally about getting some documentation setup for this.

Kind Regards
Sean

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.