Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
Only validate status on updates
Browse files Browse the repository at this point in the history
This basically ensures that spec validations don't include status.
  • Loading branch information
Jeff Peeler committed Apr 23, 2018
1 parent 929c6e2 commit 22152ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/apis/servicecatalog/validation/binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func internalValidateServiceBinding(binding *sc.ServiceBinding, create bool) fie
validateServiceBindingName,
field.NewPath("metadata"))...)
allErrs = append(allErrs, validateServiceBindingSpec(&binding.Spec, field.NewPath("spec"), create)...)
allErrs = append(allErrs, validateServiceBindingStatus(&binding.Status, field.NewPath("status"), create)...)
if create {
allErrs = append(allErrs, validateServiceBindingCreate(binding)...)
} else {
Expand Down Expand Up @@ -244,5 +243,6 @@ func ValidateServiceBindingUpdate(new *sc.ServiceBinding, old *sc.ServiceBinding
func ValidateServiceBindingStatusUpdate(new *sc.ServiceBinding, old *sc.ServiceBinding) field.ErrorList {
allErrs := field.ErrorList{}
allErrs = append(allErrs, internalValidateServiceBinding(new, false)...)
allErrs = append(allErrs, validateServiceBindingStatus(&new.Status, field.NewPath("status"), false)...)
return allErrs
}
2 changes: 2 additions & 0 deletions pkg/apis/servicecatalog/validation/binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"

"github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog"
)
Expand Down Expand Up @@ -567,6 +568,7 @@ func TestValidateServiceBinding(t *testing.T) {

for _, tc := range cases {
errs := internalValidateServiceBinding(tc.binding, tc.create)
errs = append(errs, validateServiceBindingStatus(&tc.binding.Status, field.NewPath("status"), false)...)
if len(errs) != 0 && tc.valid {
t.Errorf("%v: unexpected error: %v", tc.name, errs)
continue
Expand Down

0 comments on commit 22152ab

Please sign in to comment.