Skip to content

Commit

Permalink
apis/apis: clarify that binding.spec.reference.export is never nil b/…
Browse files Browse the repository at this point in the history
…c validation

Signed-off-by: Dr. Stefan Schimanski <[email protected]>
  • Loading branch information
sttts committed Jan 16, 2025
1 parent 5e67ef9 commit fc1e66a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
1 change: 1 addition & 0 deletions pkg/admission/apibinding/apibinding_admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (o *apiBindingAdmission) Admit(ctx context.Context, a admission.Attributes,
}

if apiBinding.Spec.Reference.Export == nil {
// should not happen due to validation.
return nil
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/admission/apibinding/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ func ValidateAPIBindingUpdate(oldBinding, newBinding *apisv1alpha1.APIBinding) f
// ValidateAPIBindingReference validates an APIBinding's BindingReference.
func ValidateAPIBindingReference(reference apisv1alpha1.BindingReference, path *field.Path) field.ErrorList {
allErrs := field.ErrorList{}

// For now, field "export" is required via OpenAPI. But just in case...

if reference.Export == nil {
allErrs = append(allErrs, field.Required(path.Child("export"), ""))
} else if reference.Export.Name == "" {
Expand Down
6 changes: 1 addition & 5 deletions pkg/reconciler/apis/apibinding/conflict_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ func newConflictChecker(clusterName logicalcluster.Name,
}
for _, b := range bindings {
if b.Spec.Reference.Export == nil {
continue
}

if b.Spec.Reference.Export == nil {
// this should not happen because of OpenAPI
// this should not happen because of validation.
return nil, fmt.Errorf("APIBinding %s|%s has no cluster reference", logicalcluster.From(b), b.Name)
}
path := logicalcluster.NewPath(b.Spec.Reference.Export.Path)
Expand Down

0 comments on commit fc1e66a

Please sign in to comment.