Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contrib/examples/apiserver/instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ metadata:
name: test-instance
namespace: test-ns
spec:
externalClusterServiceClassName: test-serviceclass
externalClusterServicePlanName: example-plan-1
clusterServiceClassExternalName: test-serviceclass
clusterServicePlanExternalName: example-plan-1
2 changes: 1 addition & 1 deletion contrib/examples/walkthrough/ups-instance-default-sp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: ups-instance-default
namespace: test-ns
spec:
externalClusterServiceClassName: user-provided-service
clusterServiceClassExternalName: user-provided-service
parameters:
credentials:
name: root
Expand Down
4 changes: 2 additions & 2 deletions contrib/examples/walkthrough/ups-instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ metadata:
name: ups-instance
namespace: test-ns
spec:
externalClusterServiceClassName: user-provided-service
externalClusterServicePlanName: default
clusterServiceClassExternalName: user-provided-service
clusterServicePlanExternalName: default
parameters:
credentials:
param-1: value-1
Expand Down
6 changes: 3 additions & 3 deletions docs/walkthrough-1.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ metadata:
uid: 07ecf19d-a781-11e7-8b18-0242ac110005
spec:
externalID: 7f2c176a-ae67-4b5e-a826-58591d85a1d7
externalClusterServiceClassName: user-provided-service
externalClusterServicePlanName: default
clusterServiceClassExternalName: user-provided-service
clusterServicePlanExternalName: default
parameters:
credentials:
param-1: value-1
Expand All @@ -216,7 +216,7 @@ status:
status: "True"
type: Ready
externalProperties:
externalClusterServicePlanName: default
clusterServicePlanExternalName: default
parameterChecksum: e65c764db8429f9afef45f1e8f71bcbf9fdbe9a13306b86fd5dcc3c5d11e5dd3
parameters:
credentials:
Expand Down
6 changes: 3 additions & 3 deletions docs/walkthrough-1.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ metadata:
uid: 07ecf19d-a781-11e7-8b18-0242ac110005
spec:
externalID: 7f2c176a-ae67-4b5e-a826-58591d85a1d7
externalClusterServiceClassName: user-provided-service
externalClusterServicePlanName: default
clusterServiceClassExternalName: user-provided-service
clusterServicePlanExternalName: default
parameters:
credentials:
param-1: value-1
Expand All @@ -204,7 +204,7 @@ status:
status: "True"
type: Ready
externalProperties:
externalClusterServicePlanName: default
clusterServicePlanExternalName: default
parameterChecksum: e65c764db8429f9afef45f1e8f71bcbf9fdbe9a13306b86fd5dcc3c5d11e5dd3
parameters:
credentials:
Expand Down
16 changes: 8 additions & 8 deletions pkg/apis/servicecatalog/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,20 +416,20 @@ type ServiceInstance struct {
// specify the desired Class/Plan, this structure specifies the
// allowed ways to specify the intent.
type PlanReference struct {
// ExternalClusterServiceClassName is the human-readable name of the
// ClusterServiceClassExternalName is the human-readable name of the
// service as reported by the broker. Note that if the broker changes
// the name of the ClusterServiceClass, it will not be reflected here,
// and to see the current name of the ClusterServiceClass, you should
// follow the ClusterServiceClassRef below.
//
// Immutable.
ExternalClusterServiceClassName string
// ExternalClusterServicePlanName is the human-readable name of the plan
ClusterServiceClassExternalName string
// ClusterServicePlanExternalName is the human-readable name of the plan
// as reported by the broker. Note that if the broker changes the name
// of the ClusterServicePlan, it will not be reflected here, and to see
// the current name of the ClusterServicePlan, you should follow the
// ClusterServicePlanRef below.
ExternalClusterServicePlanName string
ClusterServicePlanExternalName string

// ClusterServiceClassName is the kubernetes name of the
// ClusterServiceClass.
Expand All @@ -446,11 +446,11 @@ type ServiceInstanceSpec struct {

// ClusterServiceClassRef is a reference to the ClusterServiceClass
// that the user selected.
// This is set by the controller based on ExternalClusterServiceClassName
// This is set by the controller based on ClusterServiceClassExternalName
ClusterServiceClassRef *ClusterObjectReference
// ClusterServicePlanRef is a reference to the ClusterServicePlan
// that the user selected.
// This is set by the controller based on ExternalClusterServicePlanName
// This is set by the controller based on ClusterServicePlanExternalName
ClusterServicePlanRef *ClusterObjectReference

// Parameters is a set of the parameters to be passed to the underlying
Expand Down Expand Up @@ -593,10 +593,10 @@ const (
// ServiceInstancePropertiesState is the state of a ServiceInstance that
// the ServiceBroker knows about.
type ServiceInstancePropertiesState struct {
// ExternalClusterServicePlanName is the name of the plan that the broker knows this
// ClusterServicePlanExternalName is the name of the plan that the broker knows this
// ServiceInstance to be on. This is the human readable plan name from the
// OSB API.
ExternalClusterServicePlanName string
ClusterServicePlanExternalName string

// Parameters is a blob of the parameters and their values that the broker
// knows about for this ServiceInstance. If a parameter was sourced from
Expand Down
18 changes: 9 additions & 9 deletions pkg/apis/servicecatalog/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,26 +428,26 @@ type ServiceInstance struct {
// allowed ways to specify the intent.
//
// Currently supported ways:
// - ExternalClusterServiceClassName and ExternalClusterServicePlanName
// - ClusterServiceClassExternalName and ClusterServicePlanExternalName
// - ClusterServiceClassName and ClusterServicePlanName
//
// For both of these ways, if a ClusterServiceClass only has one plan
// then leaving the *ServicePlanName is optional.
type PlanReference struct {
// ExternalClusterServiceClassName is the human-readable name of the
// ClusterServiceClassExternalName is the human-readable name of the
// service as reported by the broker. Note that if the broker changes
// the name of the ClusterServiceClass, it will not be reflected here,
// and to see the current name of the ClusterServiceClass, you should
// follow the ClusterServiceClassRef below.
//
// Immutable.
ExternalClusterServiceClassName string `json:"externalClusterServiceClassName,omitempty"`
// ExternalClusterServicePlanName is the human-readable name of the plan
ClusterServiceClassExternalName string `json:"clusterServiceClassExternalName,omitempty"`
// ClusterServicePlanExternalName is the human-readable name of the plan
// as reported by the broker. Note that if the broker changes the name
// of the ClusterServicePlan, it will not be reflected here, and to see
// the current name of the ClusterServicePlan, you should follow the
// ClusterServicePlanRef below.
ExternalClusterServicePlanName string `json:"externalClusterServicePlanName,omitempty"`
ClusterServicePlanExternalName string `json:"clusterServicePlanExternalName,omitempty"`

// ClusterServiceClassName is the kubernetes name of the
// ClusterServiceClass.
Expand All @@ -466,12 +466,12 @@ type ServiceInstanceSpec struct {
// ClusterServiceClassRef is a reference to the ClusterServiceClass
// that the user selected.
// This is set by the controller based on
// ExternalClusterServiceClassName
// ClusterServiceClassExternalName
ClusterServiceClassRef *ClusterObjectReference `json:"clusterServiceClassRef,omitempty"`
// ClusterServicePlanRef is a reference to the ClusterServicePlan
// that the user selected.
// This is set by the controller based on
// ExternalClusterServicePlanName
// ClusterServicePlanExternalName
ClusterServicePlanRef *ClusterObjectReference `json:"clusterServicePlanRef,omitempty"`

// Parameters is a set of the parameters to be passed to the underlying
Expand Down Expand Up @@ -614,10 +614,10 @@ const (
// ServiceInstancePropertiesState is the state of a ServiceInstance that
// the ClusterServiceBroker knows about.
type ServiceInstancePropertiesState struct {
// ExternalClusterServicePlanName is the name of the plan that the
// ClusterServicePlanExternalName is the name of the plan that the
// broker knows this ServiceInstance to be on. This is the human
// readable plan name from the OSB API.
ExternalClusterServicePlanName string `json:"externalClusterServicePlanName"`
ClusterServicePlanExternalName string `json:"clusterServicePlanExternalName"`

// Parameters is a blob of the parameters and their values that the broker
// knows about for this ServiceInstance. If a parameter was sourced from
Expand Down
12 changes: 6 additions & 6 deletions pkg/apis/servicecatalog/v1beta1/zz_generated.conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@ func Convert_servicecatalog_ParametersFromSource_To_v1beta1_ParametersFromSource
}

func autoConvert_v1beta1_PlanReference_To_servicecatalog_PlanReference(in *PlanReference, out *servicecatalog.PlanReference, s conversion.Scope) error {
out.ExternalClusterServiceClassName = in.ExternalClusterServiceClassName
out.ExternalClusterServicePlanName = in.ExternalClusterServicePlanName
out.ClusterServiceClassExternalName = in.ClusterServiceClassExternalName
out.ClusterServicePlanExternalName = in.ClusterServicePlanExternalName
out.ClusterServiceClassName = in.ClusterServiceClassName
out.ClusterServicePlanName = in.ClusterServicePlanName
return nil
Expand All @@ -583,8 +583,8 @@ func Convert_v1beta1_PlanReference_To_servicecatalog_PlanReference(in *PlanRefer
}

func autoConvert_servicecatalog_PlanReference_To_v1beta1_PlanReference(in *servicecatalog.PlanReference, out *PlanReference, s conversion.Scope) error {
out.ExternalClusterServiceClassName = in.ExternalClusterServiceClassName
out.ExternalClusterServicePlanName = in.ExternalClusterServicePlanName
out.ClusterServiceClassExternalName = in.ClusterServiceClassExternalName
out.ClusterServicePlanExternalName = in.ClusterServicePlanExternalName
out.ClusterServiceClassName = in.ClusterServiceClassName
out.ClusterServicePlanName = in.ClusterServicePlanName
return nil
Expand Down Expand Up @@ -924,7 +924,7 @@ func Convert_servicecatalog_ServiceInstanceList_To_v1beta1_ServiceInstanceList(i
}

func autoConvert_v1beta1_ServiceInstancePropertiesState_To_servicecatalog_ServiceInstancePropertiesState(in *ServiceInstancePropertiesState, out *servicecatalog.ServiceInstancePropertiesState, s conversion.Scope) error {
out.ExternalClusterServicePlanName = in.ExternalClusterServicePlanName
out.ClusterServicePlanExternalName = in.ClusterServicePlanExternalName
out.Parameters = (*runtime.RawExtension)(unsafe.Pointer(in.Parameters))
out.ParametersChecksum = in.ParametersChecksum
out.UserInfo = (*servicecatalog.UserInfo)(unsafe.Pointer(in.UserInfo))
Expand All @@ -937,7 +937,7 @@ func Convert_v1beta1_ServiceInstancePropertiesState_To_servicecatalog_ServiceIns
}

func autoConvert_servicecatalog_ServiceInstancePropertiesState_To_v1beta1_ServiceInstancePropertiesState(in *servicecatalog.ServiceInstancePropertiesState, out *ServiceInstancePropertiesState, s conversion.Scope) error {
out.ExternalClusterServicePlanName = in.ExternalClusterServicePlanName
out.ClusterServicePlanExternalName = in.ClusterServicePlanExternalName
out.Parameters = (*runtime.RawExtension)(unsafe.Pointer(in.Parameters))
out.ParametersChecksum = in.ParametersChecksum
out.UserInfo = (*UserInfo)(unsafe.Pointer(in.UserInfo))
Expand Down
32 changes: 16 additions & 16 deletions pkg/apis/servicecatalog/validation/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ func internalValidateServiceInstanceUpdateAllowed(new *sc.ServiceInstance, old *
if old.Generation != new.Generation && old.Status.ReconciledGeneration != old.Generation {
errors = append(errors, field.Forbidden(field.NewPath("spec"), "Another update for this service instance is in progress"))
}
if old.Spec.ExternalClusterServicePlanName != new.Spec.ExternalClusterServicePlanName && new.Spec.ClusterServicePlanRef != nil {
errors = append(errors, field.Forbidden(field.NewPath("spec").Child("clusterServicePlanRef"), "clusterServicePlanRef must not be present when externalServicePlanName is being changed"))
if old.Spec.ClusterServicePlanExternalName != new.Spec.ClusterServicePlanExternalName && new.Spec.ClusterServicePlanRef != nil {
errors = append(errors, field.Forbidden(field.NewPath("spec").Child("clusterServicePlanRef"), "clusterServicePlanRef must not be present when servicePlanExternalName is being changed"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: servicePlanExternalName should be clusterServicePlanExternalName

I'm fine doing this in a follow-up

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See: #1456

}
return errors
}
Expand All @@ -246,7 +246,7 @@ func ValidateServiceInstanceUpdate(new *sc.ServiceInstance, old *sc.ServiceInsta
allErrs = append(allErrs, internalValidateServiceInstanceUpdateAllowed(new, old)...)
allErrs = append(allErrs, internalValidateServiceInstance(new, false)...)

allErrs = append(allErrs, apivalidation.ValidateImmutableField(new.Spec.ExternalClusterServiceClassName, old.Spec.ExternalClusterServiceClassName, specFieldPath.Child("externalClusterServiceClassName"))...)
allErrs = append(allErrs, apivalidation.ValidateImmutableField(new.Spec.ClusterServiceClassExternalName, old.Spec.ClusterServiceClassExternalName, specFieldPath.Child("clusterServiceClassExternalName"))...)
allErrs = append(allErrs, apivalidation.ValidateImmutableField(new.Spec.ExternalID, old.Spec.ExternalID, specFieldPath.Child("externalID"))...)

if new.Spec.UpdateRequests < old.Spec.UpdateRequests {
Expand Down Expand Up @@ -305,34 +305,34 @@ func validatePlanReference(p *sc.PlanReference, fldPath *field.Path) field.Error
allErrs := field.ErrorList{}

// Just to make reading of the conditionals in the code easier.
externalClassSet := p.ExternalClusterServiceClassName != ""
externalPlanSet := p.ExternalClusterServicePlanName != ""
externalClassSet := p.ClusterServiceClassExternalName != ""
externalPlanSet := p.ClusterServicePlanExternalName != ""
k8sClassSet := p.ClusterServiceClassName != ""
k8sPlanSet := p.ClusterServicePlanName != ""

// Can't specify both External and k8s name but must specify one.
if externalClassSet == k8sClassSet {
allErrs = append(allErrs, field.Required(fldPath.Child("externalClusterServiceClassName"), "exactly one of externalClusterServiceClassName or clusterServiceClassName required"))
allErrs = append(allErrs, field.Required(fldPath.Child("clusterServiceClassName"), "exactly one of externalClusterServiceClassName or clusterServiceClassName required"))
allErrs = append(allErrs, field.Required(fldPath.Child("clusterServiceClassExternalName"), "exactly one of clusterServiceClassExternalName or clusterServiceClassName required"))
allErrs = append(allErrs, field.Required(fldPath.Child("clusterServiceClassName"), "exactly one of clusterServiceClassExternalName or clusterServiceClassName required"))
}
// Can't specify both External and k8s name but must specify one.
if externalPlanSet == k8sPlanSet {
allErrs = append(allErrs, field.Required(fldPath.Child("externalClusterServicePlanName"), "exactly one of externalClusterServicePlanName or clusterServicePlanName required"))
allErrs = append(allErrs, field.Required(fldPath.Child("clusterServicePlanName"), "exactly one of externalClusterServicePlanName or clusterServicePlanName required"))
allErrs = append(allErrs, field.Required(fldPath.Child("clusterServicePlanExternalName"), "exactly one of clusterServicePlanExternalName or clusterServicePlanName required"))
allErrs = append(allErrs, field.Required(fldPath.Child("clusterServicePlanName"), "exactly one of clusterServicePlanExternalName or clusterServicePlanName required"))
}

if externalClassSet {
for _, msg := range validateServiceClassName(p.ExternalClusterServiceClassName, false /* prefix */) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("externalClusterServiceClassName"), p.ExternalClusterServiceClassName, msg))
for _, msg := range validateServiceClassName(p.ClusterServiceClassExternalName, false /* prefix */) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("clusterServiceClassExternalName"), p.ClusterServiceClassExternalName, msg))
}

// If ExternalClusterServiceClassName given, must use ExternalClusterServicePlanName
// If ClusterServiceClassExternalName given, must use ClusterServicePlanExternalName
if !externalPlanSet {
allErrs = append(allErrs, field.Required(fldPath.Child("externalClusterServicePlanName"), "must specify externalClusterServicePlanName with externalClusterServiceClassName"))
allErrs = append(allErrs, field.Required(fldPath.Child("clusterServicePlanExternalName"), "must specify clusterServicePlanExternalName with clusterServiceClassExternalName"))
}

for _, msg := range validateServicePlanName(p.ExternalClusterServicePlanName, false /* prefix */) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("externalClusterServicePlanName"), p.ClusterServicePlanName, msg))
for _, msg := range validateServicePlanName(p.ClusterServicePlanExternalName, false /* prefix */) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("clusterServicePlanExternalName"), p.ClusterServicePlanName, msg))
}
}
if k8sClassSet {
Expand All @@ -355,7 +355,7 @@ func validatePlanReferenceUpdate(pOld *sc.PlanReference, pNew *sc.PlanReference,
allErrs := field.ErrorList{}
allErrs = append(allErrs, validatePlanReference(pOld, fldPath)...)
allErrs = append(allErrs, validatePlanReference(pNew, fldPath)...)
allErrs = append(allErrs, apivalidation.ValidateImmutableField(pNew.ExternalClusterServiceClassName, pOld.ExternalClusterServiceClassName, field.NewPath("spec").Child("externalClusterServiceClassName"))...)
allErrs = append(allErrs, apivalidation.ValidateImmutableField(pNew.ClusterServiceClassExternalName, pOld.ClusterServiceClassExternalName, field.NewPath("spec").Child("clusterServiceClassExternalName"))...)
allErrs = append(allErrs, apivalidation.ValidateImmutableField(pNew.ClusterServiceClassName, pOld.ClusterServiceClassName, field.NewPath("spec").Child("clusterServiceClassName"))...)
return allErrs
}
Loading