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

Commit 014c468

Browse files
jeremyrickardJay Boyd
authored andcommitted
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 6b36cf7.
1 parent 5d7041b commit 014c468

File tree

15 files changed

+373
-192
lines changed

15 files changed

+373
-192
lines changed

pkg/apis/servicecatalog/types.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,8 @@ type ClusterServicePlan struct {
323323
Status ClusterServicePlanStatus
324324
}
325325

326-
// ClusterServicePlanSpec represents details about the ClusterServicePlan
327-
type ClusterServicePlanSpec struct {
328-
// ClusterServiceBrokerName is the name of the ClusterServiceBroker that offers this
329-
// ClusterServicePlan.
330-
ClusterServiceBrokerName string
331-
326+
// SharedServicePlanSpec represents details about the ServicePlan
327+
type SharedServicePlanSpec struct {
332328
// ExternalName is the name of this object that the Service Broker
333329
// exposed this Service Plan as. Mutable.
334330
ExternalName string
@@ -338,15 +334,15 @@ type ClusterServicePlanSpec struct {
338334
// Immutable.
339335
ExternalID string
340336

341-
// Description is a short description of this ClusterServicePlan.
337+
// Description is a short description of this ServicePlan.
342338
Description string
343339

344340
// Bindable indicates whether a user can create bindings to an ServiceInstance
345-
// using this ClusterServicePlan. If set, overrides the value of the
346-
// ClusterServiceClass.Bindable field.
341+
// using this ServicePlan. If set, overrides the value of the
342+
// corresponding ServiceClassSpec Bindable field.
347343
Bindable *bool
348344

349-
// Free indicates whether this ClusterServicePlan is available at no cost.
345+
// Free indicates whether this ServicePlan is available at no cost.
350346
Free bool
351347

352348
// ExternalMetadata is a blob of information about the plan, meant to be
@@ -366,7 +362,7 @@ type ClusterServicePlanSpec struct {
366362
//
367363
// ServiceInstanceUpdateParameterSchema is the schema for the parameters
368364
// that may be updated once an ServiceInstance has been provisioned on this plan.
369-
// This field only has meaning if the ClusterServiceClass is PlanUpdatable.
365+
// This field only has meaning if the corresponding ServiceClassSpec is PlanUpdatable.
370366
ServiceInstanceUpdateParameterSchema *runtime.RawExtension
371367

372368
// Currently, this field is ALPHA: it may change or disappear at any time
@@ -375,6 +371,15 @@ type ClusterServicePlanSpec struct {
375371
// ServiceBindingCreateParameterSchema is the schema for the parameters that
376372
// may be supplied binding to an ServiceInstance on this plan.
377373
ServiceBindingCreateParameterSchema *runtime.RawExtension
374+
}
375+
376+
// ClusterServicePlanSpec represents details about the ClusterServicePlan
377+
type ClusterServicePlanSpec struct {
378+
SharedServicePlanSpec
379+
380+
// ClusterServiceBrokerName is the name of the ClusterServiceBroker that offers this
381+
// ClusterServicePlan.
382+
ClusterServiceBrokerName string
378383

379384
// ClusterServiceClassRef is a reference to the service class that
380385
// owns this plan.

pkg/apis/servicecatalog/v1beta1/types.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,9 @@ type ClusterServicePlan struct {
358358
Status ClusterServicePlanStatus `json:"status,omitempty"`
359359
}
360360

361-
// ClusterServicePlanSpec represents details about a ClusterServicePlan.
362-
type ClusterServicePlanSpec struct {
363-
// ClusterServiceBrokerName is the name of the ClusterServiceBroker
364-
// that offers this ClusterServicePlan.
365-
ClusterServiceBrokerName string `json:"clusterServiceBrokerName"`
366-
361+
// SharedServicePlanSpec represents details that are shared by both
362+
// a ClusterServicePlan and a namespaced ServicePlan
363+
type SharedServicePlanSpec struct {
367364
// ExternalName is the name of this object that the Service Broker
368365
// exposed this Service Plan as. Mutable.
369366
ExternalName string `json:"externalName"`
@@ -373,12 +370,12 @@ type ClusterServicePlanSpec struct {
373370
// Immutable.
374371
ExternalID string `json:"externalID"`
375372

376-
// Description is a short description of this ClusterServicePlan.
373+
// Description is a short description of this ServicePlan.
377374
Description string `json:"description"`
378375

379376
// Bindable indicates whether a user can create bindings to an
380-
// ServiceInstance using this ClusterServicePlan. If set, overrides
381-
// the value of the ClusterServiceClass.Bindable field.
377+
// ServiceInstance using this ServicePlan. If set, overrides
378+
// the value of the corresponding ServiceClassSpec Bindable field.
382379
Bindable *bool `json:"bindable,omitempty"`
383380

384381
// Free indicates whether this plan is available at no cost.
@@ -401,7 +398,7 @@ type ClusterServicePlanSpec struct {
401398
//
402399
// ServiceInstanceUpdateParameterSchema is the schema for the parameters
403400
// that may be updated once an ServiceInstance has been provisioned on
404-
// this plan. This field only has meaning if the ClusterServiceClass is
401+
// this plan. This field only has meaning if the corresponding ServiceClassSpec is
405402
// PlanUpdatable.
406403
ServiceInstanceUpdateParameterSchema *runtime.RawExtension `json:"instanceUpdateParameterSchema,omitempty"`
407404

@@ -411,6 +408,16 @@ type ClusterServicePlanSpec struct {
411408
// ServiceBindingCreateParameterSchema is the schema for the parameters that
412409
// may be supplied binding to an ServiceInstance on this plan.
413410
ServiceBindingCreateParameterSchema *runtime.RawExtension `json:"serviceBindingCreateParameterSchema,omitempty"`
411+
}
412+
413+
// ClusterServicePlanSpec represents details about a ClusterServicePlan.
414+
type ClusterServicePlanSpec struct {
415+
// SharedServicePlanSpec contains the common details of this ClusterServicePlan
416+
SharedServicePlanSpec `json:",inline"`
417+
418+
// ClusterServiceBrokerName is the name of the ClusterServiceBroker
419+
// that offers this ClusterServicePlan.
420+
ClusterServiceBrokerName string `json:"clusterServiceBrokerName"`
414421

415422
// ClusterServiceClassRef is a reference to the service class that
416423
// owns this plan.

pkg/apis/servicecatalog/v1beta1/zz_generated.conversion.go

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ func RegisterConversions(scheme *runtime.Scheme) error {
104104
Convert_servicecatalog_ServiceInstanceSpec_To_v1beta1_ServiceInstanceSpec,
105105
Convert_v1beta1_ServiceInstanceStatus_To_servicecatalog_ServiceInstanceStatus,
106106
Convert_servicecatalog_ServiceInstanceStatus_To_v1beta1_ServiceInstanceStatus,
107+
Convert_v1beta1_SharedServicePlanSpec_To_servicecatalog_SharedServicePlanSpec,
108+
Convert_servicecatalog_SharedServicePlanSpec_To_v1beta1_SharedServicePlanSpec,
107109
Convert_v1beta1_UserInfo_To_servicecatalog_UserInfo,
108110
Convert_servicecatalog_UserInfo_To_v1beta1_UserInfo,
109111
)
@@ -448,16 +450,10 @@ func Convert_servicecatalog_ClusterServicePlanList_To_v1beta1_ClusterServicePlan
448450
}
449451

450452
func autoConvert_v1beta1_ClusterServicePlanSpec_To_servicecatalog_ClusterServicePlanSpec(in *ClusterServicePlanSpec, out *servicecatalog.ClusterServicePlanSpec, s conversion.Scope) error {
453+
if err := Convert_v1beta1_SharedServicePlanSpec_To_servicecatalog_SharedServicePlanSpec(&in.SharedServicePlanSpec, &out.SharedServicePlanSpec, s); err != nil {
454+
return err
455+
}
451456
out.ClusterServiceBrokerName = in.ClusterServiceBrokerName
452-
out.ExternalName = in.ExternalName
453-
out.ExternalID = in.ExternalID
454-
out.Description = in.Description
455-
out.Bindable = (*bool)(unsafe.Pointer(in.Bindable))
456-
out.Free = in.Free
457-
out.ExternalMetadata = (*runtime.RawExtension)(unsafe.Pointer(in.ExternalMetadata))
458-
out.ServiceInstanceCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceCreateParameterSchema))
459-
out.ServiceInstanceUpdateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceUpdateParameterSchema))
460-
out.ServiceBindingCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceBindingCreateParameterSchema))
461457
if err := Convert_v1beta1_ClusterObjectReference_To_servicecatalog_ClusterObjectReference(&in.ClusterServiceClassRef, &out.ClusterServiceClassRef, s); err != nil {
462458
return err
463459
}
@@ -470,16 +466,10 @@ func Convert_v1beta1_ClusterServicePlanSpec_To_servicecatalog_ClusterServicePlan
470466
}
471467

472468
func autoConvert_servicecatalog_ClusterServicePlanSpec_To_v1beta1_ClusterServicePlanSpec(in *servicecatalog.ClusterServicePlanSpec, out *ClusterServicePlanSpec, s conversion.Scope) error {
469+
if err := Convert_servicecatalog_SharedServicePlanSpec_To_v1beta1_SharedServicePlanSpec(&in.SharedServicePlanSpec, &out.SharedServicePlanSpec, s); err != nil {
470+
return err
471+
}
473472
out.ClusterServiceBrokerName = in.ClusterServiceBrokerName
474-
out.ExternalName = in.ExternalName
475-
out.ExternalID = in.ExternalID
476-
out.Description = in.Description
477-
out.Bindable = (*bool)(unsafe.Pointer(in.Bindable))
478-
out.Free = in.Free
479-
out.ExternalMetadata = (*runtime.RawExtension)(unsafe.Pointer(in.ExternalMetadata))
480-
out.ServiceInstanceCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceCreateParameterSchema))
481-
out.ServiceInstanceUpdateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceUpdateParameterSchema))
482-
out.ServiceBindingCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceBindingCreateParameterSchema))
483473
if err := Convert_servicecatalog_ClusterObjectReference_To_v1beta1_ClusterObjectReference(&in.ClusterServiceClassRef, &out.ClusterServiceClassRef, s); err != nil {
484474
return err
485475
}
@@ -1041,6 +1031,42 @@ func Convert_servicecatalog_ServiceInstanceStatus_To_v1beta1_ServiceInstanceStat
10411031
return autoConvert_servicecatalog_ServiceInstanceStatus_To_v1beta1_ServiceInstanceStatus(in, out, s)
10421032
}
10431033

1034+
func autoConvert_v1beta1_SharedServicePlanSpec_To_servicecatalog_SharedServicePlanSpec(in *SharedServicePlanSpec, out *servicecatalog.SharedServicePlanSpec, s conversion.Scope) error {
1035+
out.ExternalName = in.ExternalName
1036+
out.ExternalID = in.ExternalID
1037+
out.Description = in.Description
1038+
out.Bindable = (*bool)(unsafe.Pointer(in.Bindable))
1039+
out.Free = in.Free
1040+
out.ExternalMetadata = (*runtime.RawExtension)(unsafe.Pointer(in.ExternalMetadata))
1041+
out.ServiceInstanceCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceCreateParameterSchema))
1042+
out.ServiceInstanceUpdateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceUpdateParameterSchema))
1043+
out.ServiceBindingCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceBindingCreateParameterSchema))
1044+
return nil
1045+
}
1046+
1047+
// Convert_v1beta1_SharedServicePlanSpec_To_servicecatalog_SharedServicePlanSpec is an autogenerated conversion function.
1048+
func Convert_v1beta1_SharedServicePlanSpec_To_servicecatalog_SharedServicePlanSpec(in *SharedServicePlanSpec, out *servicecatalog.SharedServicePlanSpec, s conversion.Scope) error {
1049+
return autoConvert_v1beta1_SharedServicePlanSpec_To_servicecatalog_SharedServicePlanSpec(in, out, s)
1050+
}
1051+
1052+
func autoConvert_servicecatalog_SharedServicePlanSpec_To_v1beta1_SharedServicePlanSpec(in *servicecatalog.SharedServicePlanSpec, out *SharedServicePlanSpec, s conversion.Scope) error {
1053+
out.ExternalName = in.ExternalName
1054+
out.ExternalID = in.ExternalID
1055+
out.Description = in.Description
1056+
out.Bindable = (*bool)(unsafe.Pointer(in.Bindable))
1057+
out.Free = in.Free
1058+
out.ExternalMetadata = (*runtime.RawExtension)(unsafe.Pointer(in.ExternalMetadata))
1059+
out.ServiceInstanceCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceCreateParameterSchema))
1060+
out.ServiceInstanceUpdateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceInstanceUpdateParameterSchema))
1061+
out.ServiceBindingCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.ServiceBindingCreateParameterSchema))
1062+
return nil
1063+
}
1064+
1065+
// Convert_servicecatalog_SharedServicePlanSpec_To_v1beta1_SharedServicePlanSpec is an autogenerated conversion function.
1066+
func Convert_servicecatalog_SharedServicePlanSpec_To_v1beta1_SharedServicePlanSpec(in *servicecatalog.SharedServicePlanSpec, out *SharedServicePlanSpec, s conversion.Scope) error {
1067+
return autoConvert_servicecatalog_SharedServicePlanSpec_To_v1beta1_SharedServicePlanSpec(in, out, s)
1068+
}
1069+
10441070
func autoConvert_v1beta1_UserInfo_To_servicecatalog_UserInfo(in *UserInfo, out *servicecatalog.UserInfo, s conversion.Scope) error {
10451071
out.Username = in.Username
10461072
out.UID = in.UID

pkg/apis/servicecatalog/v1beta1/zz_generated.deepcopy.go

Lines changed: 62 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -414,51 +414,7 @@ func (in *ClusterServicePlanList) DeepCopyObject() runtime.Object {
414414
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
415415
func (in *ClusterServicePlanSpec) DeepCopyInto(out *ClusterServicePlanSpec) {
416416
*out = *in
417-
if in.Bindable != nil {
418-
in, out := &in.Bindable, &out.Bindable
419-
if *in == nil {
420-
*out = nil
421-
} else {
422-
*out = new(bool)
423-
**out = **in
424-
}
425-
}
426-
if in.ExternalMetadata != nil {
427-
in, out := &in.ExternalMetadata, &out.ExternalMetadata
428-
if *in == nil {
429-
*out = nil
430-
} else {
431-
*out = new(runtime.RawExtension)
432-
(*in).DeepCopyInto(*out)
433-
}
434-
}
435-
if in.ServiceInstanceCreateParameterSchema != nil {
436-
in, out := &in.ServiceInstanceCreateParameterSchema, &out.ServiceInstanceCreateParameterSchema
437-
if *in == nil {
438-
*out = nil
439-
} else {
440-
*out = new(runtime.RawExtension)
441-
(*in).DeepCopyInto(*out)
442-
}
443-
}
444-
if in.ServiceInstanceUpdateParameterSchema != nil {
445-
in, out := &in.ServiceInstanceUpdateParameterSchema, &out.ServiceInstanceUpdateParameterSchema
446-
if *in == nil {
447-
*out = nil
448-
} else {
449-
*out = new(runtime.RawExtension)
450-
(*in).DeepCopyInto(*out)
451-
}
452-
}
453-
if in.ServiceBindingCreateParameterSchema != nil {
454-
in, out := &in.ServiceBindingCreateParameterSchema, &out.ServiceBindingCreateParameterSchema
455-
if *in == nil {
456-
*out = nil
457-
} else {
458-
*out = new(runtime.RawExtension)
459-
(*in).DeepCopyInto(*out)
460-
}
461-
}
417+
in.SharedServicePlanSpec.DeepCopyInto(&out.SharedServicePlanSpec)
462418
out.ClusterServiceClassRef = in.ClusterServiceClassRef
463419
return
464420
}
@@ -1086,6 +1042,67 @@ func (in *ServiceInstanceStatus) DeepCopy() *ServiceInstanceStatus {
10861042
return out
10871043
}
10881044

1045+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
1046+
func (in *SharedServicePlanSpec) DeepCopyInto(out *SharedServicePlanSpec) {
1047+
*out = *in
1048+
if in.Bindable != nil {
1049+
in, out := &in.Bindable, &out.Bindable
1050+
if *in == nil {
1051+
*out = nil
1052+
} else {
1053+
*out = new(bool)
1054+
**out = **in
1055+
}
1056+
}
1057+
if in.ExternalMetadata != nil {
1058+
in, out := &in.ExternalMetadata, &out.ExternalMetadata
1059+
if *in == nil {
1060+
*out = nil
1061+
} else {
1062+
*out = new(runtime.RawExtension)
1063+
(*in).DeepCopyInto(*out)
1064+
}
1065+
}
1066+
if in.ServiceInstanceCreateParameterSchema != nil {
1067+
in, out := &in.ServiceInstanceCreateParameterSchema, &out.ServiceInstanceCreateParameterSchema
1068+
if *in == nil {
1069+
*out = nil
1070+
} else {
1071+
*out = new(runtime.RawExtension)
1072+
(*in).DeepCopyInto(*out)
1073+
}
1074+
}
1075+
if in.ServiceInstanceUpdateParameterSchema != nil {
1076+
in, out := &in.ServiceInstanceUpdateParameterSchema, &out.ServiceInstanceUpdateParameterSchema
1077+
if *in == nil {
1078+
*out = nil
1079+
} else {
1080+
*out = new(runtime.RawExtension)
1081+
(*in).DeepCopyInto(*out)
1082+
}
1083+
}
1084+
if in.ServiceBindingCreateParameterSchema != nil {
1085+
in, out := &in.ServiceBindingCreateParameterSchema, &out.ServiceBindingCreateParameterSchema
1086+
if *in == nil {
1087+
*out = nil
1088+
} else {
1089+
*out = new(runtime.RawExtension)
1090+
(*in).DeepCopyInto(*out)
1091+
}
1092+
}
1093+
return
1094+
}
1095+
1096+
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SharedServicePlanSpec.
1097+
func (in *SharedServicePlanSpec) DeepCopy() *SharedServicePlanSpec {
1098+
if in == nil {
1099+
return nil
1100+
}
1101+
out := new(SharedServicePlanSpec)
1102+
in.DeepCopyInto(out)
1103+
return out
1104+
}
1105+
10891106
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
10901107
func (in *UserInfo) DeepCopyInto(out *UserInfo) {
10911108
*out = *in

pkg/apis/servicecatalog/validation/serviceplan_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ func validClusterServicePlan() *servicecatalog.ClusterServicePlan {
3030
Name: "test-plan",
3131
},
3232
Spec: servicecatalog.ClusterServicePlanSpec{
33+
SharedServicePlanSpec: servicecatalog.SharedServicePlanSpec{
34+
ExternalName: "test-plan",
35+
ExternalID: "40d-0983-1b89",
36+
Description: "plan description",
37+
},
3338
ClusterServiceBrokerName: "test-broker",
34-
ExternalName: "test-plan",
35-
ExternalID: "40d-0983-1b89",
36-
Description: "plan description",
3739
ClusterServiceClassRef: servicecatalog.ClusterObjectReference{
3840
Name: "test-service-class",
3941
},

0 commit comments

Comments
 (0)