Skip to content

feat: Support cross-namespace package references with PackageRef field #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 20, 2025

Conversation

evanwave
Copy link
Contributor

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.

@RobertIndie RobertIndie merged commit 985bd76 into main Jul 20, 2025
5 checks passed
@RobertIndie RobertIndie deleted the package-ref branch July 20, 2025 14:50
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.

2 participants