Skip to content

[FEAT repo-guard] - Add kubebuilder validation markers to all CRD types #237

Description

@onuryilmaz

User Story

As a platform operator, I want invalid CRD resources to be rejected at apply time by kubectl, so that misconfigured resources never reach the controller.

Description

Currently none of the repo-guard CRD types (GithubOrganization, GithubTeam, GithubTeamRepository, Github, LDAPGroupProvider, GenericExternalMemberProvider, etc.) have +kubebuilder validation markers. There is no admission webhook in place either. As a result, resources with empty required fields, invalid permission values, or malformed URLs are admitted silently and only fail during reconciliation with hard-to-debug errors.

Adding +kubebuilder markers to the _types.go files causes make manifests to embed OpenAPI validation into the generated CRD schemas, enabling client-side validation via kubectl and server-side validation via the Kubernetes API server — no webhook required.

This is tracked as Pillar 3 of epic #95. This issue covers the marker additions only.

Acceptance Criteria

  • +kubebuilder:validation:MinLength=1 added to all required string fields (spec.github, spec.organization, spec.team, etc.)
  • +kubebuilder:validation:Minimum=1 added to spec.installationID on GithubOrganization
  • +kubebuilder:validation:Enum=admin;push;pull;maintain;triage added to all permission fields
  • +kubebuilder:validation:Pattern=^https?:// added to URL fields on Github and GenericExternalMemberProvider
  • spec.organization immutability enforced via +kubebuilder:validation:XValidation CEL oldSelf rule
  • make manifests regenerates CRDs cleanly with new constraints
  • Existing valid resources are unaffected (no breaking changes)

Reference Issues

Epic: #95

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogReady for sprint planning; triggers project additionfeatureNew functionality or enhancementkubernetesKubernetes specific features, CRDs, and controllersneeds-refinementNeeds scoping before implementation

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions