crossplane-contrib / crossplane-contrib/function-status-transformer
CRD enum values don't match function implementation for MatchType
- Dominant language
- Go
- Stars
- 20
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
## Problem
The CRD file `package/input/function-status-transformer.fn.crossplane.io_statustransformations.yaml` defines the `type` field enum values as:
```yaml
enum:
- MatchAny
- MatchAll
```
However, the function implementation in `fn.go` only recognizes these four constant values:
```go
case v1beta1.AnyResourceMatchesAnyCondition:
case v1beta1.AnyResourceMatchesAllConditions:
case v1beta1.AllResourcesMatchAnyCondition:
case v1beta1.AllResourcesMatchAllConditions:
```
## Current Behavior
When users provide `type: MatchAny` or `type: MatchAll` (the only values the CRD allows):
1. ✅ Validation passes (matches CRD enum)
2. ❌ The function receives an unrecognized value
3. ❌ Execution falls through to the `default` case, always using `AllResourcesMatchAllConditions` behavior
4. ❌ This silently produces incorrect matching logic
For example, if a user intends to use `AnyResourceMatchesAnyCondition` (match ANY resource with ANY condition), they have no way to express this in the CRD, and even if they tried to use the full name, validation would reject it.
## Root Cause
The CRD enum values are out of sync with the Go code constants defined in `input/v1beta1/input.go`.
## Solution
Update the CRD enum values in `package/input/function-status-transformer.fn.crossplane.io_statustransformations.yaml` (line 153-155) from:
```yaml
enum:
- MatchAny
- MatchAll
```
To:
```yaml
enum:
- AnyResourceMatchesAnyCondition
- AnyResourceMatchesAllConditions
- AllResourcesMatchAnyCondition
- AllResourcesMatchAllConditions
```
This will:
- ✅ Allow users to specify the correct matching behavior
- ✅ Ensure validation catches invalid values
- ✅ Make the CRD accurately reflect what the function accepts
- ✅ Prevent silent failures where users get unexpected behavior
## Related Code References
- CRD: https://github.com/crossplane-contrib/function-status-transformer/blob/main/package/input/function-status-transformer.fn.crossplane.io_statustransformations.yaml#L153-L155
- Go constants: https://github.com/crossplane-contrib/function-status-transformer/blob/main/input/v1beta1/input.go#L38-L50
- Function switch statement: https://github.com/crossplane-contrib/function-status-transformer/blob/main/fn.go#L246-L257
Contributor guide
No contributing guide indexed for this repository
Research direction
Read the constants in input/v1beta1/input.go and the MatchType switch in fn.go, then inspect package/input/function-status-transformer.fn.crossplane.io_statustransformations.yaml around lines 153-155. Update the CRD enum to the four implementation values and verify that validation accepts those values instead of MatchAny and MatchAll.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100