From 014c46809c1e330b704872826d5d2ab6b5b4bf9c Mon Sep 17 00:00:00 2001 From: Jeremy Rickard Date: Fri, 16 Mar 2018 06:01:53 -0700 Subject: [PATCH] Extracting common plan spec into embeddable struct (#1833) * Extracting common plan spec elements into embeddable struct As part of the Prosopal for Namespaced Resources (#1826), this extracts the common elements from the ClusterServicePlanSpec into a SharedServicePlanSpec that can be embedded in both the ClusterServicePlanSpec and a new namesapced plan * Cleaned up comments on shared fields to remove "Cluster" from description. * Cleaned up comments on shared fields to remove "Cluster" from description. * Refactored ClusterPlanStatus to match proposal * Revert "Refactored ClusterPlanStatus to match proposal" This reverts commit 6b36cf773c20178e47e5d0930a1f81b62b960440. --- pkg/apis/servicecatalog/types.go | 27 +++-- pkg/apis/servicecatalog/v1beta1/types.go | 27 +++-- .../v1beta1/zz_generated.conversion.go | 62 +++++++--- .../v1beta1/zz_generated.deepcopy.go | 107 ++++++++++-------- .../validation/serviceplan_test.go | 8 +- .../servicecatalog/zz_generated.deepcopy.go | 107 ++++++++++-------- pkg/controller/controller.go | 10 +- pkg/controller/controller_instance_test.go | 8 +- pkg/controller/controller_test.go | 68 +++++++---- pkg/openapi/openapi_generated.go | 87 ++++++++++++-- pkg/pretty/pretty_names_test.go | 4 +- .../defaultserviceplan/admission_test.go | 12 +- test/integration/clientset_test.go | 20 ++-- test/integration/controller_instance_test.go | 8 +- .../deleted_services_and_plans_test.go | 10 +- 15 files changed, 373 insertions(+), 192 deletions(-) diff --git a/pkg/apis/servicecatalog/types.go b/pkg/apis/servicecatalog/types.go index 55e8b46754a2..06dcb948e5ed 100644 --- a/pkg/apis/servicecatalog/types.go +++ b/pkg/apis/servicecatalog/types.go @@ -323,12 +323,8 @@ type ClusterServicePlan struct { Status ClusterServicePlanStatus } -// ClusterServicePlanSpec represents details about the ClusterServicePlan -type ClusterServicePlanSpec struct { - // ClusterServiceBrokerName is the name of the ClusterServiceBroker that offers this - // ClusterServicePlan. - ClusterServiceBrokerName string - +// SharedServicePlanSpec represents details about the ServicePlan +type SharedServicePlanSpec struct { // ExternalName is the name of this object that the Service Broker // exposed this Service Plan as. Mutable. ExternalName string @@ -338,15 +334,15 @@ type ClusterServicePlanSpec struct { // Immutable. ExternalID string - // Description is a short description of this ClusterServicePlan. + // Description is a short description of this ServicePlan. Description string // Bindable indicates whether a user can create bindings to an ServiceInstance - // using this ClusterServicePlan. If set, overrides the value of the - // ClusterServiceClass.Bindable field. + // using this ServicePlan. If set, overrides the value of the + // corresponding ServiceClassSpec Bindable field. Bindable *bool - // Free indicates whether this ClusterServicePlan is available at no cost. + // Free indicates whether this ServicePlan is available at no cost. Free bool // ExternalMetadata is a blob of information about the plan, meant to be @@ -366,7 +362,7 @@ type ClusterServicePlanSpec struct { // // ServiceInstanceUpdateParameterSchema is the schema for the parameters // that may be updated once an ServiceInstance has been provisioned on this plan. - // This field only has meaning if the ClusterServiceClass is PlanUpdatable. + // This field only has meaning if the corresponding ServiceClassSpec is PlanUpdatable. ServiceInstanceUpdateParameterSchema *runtime.RawExtension // Currently, this field is ALPHA: it may change or disappear at any time @@ -375,6 +371,15 @@ type ClusterServicePlanSpec struct { // ServiceBindingCreateParameterSchema is the schema for the parameters that // may be supplied binding to an ServiceInstance on this plan. ServiceBindingCreateParameterSchema *runtime.RawExtension +} + +// ClusterServicePlanSpec represents details about the ClusterServicePlan +type ClusterServicePlanSpec struct { + SharedServicePlanSpec + + // ClusterServiceBrokerName is the name of the ClusterServiceBroker that offers this + // ClusterServicePlan. + ClusterServiceBrokerName string // ClusterServiceClassRef is a reference to the service class that // owns this plan. diff --git a/pkg/apis/servicecatalog/v1beta1/types.go b/pkg/apis/servicecatalog/v1beta1/types.go index c8ecc0385899..0fd6d128a085 100644 --- a/pkg/apis/servicecatalog/v1beta1/types.go +++ b/pkg/apis/servicecatalog/v1beta1/types.go @@ -358,12 +358,9 @@ type ClusterServicePlan struct { Status ClusterServicePlanStatus `json:"status,omitempty"` } -// ClusterServicePlanSpec represents details about a ClusterServicePlan. -type ClusterServicePlanSpec struct { - // ClusterServiceBrokerName is the name of the ClusterServiceBroker - // that offers this ClusterServicePlan. - ClusterServiceBrokerName string `json:"clusterServiceBrokerName"` - +// SharedServicePlanSpec represents details that are shared by both +// a ClusterServicePlan and a namespaced ServicePlan +type SharedServicePlanSpec struct { // ExternalName is the name of this object that the Service Broker // exposed this Service Plan as. Mutable. ExternalName string `json:"externalName"` @@ -373,12 +370,12 @@ type ClusterServicePlanSpec struct { // Immutable. ExternalID string `json:"externalID"` - // Description is a short description of this ClusterServicePlan. + // Description is a short description of this ServicePlan. Description string `json:"description"` // Bindable indicates whether a user can create bindings to an - // ServiceInstance using this ClusterServicePlan. If set, overrides - // the value of the ClusterServiceClass.Bindable field. + // ServiceInstance using this ServicePlan. If set, overrides + // the value of the corresponding ServiceClassSpec Bindable field. Bindable *bool `json:"bindable,omitempty"` // Free indicates whether this plan is available at no cost. @@ -401,7 +398,7 @@ type ClusterServicePlanSpec struct { // // ServiceInstanceUpdateParameterSchema is the schema for the parameters // that may be updated once an ServiceInstance has been provisioned on - // this plan. This field only has meaning if the ClusterServiceClass is + // this plan. This field only has meaning if the corresponding ServiceClassSpec is // PlanUpdatable. ServiceInstanceUpdateParameterSchema *runtime.RawExtension `json:"instanceUpdateParameterSchema,omitempty"` @@ -411,6 +408,16 @@ type ClusterServicePlanSpec struct { // ServiceBindingCreateParameterSchema is the schema for the parameters that // may be supplied binding to an ServiceInstance on this plan. ServiceBindingCreateParameterSchema *runtime.RawExtension `json:"serviceBindingCreateParameterSchema,omitempty"` +} + +// ClusterServicePlanSpec represents details about a ClusterServicePlan. +type ClusterServicePlanSpec struct { + // SharedServicePlanSpec contains the common details of this ClusterServicePlan + SharedServicePlanSpec `json:",inline"` + + // ClusterServiceBrokerName is the name of the ClusterServiceBroker + // that offers this ClusterServicePlan. + ClusterServiceBrokerName string `json:"clusterServiceBrokerName"` // ClusterServiceClassRef is a reference to the service class that // owns this plan. diff --git a/pkg/apis/servicecatalog/v1beta1/zz_generated.conversion.go b/pkg/apis/servicecatalog/v1beta1/zz_generated.conversion.go index da0cc079f690..af9d2cba4035 100644 --- a/pkg/apis/servicecatalog/v1beta1/zz_generated.conversion.go +++ b/pkg/apis/servicecatalog/v1beta1/zz_generated.conversion.go @@ -104,6 +104,8 @@ func RegisterConversions(scheme *runtime.Scheme) error { Convert_servicecatalog_ServiceInstanceSpec_To_v1beta1_ServiceInstanceSpec, Convert_v1beta1_ServiceInstanceStatus_To_servicecatalog_ServiceInstanceStatus, Convert_servicecatalog_ServiceInstanceStatus_To_v1beta1_ServiceInstanceStatus, + Convert_v1beta1_SharedServicePlanSpec_To_servicecatalog_SharedServicePlanSpec, + Convert_servicecatalog_SharedServicePlanSpec_To_v1beta1_SharedServicePlanSpec, Convert_v1beta1_UserInfo_To_servicecatalog_UserInfo, Convert_servicecatalog_UserInfo_To_v1beta1_UserInfo, ) @@ -448,16 +450,10 @@ func Convert_servicecatalog_ClusterServicePlanList_To_v1beta1_ClusterServicePlan } func autoConvert_v1beta1_ClusterServicePlanSpec_To_servicecatalog_ClusterServicePlanSpec(in *ClusterServicePlanSpec, out *servicecatalog.ClusterServicePlanSpec, s conversion.Scope) error { + if err := Convert_v1beta1_SharedServicePlanSpec_To_servicecatalog_SharedServicePlanSpec(&in.SharedServicePlanSpec, &out.SharedServicePlanSpec, s); err != nil { + return err + } out.ClusterServiceBrokerName = in.ClusterServiceBrokerName - out.ExternalName = in.ExternalName - out.ExternalID = in.ExternalID - out.Description = in.Description - out.Bindable = (*bool)(unsafe.Pointer(in.Bindable)) - out.Free = in.Free - out.ExternalMetadata = (*runtime.RawExtension)(unsafe.Pointer(in.ExternalMetadata)) - out.ServiceInstanceCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceCreateParameterSchema)) - out.ServiceInstanceUpdateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceUpdateParameterSchema)) - out.ServiceBindingCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceBindingCreateParameterSchema)) if err := Convert_v1beta1_ClusterObjectReference_To_servicecatalog_ClusterObjectReference(&in.ClusterServiceClassRef, &out.ClusterServiceClassRef, s); err != nil { return err } @@ -470,16 +466,10 @@ func Convert_v1beta1_ClusterServicePlanSpec_To_servicecatalog_ClusterServicePlan } func autoConvert_servicecatalog_ClusterServicePlanSpec_To_v1beta1_ClusterServicePlanSpec(in *servicecatalog.ClusterServicePlanSpec, out *ClusterServicePlanSpec, s conversion.Scope) error { + if err := Convert_servicecatalog_SharedServicePlanSpec_To_v1beta1_SharedServicePlanSpec(&in.SharedServicePlanSpec, &out.SharedServicePlanSpec, s); err != nil { + return err + } out.ClusterServiceBrokerName = in.ClusterServiceBrokerName - out.ExternalName = in.ExternalName - out.ExternalID = in.ExternalID - out.Description = in.Description - out.Bindable = (*bool)(unsafe.Pointer(in.Bindable)) - out.Free = in.Free - out.ExternalMetadata = (*runtime.RawExtension)(unsafe.Pointer(in.ExternalMetadata)) - out.ServiceInstanceCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceCreateParameterSchema)) - out.ServiceInstanceUpdateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceUpdateParameterSchema)) - out.ServiceBindingCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceBindingCreateParameterSchema)) if err := Convert_servicecatalog_ClusterObjectReference_To_v1beta1_ClusterObjectReference(&in.ClusterServiceClassRef, &out.ClusterServiceClassRef, s); err != nil { return err } @@ -1041,6 +1031,42 @@ func Convert_servicecatalog_ServiceInstanceStatus_To_v1beta1_ServiceInstanceStat return autoConvert_servicecatalog_ServiceInstanceStatus_To_v1beta1_ServiceInstanceStatus(in, out, s) } +func autoConvert_v1beta1_SharedServicePlanSpec_To_servicecatalog_SharedServicePlanSpec(in *SharedServicePlanSpec, out *servicecatalog.SharedServicePlanSpec, s conversion.Scope) error { + out.ExternalName = in.ExternalName + out.ExternalID = in.ExternalID + out.Description = in.Description + out.Bindable = (*bool)(unsafe.Pointer(in.Bindable)) + out.Free = in.Free + out.ExternalMetadata = (*runtime.RawExtension)(unsafe.Pointer(in.ExternalMetadata)) + out.ServiceInstanceCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceCreateParameterSchema)) + out.ServiceInstanceUpdateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceUpdateParameterSchema)) + out.ServiceBindingCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceBindingCreateParameterSchema)) + return nil +} + +// Convert_v1beta1_SharedServicePlanSpec_To_servicecatalog_SharedServicePlanSpec is an autogenerated conversion function. +func Convert_v1beta1_SharedServicePlanSpec_To_servicecatalog_SharedServicePlanSpec(in *SharedServicePlanSpec, out *servicecatalog.SharedServicePlanSpec, s conversion.Scope) error { + return autoConvert_v1beta1_SharedServicePlanSpec_To_servicecatalog_SharedServicePlanSpec(in, out, s) +} + +func autoConvert_servicecatalog_SharedServicePlanSpec_To_v1beta1_SharedServicePlanSpec(in *servicecatalog.SharedServicePlanSpec, out *SharedServicePlanSpec, s conversion.Scope) error { + out.ExternalName = in.ExternalName + out.ExternalID = in.ExternalID + out.Description = in.Description + out.Bindable = (*bool)(unsafe.Pointer(in.Bindable)) + out.Free = in.Free + out.ExternalMetadata = (*runtime.RawExtension)(unsafe.Pointer(in.ExternalMetadata)) + out.ServiceInstanceCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceCreateParameterSchema)) + out.ServiceInstanceUpdateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceUpdateParameterSchema)) + out.ServiceBindingCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceBindingCreateParameterSchema)) + return nil +} + +// Convert_servicecatalog_SharedServicePlanSpec_To_v1beta1_SharedServicePlanSpec is an autogenerated conversion function. +func Convert_servicecatalog_SharedServicePlanSpec_To_v1beta1_SharedServicePlanSpec(in *servicecatalog.SharedServicePlanSpec, out *SharedServicePlanSpec, s conversion.Scope) error { + return autoConvert_servicecatalog_SharedServicePlanSpec_To_v1beta1_SharedServicePlanSpec(in, out, s) +} + func autoConvert_v1beta1_UserInfo_To_servicecatalog_UserInfo(in *UserInfo, out *servicecatalog.UserInfo, s conversion.Scope) error { out.Username = in.Username out.UID = in.UID diff --git a/pkg/apis/servicecatalog/v1beta1/zz_generated.deepcopy.go b/pkg/apis/servicecatalog/v1beta1/zz_generated.deepcopy.go index f1568ddf2b89..fec8916c5caa 100644 --- a/pkg/apis/servicecatalog/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/servicecatalog/v1beta1/zz_generated.deepcopy.go @@ -414,51 +414,7 @@ func (in *ClusterServicePlanList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterServicePlanSpec) DeepCopyInto(out *ClusterServicePlanSpec) { *out = *in - if in.Bindable != nil { - in, out := &in.Bindable, &out.Bindable - if *in == nil { - *out = nil - } else { - *out = new(bool) - **out = **in - } - } - if in.ExternalMetadata != nil { - in, out := &in.ExternalMetadata, &out.ExternalMetadata - if *in == nil { - *out = nil - } else { - *out = new(runtime.RawExtension) - (*in).DeepCopyInto(*out) - } - } - if in.ServiceInstanceCreateParameterSchema != nil { - in, out := &in.ServiceInstanceCreateParameterSchema, &out.ServiceInstanceCreateParameterSchema - if *in == nil { - *out = nil - } else { - *out = new(runtime.RawExtension) - (*in).DeepCopyInto(*out) - } - } - if in.ServiceInstanceUpdateParameterSchema != nil { - in, out := &in.ServiceInstanceUpdateParameterSchema, &out.ServiceInstanceUpdateParameterSchema - if *in == nil { - *out = nil - } else { - *out = new(runtime.RawExtension) - (*in).DeepCopyInto(*out) - } - } - if in.ServiceBindingCreateParameterSchema != nil { - in, out := &in.ServiceBindingCreateParameterSchema, &out.ServiceBindingCreateParameterSchema - if *in == nil { - *out = nil - } else { - *out = new(runtime.RawExtension) - (*in).DeepCopyInto(*out) - } - } + in.SharedServicePlanSpec.DeepCopyInto(&out.SharedServicePlanSpec) out.ClusterServiceClassRef = in.ClusterServiceClassRef return } @@ -1086,6 +1042,67 @@ func (in *ServiceInstanceStatus) DeepCopy() *ServiceInstanceStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SharedServicePlanSpec) DeepCopyInto(out *SharedServicePlanSpec) { + *out = *in + if in.Bindable != nil { + in, out := &in.Bindable, &out.Bindable + if *in == nil { + *out = nil + } else { + *out = new(bool) + **out = **in + } + } + if in.ExternalMetadata != nil { + in, out := &in.ExternalMetadata, &out.ExternalMetadata + if *in == nil { + *out = nil + } else { + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + } + if in.ServiceInstanceCreateParameterSchema != nil { + in, out := &in.ServiceInstanceCreateParameterSchema, &out.ServiceInstanceCreateParameterSchema + if *in == nil { + *out = nil + } else { + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + } + if in.ServiceInstanceUpdateParameterSchema != nil { + in, out := &in.ServiceInstanceUpdateParameterSchema, &out.ServiceInstanceUpdateParameterSchema + if *in == nil { + *out = nil + } else { + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + } + if in.ServiceBindingCreateParameterSchema != nil { + in, out := &in.ServiceBindingCreateParameterSchema, &out.ServiceBindingCreateParameterSchema + if *in == nil { + *out = nil + } else { + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SharedServicePlanSpec. +func (in *SharedServicePlanSpec) DeepCopy() *SharedServicePlanSpec { + if in == nil { + return nil + } + out := new(SharedServicePlanSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *UserInfo) DeepCopyInto(out *UserInfo) { *out = *in diff --git a/pkg/apis/servicecatalog/validation/serviceplan_test.go b/pkg/apis/servicecatalog/validation/serviceplan_test.go index d391c23b1e85..5cdd89f8186a 100644 --- a/pkg/apis/servicecatalog/validation/serviceplan_test.go +++ b/pkg/apis/servicecatalog/validation/serviceplan_test.go @@ -30,10 +30,12 @@ func validClusterServicePlan() *servicecatalog.ClusterServicePlan { Name: "test-plan", }, Spec: servicecatalog.ClusterServicePlanSpec{ + SharedServicePlanSpec: servicecatalog.SharedServicePlanSpec{ + ExternalName: "test-plan", + ExternalID: "40d-0983-1b89", + Description: "plan description", + }, ClusterServiceBrokerName: "test-broker", - ExternalName: "test-plan", - ExternalID: "40d-0983-1b89", - Description: "plan description", ClusterServiceClassRef: servicecatalog.ClusterObjectReference{ Name: "test-service-class", }, diff --git a/pkg/apis/servicecatalog/zz_generated.deepcopy.go b/pkg/apis/servicecatalog/zz_generated.deepcopy.go index 2f664996d054..836cffb42748 100644 --- a/pkg/apis/servicecatalog/zz_generated.deepcopy.go +++ b/pkg/apis/servicecatalog/zz_generated.deepcopy.go @@ -414,51 +414,7 @@ func (in *ClusterServicePlanList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterServicePlanSpec) DeepCopyInto(out *ClusterServicePlanSpec) { *out = *in - if in.Bindable != nil { - in, out := &in.Bindable, &out.Bindable - if *in == nil { - *out = nil - } else { - *out = new(bool) - **out = **in - } - } - if in.ExternalMetadata != nil { - in, out := &in.ExternalMetadata, &out.ExternalMetadata - if *in == nil { - *out = nil - } else { - *out = new(runtime.RawExtension) - (*in).DeepCopyInto(*out) - } - } - if in.ServiceInstanceCreateParameterSchema != nil { - in, out := &in.ServiceInstanceCreateParameterSchema, &out.ServiceInstanceCreateParameterSchema - if *in == nil { - *out = nil - } else { - *out = new(runtime.RawExtension) - (*in).DeepCopyInto(*out) - } - } - if in.ServiceInstanceUpdateParameterSchema != nil { - in, out := &in.ServiceInstanceUpdateParameterSchema, &out.ServiceInstanceUpdateParameterSchema - if *in == nil { - *out = nil - } else { - *out = new(runtime.RawExtension) - (*in).DeepCopyInto(*out) - } - } - if in.ServiceBindingCreateParameterSchema != nil { - in, out := &in.ServiceBindingCreateParameterSchema, &out.ServiceBindingCreateParameterSchema - if *in == nil { - *out = nil - } else { - *out = new(runtime.RawExtension) - (*in).DeepCopyInto(*out) - } - } + in.SharedServicePlanSpec.DeepCopyInto(&out.SharedServicePlanSpec) out.ClusterServiceClassRef = in.ClusterServiceClassRef return } @@ -1086,6 +1042,67 @@ func (in *ServiceInstanceStatus) DeepCopy() *ServiceInstanceStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SharedServicePlanSpec) DeepCopyInto(out *SharedServicePlanSpec) { + *out = *in + if in.Bindable != nil { + in, out := &in.Bindable, &out.Bindable + if *in == nil { + *out = nil + } else { + *out = new(bool) + **out = **in + } + } + if in.ExternalMetadata != nil { + in, out := &in.ExternalMetadata, &out.ExternalMetadata + if *in == nil { + *out = nil + } else { + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + } + if in.ServiceInstanceCreateParameterSchema != nil { + in, out := &in.ServiceInstanceCreateParameterSchema, &out.ServiceInstanceCreateParameterSchema + if *in == nil { + *out = nil + } else { + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + } + if in.ServiceInstanceUpdateParameterSchema != nil { + in, out := &in.ServiceInstanceUpdateParameterSchema, &out.ServiceInstanceUpdateParameterSchema + if *in == nil { + *out = nil + } else { + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + } + if in.ServiceBindingCreateParameterSchema != nil { + in, out := &in.ServiceBindingCreateParameterSchema, &out.ServiceBindingCreateParameterSchema + if *in == nil { + *out = nil + } else { + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SharedServicePlanSpec. +func (in *SharedServicePlanSpec) DeepCopy() *SharedServicePlanSpec { + if in == nil { + return nil + } + out := new(SharedServicePlanSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *UserInfo) DeepCopyInto(out *UserInfo) { *out = *in diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index c41de3d3c394..dc19b250217c 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -539,10 +539,12 @@ func convertClusterServicePlans(plans []osb.Plan, serviceClassID string) ([]*v1b for i, plan := range plans { servicePlans[i] = &v1beta1.ClusterServicePlan{ Spec: v1beta1.ClusterServicePlanSpec{ - ExternalName: plan.Name, - ExternalID: plan.ID, - Free: plan.Free != nil && *plan.Free, - Description: plan.Description, + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + ExternalName: plan.Name, + ExternalID: plan.ID, + Free: plan.Free != nil && *plan.Free, + Description: plan.Description, + }, ClusterServiceClassRef: v1beta1.ClusterObjectReference{Name: serviceClassID}, }, } diff --git a/pkg/controller/controller_instance_test.go b/pkg/controller/controller_instance_test.go index 293566d1ad6f..e284f8d13163 100644 --- a/pkg/controller/controller_instance_test.go +++ b/pkg/controller/controller_instance_test.go @@ -4760,9 +4760,11 @@ func TestResolveReferencesForPlanChange(t *testing.T) { sp := &v1beta1.ClusterServicePlan{ ObjectMeta: metav1.ObjectMeta{Name: newPlanID}, Spec: v1beta1.ClusterServicePlanSpec{ - ExternalID: newPlanID, - ExternalName: newPlanName, - Bindable: truePtr(), + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + ExternalID: newPlanID, + ExternalName: newPlanName, + Bindable: truePtr(), + }, }, } var spItems []v1beta1.ClusterServicePlan diff --git a/pkg/controller/controller_test.go b/pkg/controller/controller_test.go index f6ab16f8d9c5..e2832c374843 100644 --- a/pkg/controller/controller_test.go +++ b/pkg/controller/controller_test.go @@ -460,9 +460,11 @@ func getTestClusterServicePlan() *v1beta1.ClusterServicePlan { ObjectMeta: metav1.ObjectMeta{Name: testClusterServicePlanGUID}, Spec: v1beta1.ClusterServicePlanSpec{ ClusterServiceBrokerName: testClusterServiceBrokerName, - ExternalID: testClusterServicePlanGUID, - ExternalName: testClusterServicePlanName, - Bindable: truePtr(), + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + ExternalID: testClusterServicePlanGUID, + ExternalName: testClusterServicePlanName, + Bindable: truePtr(), + }, ClusterServiceClassRef: v1beta1.ClusterObjectReference{ Name: testClusterServiceClassGUID, }, @@ -476,9 +478,11 @@ func getTestMarkedAsRemovedClusterServicePlan() *v1beta1.ClusterServicePlan { ObjectMeta: metav1.ObjectMeta{Name: testRemovedClusterServicePlanGUID}, Spec: v1beta1.ClusterServicePlanSpec{ ClusterServiceBrokerName: testClusterServiceBrokerName, - ExternalID: testRemovedClusterServicePlanGUID, - ExternalName: testRemovedClusterServicePlanName, - Bindable: truePtr(), + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + ExternalID: testRemovedClusterServicePlanGUID, + ExternalName: testRemovedClusterServicePlanName, + Bindable: truePtr(), + }, ClusterServiceClassRef: v1beta1.ClusterObjectReference{ Name: testClusterServiceClassGUID, }, @@ -492,9 +496,11 @@ func getTestRemovedClusterServicePlan() *v1beta1.ClusterServicePlan { ObjectMeta: metav1.ObjectMeta{Name: testRemovedClusterServicePlanGUID}, Spec: v1beta1.ClusterServicePlanSpec{ ClusterServiceBrokerName: testClusterServiceBrokerName, - ExternalID: testRemovedClusterServicePlanGUID, - ExternalName: testRemovedClusterServicePlanName, - Bindable: truePtr(), + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + ExternalID: testRemovedClusterServicePlanGUID, + ExternalName: testRemovedClusterServicePlanName, + Bindable: truePtr(), + }, ClusterServiceClassRef: v1beta1.ClusterObjectReference{ Name: testClusterServiceClassGUID, }, @@ -506,9 +512,11 @@ func getTestClusterServicePlanNonbindable() *v1beta1.ClusterServicePlan { return &v1beta1.ClusterServicePlan{ ObjectMeta: metav1.ObjectMeta{Name: testNonbindableClusterServicePlanGUID}, Spec: v1beta1.ClusterServicePlanSpec{ - ExternalName: testNonbindableClusterServicePlanName, - ExternalID: testNonbindableClusterServicePlanGUID, - Bindable: falsePtr(), + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + ExternalName: testNonbindableClusterServicePlanName, + ExternalID: testNonbindableClusterServicePlanGUID, + Bindable: falsePtr(), + }, ClusterServiceClassRef: v1beta1.ClusterObjectReference{ Name: testClusterServiceClassGUID, }, @@ -1321,9 +1329,11 @@ func TestCatalogConversionClusterServicePlanBindable(t *testing.T) { Name: "s1_plan1_id", }, Spec: v1beta1.ClusterServicePlanSpec{ - ExternalID: "s1_plan1_id", - ExternalName: "bindable-bindable", - Bindable: nil, + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + ExternalID: "s1_plan1_id", + ExternalName: "bindable-bindable", + Bindable: nil, + }, ClusterServiceClassRef: v1beta1.ClusterObjectReference{ Name: "bindable-id", }, @@ -1334,9 +1344,11 @@ func TestCatalogConversionClusterServicePlanBindable(t *testing.T) { Name: "s1_plan2_id", }, Spec: v1beta1.ClusterServicePlanSpec{ - ExternalName: "bindable-unbindable", - ExternalID: "s1_plan2_id", - Bindable: falsePtr(), + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + ExternalName: "bindable-unbindable", + ExternalID: "s1_plan2_id", + Bindable: falsePtr(), + }, ClusterServiceClassRef: v1beta1.ClusterObjectReference{ Name: "bindable-id", }, @@ -1347,9 +1359,11 @@ func TestCatalogConversionClusterServicePlanBindable(t *testing.T) { Name: "s2_plan1_id", }, Spec: v1beta1.ClusterServicePlanSpec{ - ExternalName: "unbindable-unbindable", - ExternalID: "s2_plan1_id", - Bindable: nil, + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + ExternalName: "unbindable-unbindable", + ExternalID: "s2_plan1_id", + Bindable: nil, + }, ClusterServiceClassRef: v1beta1.ClusterObjectReference{ Name: "unbindable-id", }, @@ -1360,9 +1374,11 @@ func TestCatalogConversionClusterServicePlanBindable(t *testing.T) { Name: "s2_plan2_id", }, Spec: v1beta1.ClusterServicePlanSpec{ - ExternalName: "unbindable-bindable", - ExternalID: "s2_plan2_id", - Bindable: truePtr(), + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + ExternalName: "unbindable-bindable", + ExternalID: "s2_plan2_id", + Bindable: truePtr(), + }, ClusterServiceClassRef: v1beta1.ClusterObjectReference{ Name: "unbindable-id", }, @@ -1419,7 +1435,9 @@ func TestIsPlanBindable(t *testing.T) { servicePlan := func(bindable *bool) *v1beta1.ClusterServicePlan { return &v1beta1.ClusterServicePlan{ Spec: v1beta1.ClusterServicePlanSpec{ - Bindable: bindable, + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + Bindable: bindable, + }, }, } } diff --git a/pkg/openapi/openapi_generated.go b/pkg/openapi/openapi_generated.go index 821a6d03d117..76ee53240ff2 100644 --- a/pkg/openapi/openapi_generated.go +++ b/pkg/openapi/openapi_generated.go @@ -573,13 +573,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA SchemaProps: spec.SchemaProps{ Description: "ClusterServicePlanSpec represents details about a ClusterServicePlan.", Properties: map[string]spec.Schema{ - "clusterServiceBrokerName": { - SchemaProps: spec.SchemaProps{ - Description: "ClusterServiceBrokerName is the name of the ClusterServiceBroker that offers this ClusterServicePlan.", - Type: []string{"string"}, - Format: "", - }, - }, "externalName": { SchemaProps: spec.SchemaProps{ Description: "ExternalName is the name of this object that the Service Broker exposed this Service Plan as. Mutable.", @@ -639,6 +632,13 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), }, }, + "clusterServiceBrokerName": { + SchemaProps: spec.SchemaProps{ + Description: "ClusterServiceBrokerName is the name of the ClusterServiceBroker that offers this ClusterServicePlan.", + Type: []string{"string"}, + Format: "", + }, + }, "clusterServiceClassRef": { SchemaProps: spec.SchemaProps{ Description: "ClusterServiceClassRef is a reference to the service class that owns this plan.", @@ -646,7 +646,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA }, }, }, - Required: []string{"clusterServiceBrokerName", "externalName", "externalID", "description", "free", "clusterServiceClassRef"}, + Required: []string{"externalName", "externalID", "description", "free", "clusterServiceBrokerName", "clusterServiceClassRef"}, }, }, Dependencies: []string{ @@ -1546,6 +1546,77 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA Dependencies: []string{ "github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ServiceInstanceCondition", "github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ServiceInstancePropertiesState", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, }, + "github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.SharedServicePlanSpec": { + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SharedServicePlanSpec represents details that are shared by both a ClusterServicePlan and a namespaced ServicePlan", + Properties: map[string]spec.Schema{ + "externalName": { + SchemaProps: spec.SchemaProps{ + Description: "ExternalName is the name of this object that the Service Broker exposed this Service Plan as. Mutable.", + Type: []string{"string"}, + Format: "", + }, + }, + "externalID": { + SchemaProps: spec.SchemaProps{ + Description: "ExternalID is the identity of this object for use with the OSB API.\n\nImmutable.", + Type: []string{"string"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Description: "Description is a short description of this ClusterServicePlan.", + Type: []string{"string"}, + Format: "", + }, + }, + "bindable": { + SchemaProps: spec.SchemaProps{ + Description: "Bindable indicates whether a user can create bindings to an ServiceInstance using this ClusterServicePlan. If set, overrides the value of the ClusterServiceClass.Bindable field.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "free": { + SchemaProps: spec.SchemaProps{ + Description: "Free indicates whether this plan is available at no cost.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "externalMetadata": { + SchemaProps: spec.SchemaProps{ + Description: "ExternalMetadata is a blob of information about the plan, meant to be user-facing content and display instructions. This field may contain platform-specific conventional values.", + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + "instanceCreateParameterSchema": { + SchemaProps: spec.SchemaProps{ + Description: "Currently, this field is ALPHA: it may change or disappear at any time and its data will not be migrated.\n\nServiceInstanceCreateParameterSchema is the schema for the parameters that may be supplied when provisioning a new ServiceInstance on this plan.", + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + "instanceUpdateParameterSchema": { + SchemaProps: spec.SchemaProps{ + Description: "Currently, this field is ALPHA: it may change or disappear at any time and its data will not be migrated.\n\nServiceInstanceUpdateParameterSchema is the schema for the parameters that may be updated once an ServiceInstance has been provisioned on this plan. This field only has meaning if the ClusterServiceClass is PlanUpdatable.", + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + "serviceBindingCreateParameterSchema": { + SchemaProps: spec.SchemaProps{ + Description: "Currently, this field is ALPHA: it may change or disappear at any time and its data will not be migrated.\n\nServiceBindingCreateParameterSchema is the schema for the parameters that may be supplied binding to an ServiceInstance on this plan.", + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + }, + Required: []string{"externalName", "externalID", "description", "free"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/runtime.RawExtension"}, + }, "github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.UserInfo": { Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ diff --git a/pkg/pretty/pretty_names_test.go b/pkg/pretty/pretty_names_test.go index d561d9fa11d9..a95f374c3349 100644 --- a/pkg/pretty/pretty_names_test.go +++ b/pkg/pretty/pretty_names_test.go @@ -68,7 +68,9 @@ func TestClusterServicePlanName(t *testing.T) { servicePlan := &v1beta1.ClusterServicePlan{ ObjectMeta: metav1.ObjectMeta{Name: "service-plan"}, Spec: v1beta1.ClusterServicePlanSpec{ - ExternalName: "external-plan-name", + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + ExternalName: "external-plan-name", + }, }, } diff --git a/plugin/pkg/admission/serviceplan/defaultserviceplan/admission_test.go b/plugin/pkg/admission/serviceplan/defaultserviceplan/admission_test.go index 6191af353a2f..79e18c43d750 100644 --- a/plugin/pkg/admission/serviceplan/defaultserviceplan/admission_test.go +++ b/plugin/pkg/admission/serviceplan/defaultserviceplan/admission_test.go @@ -126,8 +126,10 @@ func newClusterServicePlans(count uint, useDifferentClasses bool) []*servicecata sp1 := &servicecatalog.ClusterServicePlan{ ObjectMeta: metav1.ObjectMeta{Name: "bar-id"}, Spec: servicecatalog.ClusterServicePlanSpec{ - ExternalName: "bar", - ExternalID: "12345", + SharedServicePlanSpec: servicecatalog.SharedServicePlanSpec{ + ExternalName: "bar", + ExternalID: "12345", + }, ClusterServiceClassRef: servicecatalog.ClusterObjectReference{ Name: classname, }, @@ -139,8 +141,10 @@ func newClusterServicePlans(count uint, useDifferentClasses bool) []*servicecata sp2 := &servicecatalog.ClusterServicePlan{ ObjectMeta: metav1.ObjectMeta{Name: "baz-id"}, Spec: servicecatalog.ClusterServicePlanSpec{ - ExternalName: "baz", - ExternalID: "23456", + SharedServicePlanSpec: servicecatalog.SharedServicePlanSpec{ + ExternalName: "baz", + ExternalID: "23456", + }, ClusterServiceClassRef: servicecatalog.ClusterObjectReference{ Name: classname, }, diff --git a/test/integration/clientset_test.go b/test/integration/clientset_test.go index 347ec39562e9..84c5f90420a3 100644 --- a/test/integration/clientset_test.go +++ b/test/integration/clientset_test.go @@ -614,10 +614,12 @@ func testClusterServicePlanClient(sType server.StorageType, client servicecatalo ObjectMeta: metav1.ObjectMeta{Name: name}, Spec: v1beta1.ClusterServicePlanSpec{ ClusterServiceBrokerName: "test-broker", - Bindable: &bindable, - ExternalName: name, - ExternalID: "b8269ab4-7d2d-456d-8c8b-5aab63b321d1", - Description: "test description", + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + Bindable: &bindable, + ExternalName: name, + ExternalID: "b8269ab4-7d2d-456d-8c8b-5aab63b321d1", + Description: "test description", + }, ClusterServiceClassRef: v1beta1.ClusterObjectReference{ Name: "test-serviceclass", }, @@ -712,10 +714,12 @@ func testClusterServicePlanClient(sType server.StorageType, client servicecatalo ObjectMeta: metav1.ObjectMeta{Name: sp2Name}, Spec: v1beta1.ClusterServicePlanSpec{ ClusterServiceBrokerName: "test-broker", - Bindable: &bindable, - ExternalName: sp2Name, - ExternalID: sp2ID, - Description: "test description 2", + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + Bindable: &bindable, + ExternalName: sp2Name, + ExternalID: sp2ID, + Description: "test description 2", + }, ClusterServiceClassRef: v1beta1.ClusterObjectReference{ Name: "test-serviceclass", }, diff --git a/test/integration/controller_instance_test.go b/test/integration/controller_instance_test.go index b565b5db7d3d..0d046043c2a0 100644 --- a/test/integration/controller_instance_test.go +++ b/test/integration/controller_instance_test.go @@ -163,9 +163,11 @@ func TestCreateServiceInstanceNonExistentClusterServiceBroker(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: testPlanExternalID}, Spec: v1beta1.ClusterServicePlanSpec{ ClusterServiceBrokerName: testClusterServiceBrokerName, - ExternalID: testPlanExternalID, - ExternalName: testClusterServicePlanName, - Description: "a test plan", + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + ExternalID: testPlanExternalID, + ExternalName: testClusterServicePlanName, + Description: "a test plan", + }, ClusterServiceClassRef: v1beta1.ClusterObjectReference{ Name: testClusterServiceClassGUID, }, diff --git a/test/integration/deleted_services_and_plans_test.go b/test/integration/deleted_services_and_plans_test.go index 68b29250b4b9..8a660a039186 100644 --- a/test/integration/deleted_services_and_plans_test.go +++ b/test/integration/deleted_services_and_plans_test.go @@ -72,10 +72,12 @@ func getTestClusterServicePlanRemoved() *v1beta1.ClusterServicePlan { ObjectMeta: metav1.ObjectMeta{Name: testRemovedClusterServicePlanGUID}, Spec: v1beta1.ClusterServicePlanSpec{ ClusterServiceBrokerName: testClusterServiceBrokerName, - ExternalID: testRemovedClusterServicePlanGUID, - ExternalName: testRemovedClusterServicePlanExternalName, - Description: "a plan that will be removed", - Bindable: truePtr(), + SharedServicePlanSpec: v1beta1.SharedServicePlanSpec{ + ExternalID: testRemovedClusterServicePlanGUID, + ExternalName: testRemovedClusterServicePlanExternalName, + Description: "a plan that will be removed", + Bindable: truePtr(), + }, ClusterServiceClassRef: v1beta1.ClusterObjectReference{ Name: testClusterServiceClassGUID, },