Skip to content

Comments

Feat selector transforms#99

Open
jtucci wants to merge 5 commits intocrossplane-contrib:mainfrom
jtucci:feat-selector-transforms
Open

Feat selector transforms#99
jtucci wants to merge 5 commits intocrossplane-contrib:mainfrom
jtucci:feat-selector-transforms

Conversation

@jtucci
Copy link

@jtucci jtucci commented Feb 15, 2026

Description of your changes

Adds transform support to label selectors in EnvironmentConfig selection. This allows field path values to be transformed before being used as label match values, bringing a subset of function-patch-and-transform's transform functionality to environment config selection.

Supported transforms:

  • Map — value lookup from a key-value map
  • Match — pattern-based matching (literal and regexp) with fallback
  • String — Format, Convert (ToUpper/ToLower), TrimPrefix, TrimSuffix, Regexp (group extract + replace with backreferences), Replace

Key changes:

  • input/v1beta1/transforms.go — Transform types (subset of patch-and-transform, excluding math/convert/base64/hash/join as they don't produce valid label values)
  • transforms.go — Transform resolution logic, faithfully copied from function-patch-and-transform with regexp replace backreference support added
  • transforms_test.go — Unit tests for map, match, and string transforms
  • fn.go — Changed GetString() to GetValue() on field path resolution to support non-string fields (booleans, numbers), with transforms applied before converting to label string
  • input/v1beta1/environment.go — Added Transforms field to EnvironmentSourceSelectorLabelMatcher
  • Added examples/selector_with_transforms/ demonstrating regexp group extract, regexp replace with backreferences, map transform, and case conversion

Example use case:

matchLabels:
  - key: config
    valueFromFieldPath: "metadata.labels[crossplane.io/claim-namespace]"
    transforms:
      - type: string
        string:
          type: Regexp
          regexp:
            match: "^team-(.+)$"
            replace: "${1}-environment-config"

team-alphaalpha-environment-config

Fixes #100

I have:

@jtucci jtucci requested a review from phisco as a code owner February 15, 2026 19:49
@jtucci jtucci force-pushed the feat-selector-transforms branch from 3d9a647 to a9862c2 Compare February 15, 2026 19:50
@jtucci
Copy link
Author

jtucci commented Feb 15, 2026

Hey @phisco :) Is this feature something we can add in?

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.

Add transform support to EnvironmentConfig label selectors

2 participants