Conversation
1. AviLoadBalancerConfig validation markers:
- spec.cloudName: add MinLength=1 constraint (+kubebuilder:validation:MinLength=1)
- spec.credentialSecretRef.name: add canonical DNS-1123 subdomain validation
(+kubebuilder:validation:MinLength=1, MaxLength=253, Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`)
2. envtest test suite:
- add test/cel/aviloadbalancerconfig_test.go covering valid admission, empty server admission,
cloudName defaulting vs. MinLength=1 rejection, and credentialSecretRef.name pattern validation.
Testing Done:
- make generate — regenerated CRD manifests and client code cleanly
- make test-cel — all CEL envtest cases pass against kube-apiserver
- make test-unit — all unit tests pass
Signed-off-by: Fangchi Wang <fangchi.wang@broadcom.com>
wfangchi
marked this pull request as ready for review
August 27, 2026 03:04
- Add optional CertificateAuthorityData field to AviLoadBalancerConfigSpec to store PEM-encoded CA certificates used to verify the Avi Controller's TLS certificate. - Enables synchronous certificate format validation in admission webhooks on both Create and Update operations without depending on external Secret lifecycle timing. - Maintains backward compatibility: if empty or omitted, controllers fall back to reading the CA certificate from the Secret referenced by CredentialSecretRef. Testing Done: - make generate — regenerated CRD manifests and deepcopy stubs - make test-unit — unit tests pass Signed-off-by: Fangchi Wang <fangchi.wang@broadcom.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces the
certificateAuthorityDatafield toAviLoadBalancerConfigSpecalong with admission-time validation markers and anenvtestCEL test suite forAviLoadBalancerConfig.API changes
AviLoadBalancerConfigSpeccertificateAuthorityData(new field) — Added optional string field (json:"certificateAuthorityData,omitempty") containing PEM-encoded CA certificates used to verify the Avi Controller's TLS certificate.net-operator) on both Create and Update operations without depending on external Secret lifecycles or ordering guarantees.credentialSecretRef.cloudName— Added+kubebuilder:validation:MinLength=1constraint to reject explicitly-empty strings while preserving theDefault-Clouddefault when omitted or zero-valued via typed Go clients (omitempty).server— Intentionally left withoutMinLength=1to ensure backward compatibility with existing running configurations; runtime validation remains guarded by controller and VAPI layers.ClientSecretReferencename— Added canonical Kubernetes DNS-1123 subdomain validation markers (+kubebuilder:validation:MinLength=1,MaxLength=253, andPattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$). Ensures secret references conform to standard Kubernetes resource naming requirements.Tests
envtestintegration test cases added intest/cel/aviloadbalancerconfig_test.gocovering all validation rules and defaulting behavior:AviLoadBalancerConfigadmission.spec.server(backward-compatibility preservation).spec.cloudNamedefaulting to"Default-Cloud"when omitted or zero-valued via typed Go client (omitemptybehavior).spec.cloudNamerejection byMinLength=1when sent explicitly as""via unstructured JSON payload.spec.credentialSecretRef.name(e.g.avi.creds.v1).spec.credentialSecretRef.namepatterns (uppercase characters, leading/trailing hyphens, consecutive dots, and empty strings).make generate— clean regeneration of deepcopy and CRD YAML manifests.make test-unit&make test-cel— all unit tests and CEL integration tests passing.