You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Support cross-namespace package references with PackageRef field (#203)
### Motivation
The current Function CRD uses a simple `Package` field to reference packages, which limits the ability to reference packages from different namespaces. This change introduces a new `PackageRef` structure that supports cross-namespace package references while maintaining backward compatibility and proper label management.
The main problems this solves:
1. **Cross-namespace package references**: Functions can now reference packages from different namespaces
2. **Improved package label management**: Package labels now include namespace information to avoid conflicts
3. **Better validation**: Enhanced webhook validation for cross-namespace references
4. **Consistent labeling**: Automatic generation of package labels with namespace prefix
### Modifications
1. **Updated Function CRD structure**:
- Replaced `Package` field with `PackageRef` structure containing `Name` and `Namespace` fields
- Updated all test files to use the new `PackageRef` structure
2. **Enhanced webhook validation**:
- Modified `function_webhook.go` to validate cross-namespace package references
- Updated package label generation to include namespace prefix (format: `namespace.package-name`)
- Added comprehensive tests for cross-namespace scenarios
3. **Improved controller logic**:
- Updated `function_controller.go` to handle cross-namespace package lookups
- Modified `mapPackageToFunctions` to work with namespace-aware package labels
- Removed manual package label management from controller (now handled by webhook)
4. **Enhanced test coverage**:
- Added extensive tests for cross-namespace package references
- Updated existing tests to use `PackageRef` instead of `Package`
- Added tests for automatic package label generation
- Added integration tests for multiple functions with auto-generated labels
5. **Updated package webhook**:
- Modified `packages_webhook.go` to use namespace-aware package labels when finding referencing functions
The changes maintain backward compatibility while providing a more robust and flexible package reference system that supports cross-namespace operations.
0 commit comments