Skip to content

Support value substitution in attribute values. - #24

Merged
fdevans merged 3 commits into
mainfrom
enh/substitutions
Jul 10, 2026
Merged

Support value substitution in attribute values.#24
fdevans merged 3 commits into
mainfrom
enh/substitutions

Conversation

@gschueler

@gschueler gschueler commented Apr 8, 2025

Copy link
Copy Markdown
Member

Release Notes

The Attribute Match Enhancer now supports value substitution, letting you build new tags and attribute values from a node's existing attributes (for example, image-${ec2.imageId}). It also adds a new "is present" match operator (~~) so you can target nodes simply based on whether an attribute exists, regardless of its value.

PR Details

Summary

Adds the ability to substitute existing node attribute values into newly-added attributes and tags, and introduces a new presence-check match operator.

Changes

  • New ~~ "is present" operator — matches when an attribute exists (no value required), complementing the existing !! "not present" operator. Operator documentation updated to indicate which operators take no value.
  • Attribute substitution — new opt-in "Enable Attribute Substitution" property. When enabled, added attribute values and tags may reference existing node attributes using ${attribute} syntax (e.g. tag1,image-${ec2.imageId} or newattr=some-${oldattr}/${otherattr}). Unknown references resolve to an empty string. Disabled by default, so existing configurations are unaffected.
  • Cleanup — converted match/add/tag helpers to static methods and removed cached mutable state (loadedProps/loadedTags); added a descriptive message and cause to the properties-parsing IllegalArgumentException; replaced a wildcard import with explicit imports.

Tests

Added Spock coverage for attribute-value substitution, tag substitution (both with substitution enabled and disabled), and a parameterized matrix validating the ~~ and !! operators.

@gschueler
gschueler requested a review from Copilot April 8, 2025 23:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

Files not reviewed (1)
  • src/test/groovy/org/rundeck/plugins/nodes/attributes/AttributeNodeEnhancerSpec.groovy: Language not supported
Comments suppressed due to low confidence (2)

src/main/java/org/rundeck/plugins/nodes/attributes/AttributeNodeEnhancer.java:119

  • The IllegalArgumentException thrown here lacks a descriptive message, which may hinder debugging. Consider adding a message detailing the cause, possibly including the IOException message.
throw new IllegalArgumentException();

src/main/java/org/rundeck/plugins/nodes/attributes/AttributeNodeEnhancer.java:84

  • [nitpick] The parameter name 'addTags1' is unclear and inconsistent with similar naming elsewhere. Consider renaming it to 'addTags' to improve clarity.
public static void addAllTags(final Set<String> tags, Map<String, String> attributes, String addTags1, boolean enableSubstitution) {

@gschueler
gschueler requested a review from Copilot April 9, 2025 00:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • src/test/groovy/org/rundeck/plugins/nodes/attributes/AttributeNodeEnhancerSpec.groovy: Language not supported
Comments suppressed due to low confidence (1)

src/main/java/org/rundeck/plugins/nodes/attributes/AttributeNodeEnhancer.java:133

  • Add unit tests to cover the substitution logic, including cases with special characters and missing attribute values to ensure the new functionality behaves as expected.
private static String substitute(Map<String, String> attributes, String value) {

Comment thread src/main/java/org/rundeck/plugins/nodes/attributes/AttributeNodeEnhancer.java Outdated
@fdevans fdevans changed the title add capability to substitute values Support value substitution in attribute values. Jul 10, 2026
Attribute values containing $ or \ were interpreted as regex group
references/escapes during substitution, causing errors or mangled
output. Quote the replacement and add tests for special characters.
@fdevans
fdevans requested a review from a team July 10, 2026 19:02
@fdevans
fdevans merged commit f24426c into main Jul 10, 2026
2 checks passed
@fdevans
fdevans deleted the enh/substitutions branch July 10, 2026 19:05
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.

3 participants