-
Notifications
You must be signed in to change notification settings - Fork 21
Description
What problem are you facing?
When using EnvironmentConfig selectors with valueFromFieldPath, the raw field value is used directly as the label match value. There is no way to transform or manipulate the value before matching. This is limiting in real-world scenarios where the composite resource field values don't directly correspond to EnvironmentConfig label values.
For example, if a claim is submitted from namespace team-alpha and the EnvironmentConfig is labeled config: alpha-environment-config, there's currently no way to extract alpha from team-alpha and concatenate it with -environment-config to form the label match value. Users are forced to either restructure their labeling scheme or use additional intermediate resources.
function-patch-and-transform already supports transforms during patch resolution, but function-environment-configs has no equivalent capability for label selector values.
How could this Function help solve your problem?
Add transform support to matchLabels selectors, allowing field path values to be transformed before being used as label match values. A subset of transforms from function-patch-and-transform that produce valid Kubernetes label values would cover the majority of use cases:
- Map — value lookup (e.g.
production→prod) - Match — pattern-based matching with fallback
- String transforms — Format, Convert (ToUpper/ToLower), TrimPrefix, TrimSuffix, Regexp (group extract + replace with backreferences), Replace
Example usage:
matchLabels:
- key: config
valueFromFieldPath: "metadata.labels[crossplane.io/claim-namespace]"
transforms:
- type: string
string:
type: Regexp
regexp:
match: "^team-(.+)$"
replace: "${1}-environment-config"This would also support reading from metadata fields using bracket notation (e.g. metadata.labels[crossplane.io/claim-namespace]) and handling non-string field types (booleans, numbers) by using GetValue() instead of GetString().