From 55548558b01263ad1703944dc30256a5c225c48f Mon Sep 17 00:00:00 2001 From: Paul Morie Date: Tue, 9 May 2017 16:38:15 -0400 Subject: [PATCH 1/3] Add support for OSB parameter schemas --- pkg/apis/servicecatalog/testing/fuzzer.go | 5 +- pkg/apis/servicecatalog/types.go | 22 ++++++ pkg/apis/servicecatalog/v1alpha1/types.go | 22 ++++++ pkg/brokerapi/schemas.go | 14 ++-- pkg/controller/controller.go | 35 +++++++++ pkg/controller/controller_test.go | 96 +++++++++++++++++++++++ 6 files changed, 185 insertions(+), 9 deletions(-) diff --git a/pkg/apis/servicecatalog/testing/fuzzer.go b/pkg/apis/servicecatalog/testing/fuzzer.go index f75511c3441..72246382994 100644 --- a/pkg/apis/servicecatalog/testing/fuzzer.go +++ b/pkg/apis/servicecatalog/testing/fuzzer.go @@ -168,7 +168,7 @@ func FuzzerFor(t *testing.T, version schema.GroupVersion, src rand.Source) *fuzz c.Fuzz(obj) // Find a codec for converting the object to raw bytes. This is necessary for the - // api version and kind to be correctly set be serialization. + // api version and kind to be correctly set by serialization. var codec runtime.Codec switch obj.(type) { case *api.Pod: @@ -229,6 +229,9 @@ func FuzzerFor(t *testing.T, version schema.GroupVersion, src rand.Source) *fuzz return } sp.ExternalMetadata = metadata + sp.AlphaBindingCreateParameterSchema = metadata + sp.AlphaInstanceCreateParameterSchema = metadata + sp.AlphaInstanceUpdateParameterSchema = metadata }, ) return f diff --git a/pkg/apis/servicecatalog/types.go b/pkg/apis/servicecatalog/types.go index 20db5191c95..c85a2560550 100644 --- a/pkg/apis/servicecatalog/types.go +++ b/pkg/apis/servicecatalog/types.go @@ -199,6 +199,28 @@ type ServicePlan struct { // user-facing content and display instructions. This field may contain // platform-specific conventional values. ExternalMetadata *runtime.RawExtension + + // Currently, this field is ALPHA: it may change or disappear at any time + // and its data will not be migrated. + // + // AlphaInstanceCreateParameterSchema is the schema for the parameters + // that may be supplied when provisioning a new Instance on this plan. + AlphaInstanceCreateParameterSchema *runtime.RawExtension + + // Currently, this field is ALPHA: it may change or disappear at any time + // and its data will not be migrated. + // + // AlphaInstanceUpdateParameterSchema is the schema for the parameters + // that may be updated once an Instance has been provisioned on this plan. + // This field only has meaning if the ServiceClass is PlanUpdatable. + AlphaInstanceUpdateParameterSchema *runtime.RawExtension + + // Currently, this field is ALPHA: it may change or disappear at any time + // and its data will not be migrated. + // + // AlphaBindingCreateParameterSchema is the schema for the parameters that + // may be supplied binding to an Instance on this plan. + AlphaBindingCreateParameterSchema *runtime.RawExtension } // InstanceList is a list of instances. diff --git a/pkg/apis/servicecatalog/v1alpha1/types.go b/pkg/apis/servicecatalog/v1alpha1/types.go index 15fc5f8d048..0a0f4c8ec54 100644 --- a/pkg/apis/servicecatalog/v1alpha1/types.go +++ b/pkg/apis/servicecatalog/v1alpha1/types.go @@ -200,6 +200,28 @@ type ServicePlan struct { // user-facing content and display instructions. This field may contain // platform-specific conventional values. ExternalMetadata *runtime.RawExtension `json:"externalMetadata, omitempty"` + + // Currently, this field is ALPHA: it may change or disappear at any time + // and its data will not be migrated. + // + // AlphaInstanceCreateParameterSchema is the schema for the parameters + // that may be supplied when provisioning a new Instance on this plan. + AlphaInstanceCreateParameterSchema *runtime.RawExtension `json:"alphaInstanceCreateParameterSchema,omitempty"` + + // Currently, this field is ALPHA: it may change or disappear at any time + // and its data will not be migrated. + // + // AlphaInstanceUpdateParameterSchema is the schema for the parameters + // that may be updated once an Instance has been provisioned on this plan. + // This field only has meaning if the ServiceClass is PlanUpdatable. + AlphaInstanceUpdateParameterSchema *runtime.RawExtension `json:"alphaInstanceUpdateParameterSchema,omitempty"` + + // Currently, this field is ALPHA: it may change or disappear at any time + // and its data will not be migrated. + // + // AlphaBindingCreateParameterSchema is the schema for the parameters that + // may be supplied binding to an Instance on this plan. + AlphaBindingCreateParameterSchema *runtime.RawExtension `json:"alphaBindingCreateParameterSchema,omitempty"` } // InstanceList is a list of instances. diff --git a/pkg/brokerapi/schemas.go b/pkg/brokerapi/schemas.go index d4098785ba1..98b551ce55c 100644 --- a/pkg/brokerapi/schemas.go +++ b/pkg/brokerapi/schemas.go @@ -16,16 +16,14 @@ limitations under the License. package brokerapi -// Schemas represents a broker's schemas for both service instances and service -// bindings +// Schemas represents a plan's schemas for service instance and binding create +// and update. type Schemas struct { - Instance Schema `json:"instance"` - Binding Schema `json:"binding"` + ServiceInstances *Schema `json:"service_instances,omitempty"` + ServiceBindings *Schema `json:"service_bindings,omitempty"` } -// Schema consists of the schema for inputs and the schema for outputs. -// Schemas are in the form of JSON Schema v4 (http://json-schema.org/). type Schema struct { - Inputs string `json:"inputs"` - Outputs string `json:"outputs"` + Create interface{} `json:"create,omitempty"` + Update interface{} `json:"update,omitempty"` } diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 9beb70569ea..faae5da89a6 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -414,6 +414,7 @@ func convertServicePlans(plans []brokerapi.ServicePlan) ([]v1alpha1.ServicePlan, Free: plans[i].Free, Description: plans[i].Description, } + if plans[i].Bindable != nil { b := *plans[i].Bindable ret[i].Bindable = &b @@ -429,6 +430,40 @@ func convertServicePlans(plans []brokerapi.ServicePlan) ([]v1alpha1.ServicePlan, ret[i].ExternalMetadata = &runtime.RawExtension{Raw: metadata} } + if schemas := plans[i].Schemas; schemas != nil { + if instanceSchemas := schemas.ServiceInstances; instanceSchemas != nil { + if instanceCreateSchema := instanceSchemas.Create; instanceCreateSchema != nil { + schema, err := json.Marshal(instanceCreateSchema) + if err != nil { + err = fmt.Errorf("Failed to marshal instance create schema \n%+v\n %v", instanceCreateSchema, err) + glog.Error(err) + return nil, err + } + ret[i].AlphaInstanceCreateParameterSchema = &runtime.RawExtension{Raw: schema} + } + if instanceUpdateSchema := instanceSchemas.Update; instanceUpdateSchema != nil { + schema, err := json.Marshal(instanceUpdateSchema) + if err != nil { + err = fmt.Errorf("Failed to marshal instance update schema \n%+v\n %v", instanceUpdateSchema, err) + glog.Error(err) + return nil, err + } + ret[i].AlphaInstanceUpdateParameterSchema = &runtime.RawExtension{Raw: schema} + } + } + if bindingSchemas := schemas.ServiceBindings; bindingSchemas != nil { + if bindingCreateSchema := bindingSchemas.Create; bindingCreateSchema != nil { + schema, err := json.Marshal(bindingCreateSchema) + if err != nil { + err = fmt.Errorf("Failed to marshal binding create schema \n%+v\n %v", bindingCreateSchema, err) + glog.Error(err) + return nil, err + } + ret[i].AlphaBindingCreateParameterSchema = &runtime.RawExtension{Raw: schema} + } + } + } + } return ret, nil } diff --git a/pkg/controller/controller_test.go b/pkg/controller/controller_test.go index 8665276a7cb..b2fb579b83f 100644 --- a/pkg/controller/controller_test.go +++ b/pkg/controller/controller_test.go @@ -433,6 +433,102 @@ func TestCatalogConversion(t *testing.T) { checkPlan(serviceClass, 1, "fake-plan-2", "Shared fake Server, 5tb persistent disk, 40 max concurrent connections. 100 async", t) } +const alphaParameterSchemaCatalogBytes = `{ + "services": [{ + "name": "fake-service", + "id": "acb56d7c-XXXX-XXXX-XXXX-feb140a59a66", + "description": "fake service", + "tags": ["tag1", "tag2"], + "requires": ["route_forwarding"], + "bindable": true, + "metadata": { + "a": "b", + "c": "d" + }, + "dashboard_client": { + "id": "398e2f8e-XXXX-XXXX-XXXX-19a71ecbcf64", + "secret": "277cabb0-XXXX-XXXX-XXXX-7822c0a90e5d", + "redirect_uri": "http://localhost:1234" + }, + "plan_updateable": true, + "plans": [{ + "name": "fake-plan-1", + "id": "d3031751-XXXX-XXXX-XXXX-a42377d3320e", + "description": "description1", + "metadata": { + "b": "c", + "d": "e" + }, + "schemas": { + "service_instances": { + "create": { + "foo": "bar" + }, + "update": { + "baz": "zap" + } + }, + "service_bindings": { + "create": { + "zoo": "blu" + } + } + } + }] + }] +}` + +func TestCatalogConversionWithAlphaParameterSchemas(t *testing.T) { + catalog := &brokerapi.Catalog{} + err := json.Unmarshal([]byte(alphaParameterSchemaCatalogBytes), &catalog) + if err != nil { + t.Fatalf("Failed to unmarshal test catalog: %v", err) + } + serviceClasses, err := convertCatalog(catalog) + if err != nil { + t.Fatalf("Failed to convertCatalog: %v", err) + } + if len(serviceClasses) != 1 { + t.Fatalf("Expected 1 serviceclasses for testCatalog, but got: %d", len(serviceClasses)) + } + serviceClass := serviceClasses[0] + if len(serviceClass.Plans) != 1 { + t.Fatalf("Expected 1 plan for testCatalog, but got: %d", len(serviceClass.Plans)) + } + + plan := serviceClass.Plans[0] + if plan.AlphaInstanceCreateParameterSchema == nil { + t.Fatalf("Expected plan.AlphaInstanceCreateParameterSchema to be set, but was nil") + } + + m := make(map[string]string) + if err := json.Unmarshal(plan.AlphaInstanceCreateParameterSchema.Raw, &m); err == nil { + if e, a := "bar", m["foo"]; e != a { + t.Fatalf("Unexpected value of alphaInstanceCreateParameterSchema; expected %v, got %v", e, a) + } + } + + if plan.AlphaInstanceUpdateParameterSchema == nil { + t.Fatalf("Expected plan.AlphaInstanceUpdateParameterSchema to be set, but was nil") + } + m = make(map[string]string) + if err := json.Unmarshal(plan.AlphaInstanceUpdateParameterSchema.Raw, &m); err == nil { + if e, a := "zap", m["baz"]; e != a { + t.Fatalf("Unexpected value of alphaInstanceUpdateParameterSchema; expected %v, got %v", e, a) + } + } + + if plan.AlphaBindingCreateParameterSchema == nil { + t.Fatalf("Expected plan.AlphaBindingCreateParameterSchema to be set, but was nil") + } + m = make(map[string]string) + if err := json.Unmarshal(plan.AlphaBindingCreateParameterSchema.Raw, &m); err == nil { + if e, a := "blu", m["zoo"]; e != a { + t.Fatalf("Unexpected value of alphaBindingCreateParameterSchema; expected %v, got %v", e, a) + } + } +} + func checkPlan(serviceClass *v1alpha1.ServiceClass, index int, planName, planDescription string, t *testing.T) { plan := serviceClass.Plans[index] if plan.Name != planName { From ef0f91f6eb048147666b6e4c452ec7bc03c318c9 Mon Sep 17 00:00:00 2001 From: Paul Morie Date: Thu, 18 May 2017 13:59:30 -0400 Subject: [PATCH 2/3] Regen code --- .../v1alpha1/types.generated.go | 390 +++++++++++++++--- .../v1alpha1/zz_generated.conversion.go | 6 + .../v1alpha1/zz_generated.deepcopy.go | 24 ++ .../servicecatalog/zz_generated.deepcopy.go | 24 ++ pkg/openapi/openapi_generated.go | 18 + 5 files changed, 399 insertions(+), 63 deletions(-) diff --git a/pkg/apis/servicecatalog/v1alpha1/types.generated.go b/pkg/apis/servicecatalog/v1alpha1/types.generated.go index 5de604c5e68..81b9b5a4199 100644 --- a/pkg/apis/servicecatalog/v1alpha1/types.generated.go +++ b/pkg/apis/servicecatalog/v1alpha1/types.generated.go @@ -2882,13 +2882,16 @@ func (x *ServicePlan) CodecEncodeSelf(e *codec1978.Encoder) { } else { yysep2 := !z.EncBinary() yy2arr2 := z.EncBasicHandle().StructToArray - var yyq2 [6]bool + var yyq2 [9]bool _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false yyq2[3] = x.Bindable != nil + yyq2[6] = x.AlphaInstanceCreateParameterSchema != nil + yyq2[7] = x.AlphaInstanceUpdateParameterSchema != nil + yyq2[8] = x.AlphaBindingCreateParameterSchema != nil var yynn2 int if yyr2 || yy2arr2 { - r.EncodeArrayStart(6) + r.EncodeArrayStart(9) } else { yynn2 = 5 for _, b := range yyq2 { @@ -3043,6 +3046,123 @@ func (x *ServicePlan) CodecEncodeSelf(e *codec1978.Encoder) { } } } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[6] { + if x.AlphaInstanceCreateParameterSchema == nil { + r.EncodeNil() + } else { + yym24 := z.EncBinary() + _ = yym24 + if false { + } else if z.HasExtensions() && z.EncExt(x.AlphaInstanceCreateParameterSchema) { + } else if !yym24 && z.IsJSONHandle() { + z.EncJSONMarshal(x.AlphaInstanceCreateParameterSchema) + } else { + z.EncFallback(x.AlphaInstanceCreateParameterSchema) + } + } + } else { + r.EncodeNil() + } + } else { + if yyq2[6] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("alphaInstanceCreateParameterSchema")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.AlphaInstanceCreateParameterSchema == nil { + r.EncodeNil() + } else { + yym25 := z.EncBinary() + _ = yym25 + if false { + } else if z.HasExtensions() && z.EncExt(x.AlphaInstanceCreateParameterSchema) { + } else if !yym25 && z.IsJSONHandle() { + z.EncJSONMarshal(x.AlphaInstanceCreateParameterSchema) + } else { + z.EncFallback(x.AlphaInstanceCreateParameterSchema) + } + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[7] { + if x.AlphaInstanceUpdateParameterSchema == nil { + r.EncodeNil() + } else { + yym27 := z.EncBinary() + _ = yym27 + if false { + } else if z.HasExtensions() && z.EncExt(x.AlphaInstanceUpdateParameterSchema) { + } else if !yym27 && z.IsJSONHandle() { + z.EncJSONMarshal(x.AlphaInstanceUpdateParameterSchema) + } else { + z.EncFallback(x.AlphaInstanceUpdateParameterSchema) + } + } + } else { + r.EncodeNil() + } + } else { + if yyq2[7] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("alphaInstanceUpdateParameterSchema")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.AlphaInstanceUpdateParameterSchema == nil { + r.EncodeNil() + } else { + yym28 := z.EncBinary() + _ = yym28 + if false { + } else if z.HasExtensions() && z.EncExt(x.AlphaInstanceUpdateParameterSchema) { + } else if !yym28 && z.IsJSONHandle() { + z.EncJSONMarshal(x.AlphaInstanceUpdateParameterSchema) + } else { + z.EncFallback(x.AlphaInstanceUpdateParameterSchema) + } + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[8] { + if x.AlphaBindingCreateParameterSchema == nil { + r.EncodeNil() + } else { + yym30 := z.EncBinary() + _ = yym30 + if false { + } else if z.HasExtensions() && z.EncExt(x.AlphaBindingCreateParameterSchema) { + } else if !yym30 && z.IsJSONHandle() { + z.EncJSONMarshal(x.AlphaBindingCreateParameterSchema) + } else { + z.EncFallback(x.AlphaBindingCreateParameterSchema) + } + } + } else { + r.EncodeNil() + } + } else { + if yyq2[8] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("alphaBindingCreateParameterSchema")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.AlphaBindingCreateParameterSchema == nil { + r.EncodeNil() + } else { + yym31 := z.EncBinary() + _ = yym31 + if false { + } else if z.HasExtensions() && z.EncExt(x.AlphaBindingCreateParameterSchema) { + } else if !yym31 && z.IsJSONHandle() { + z.EncJSONMarshal(x.AlphaBindingCreateParameterSchema) + } else { + z.EncFallback(x.AlphaBindingCreateParameterSchema) + } + } + } + } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayEnd1234) } else { @@ -3187,6 +3307,63 @@ func (x *ServicePlan) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { z.DecFallback(x.ExternalMetadata, false) } } + case "alphaInstanceCreateParameterSchema": + if r.TryDecodeAsNil() { + if x.AlphaInstanceCreateParameterSchema != nil { + x.AlphaInstanceCreateParameterSchema = nil + } + } else { + if x.AlphaInstanceCreateParameterSchema == nil { + x.AlphaInstanceCreateParameterSchema = new(pkg4_runtime.RawExtension) + } + yym17 := z.DecBinary() + _ = yym17 + if false { + } else if z.HasExtensions() && z.DecExt(x.AlphaInstanceCreateParameterSchema) { + } else if !yym17 && z.IsJSONHandle() { + z.DecJSONUnmarshal(x.AlphaInstanceCreateParameterSchema) + } else { + z.DecFallback(x.AlphaInstanceCreateParameterSchema, false) + } + } + case "alphaInstanceUpdateParameterSchema": + if r.TryDecodeAsNil() { + if x.AlphaInstanceUpdateParameterSchema != nil { + x.AlphaInstanceUpdateParameterSchema = nil + } + } else { + if x.AlphaInstanceUpdateParameterSchema == nil { + x.AlphaInstanceUpdateParameterSchema = new(pkg4_runtime.RawExtension) + } + yym19 := z.DecBinary() + _ = yym19 + if false { + } else if z.HasExtensions() && z.DecExt(x.AlphaInstanceUpdateParameterSchema) { + } else if !yym19 && z.IsJSONHandle() { + z.DecJSONUnmarshal(x.AlphaInstanceUpdateParameterSchema) + } else { + z.DecFallback(x.AlphaInstanceUpdateParameterSchema, false) + } + } + case "alphaBindingCreateParameterSchema": + if r.TryDecodeAsNil() { + if x.AlphaBindingCreateParameterSchema != nil { + x.AlphaBindingCreateParameterSchema = nil + } + } else { + if x.AlphaBindingCreateParameterSchema == nil { + x.AlphaBindingCreateParameterSchema = new(pkg4_runtime.RawExtension) + } + yym21 := z.DecBinary() + _ = yym21 + if false { + } else if z.HasExtensions() && z.DecExt(x.AlphaBindingCreateParameterSchema) { + } else if !yym21 && z.IsJSONHandle() { + z.DecJSONUnmarshal(x.AlphaBindingCreateParameterSchema) + } else { + z.DecFallback(x.AlphaBindingCreateParameterSchema, false) + } + } default: z.DecStructFieldNotFound(-1, yys3) } // end switch yys3 @@ -3198,16 +3375,16 @@ func (x *ServicePlan) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj16 int - var yyb16 bool - var yyhl16 bool = l >= 0 - yyj16++ - if yyhl16 { - yyb16 = yyj16 > l + var yyj22 int + var yyb22 bool + var yyhl22 bool = l >= 0 + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l } else { - yyb16 = r.CheckBreak() + yyb22 = r.CheckBreak() } - if yyb16 { + if yyb22 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -3215,21 +3392,21 @@ func (x *ServicePlan) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.Name = "" } else { - yyv17 := &x.Name - yym18 := z.DecBinary() - _ = yym18 + yyv23 := &x.Name + yym24 := z.DecBinary() + _ = yym24 if false { } else { - *((*string)(yyv17)) = r.DecodeString() + *((*string)(yyv23)) = r.DecodeString() } } - yyj16++ - if yyhl16 { - yyb16 = yyj16 > l + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l } else { - yyb16 = r.CheckBreak() + yyb22 = r.CheckBreak() } - if yyb16 { + if yyb22 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -3237,21 +3414,21 @@ func (x *ServicePlan) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.ExternalID = "" } else { - yyv19 := &x.ExternalID - yym20 := z.DecBinary() - _ = yym20 + yyv25 := &x.ExternalID + yym26 := z.DecBinary() + _ = yym26 if false { } else { - *((*string)(yyv19)) = r.DecodeString() + *((*string)(yyv25)) = r.DecodeString() } } - yyj16++ - if yyhl16 { - yyb16 = yyj16 > l + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l } else { - yyb16 = r.CheckBreak() + yyb22 = r.CheckBreak() } - if yyb16 { + if yyb22 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -3259,21 +3436,21 @@ func (x *ServicePlan) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.Description = "" } else { - yyv21 := &x.Description - yym22 := z.DecBinary() - _ = yym22 + yyv27 := &x.Description + yym28 := z.DecBinary() + _ = yym28 if false { } else { - *((*string)(yyv21)) = r.DecodeString() + *((*string)(yyv27)) = r.DecodeString() } } - yyj16++ - if yyhl16 { - yyb16 = yyj16 > l + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l } else { - yyb16 = r.CheckBreak() + yyb22 = r.CheckBreak() } - if yyb16 { + if yyb22 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -3286,20 +3463,20 @@ func (x *ServicePlan) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if x.Bindable == nil { x.Bindable = new(bool) } - yym24 := z.DecBinary() - _ = yym24 + yym30 := z.DecBinary() + _ = yym30 if false { } else { *((*bool)(x.Bindable)) = r.DecodeBool() } } - yyj16++ - if yyhl16 { - yyb16 = yyj16 > l + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l } else { - yyb16 = r.CheckBreak() + yyb22 = r.CheckBreak() } - if yyb16 { + if yyb22 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -3307,21 +3484,21 @@ func (x *ServicePlan) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.Free = false } else { - yyv25 := &x.Free - yym26 := z.DecBinary() - _ = yym26 + yyv31 := &x.Free + yym32 := z.DecBinary() + _ = yym32 if false { } else { - *((*bool)(yyv25)) = r.DecodeBool() + *((*bool)(yyv31)) = r.DecodeBool() } } - yyj16++ - if yyhl16 { - yyb16 = yyj16 > l + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l } else { - yyb16 = r.CheckBreak() + yyb22 = r.CheckBreak() } - if yyb16 { + if yyb22 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -3334,28 +3511,115 @@ func (x *ServicePlan) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if x.ExternalMetadata == nil { x.ExternalMetadata = new(pkg4_runtime.RawExtension) } - yym28 := z.DecBinary() - _ = yym28 + yym34 := z.DecBinary() + _ = yym34 if false { } else if z.HasExtensions() && z.DecExt(x.ExternalMetadata) { - } else if !yym28 && z.IsJSONHandle() { + } else if !yym34 && z.IsJSONHandle() { z.DecJSONUnmarshal(x.ExternalMetadata) } else { z.DecFallback(x.ExternalMetadata, false) } } + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l + } else { + yyb22 = r.CheckBreak() + } + if yyb22 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.AlphaInstanceCreateParameterSchema != nil { + x.AlphaInstanceCreateParameterSchema = nil + } + } else { + if x.AlphaInstanceCreateParameterSchema == nil { + x.AlphaInstanceCreateParameterSchema = new(pkg4_runtime.RawExtension) + } + yym36 := z.DecBinary() + _ = yym36 + if false { + } else if z.HasExtensions() && z.DecExt(x.AlphaInstanceCreateParameterSchema) { + } else if !yym36 && z.IsJSONHandle() { + z.DecJSONUnmarshal(x.AlphaInstanceCreateParameterSchema) + } else { + z.DecFallback(x.AlphaInstanceCreateParameterSchema, false) + } + } + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l + } else { + yyb22 = r.CheckBreak() + } + if yyb22 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.AlphaInstanceUpdateParameterSchema != nil { + x.AlphaInstanceUpdateParameterSchema = nil + } + } else { + if x.AlphaInstanceUpdateParameterSchema == nil { + x.AlphaInstanceUpdateParameterSchema = new(pkg4_runtime.RawExtension) + } + yym38 := z.DecBinary() + _ = yym38 + if false { + } else if z.HasExtensions() && z.DecExt(x.AlphaInstanceUpdateParameterSchema) { + } else if !yym38 && z.IsJSONHandle() { + z.DecJSONUnmarshal(x.AlphaInstanceUpdateParameterSchema) + } else { + z.DecFallback(x.AlphaInstanceUpdateParameterSchema, false) + } + } + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l + } else { + yyb22 = r.CheckBreak() + } + if yyb22 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.AlphaBindingCreateParameterSchema != nil { + x.AlphaBindingCreateParameterSchema = nil + } + } else { + if x.AlphaBindingCreateParameterSchema == nil { + x.AlphaBindingCreateParameterSchema = new(pkg4_runtime.RawExtension) + } + yym40 := z.DecBinary() + _ = yym40 + if false { + } else if z.HasExtensions() && z.DecExt(x.AlphaBindingCreateParameterSchema) { + } else if !yym40 && z.IsJSONHandle() { + z.DecJSONUnmarshal(x.AlphaBindingCreateParameterSchema) + } else { + z.DecFallback(x.AlphaBindingCreateParameterSchema, false) + } + } for { - yyj16++ - if yyhl16 { - yyb16 = yyj16 > l + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l } else { - yyb16 = r.CheckBreak() + yyb22 = r.CheckBreak() } - if yyb16 { + if yyb22 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj16-1, "") + z.DecStructFieldNotFound(yyj22-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -7481,7 +7745,7 @@ func (x codecSelfer1234) decSliceServicePlan(v *[]ServicePlan, d *codec1978.Deco yyrg1 := len(yyv1) > 0 yyv21 := yyv1 - yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 72) + yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 96) if yyrt1 { if yyrl1 <= cap(yyv1) { yyv1 = yyv1[:yyrl1] diff --git a/pkg/apis/servicecatalog/v1alpha1/zz_generated.conversion.go b/pkg/apis/servicecatalog/v1alpha1/zz_generated.conversion.go index 10021d1cb62..7b22d2a08a7 100644 --- a/pkg/apis/servicecatalog/v1alpha1/zz_generated.conversion.go +++ b/pkg/apis/servicecatalog/v1alpha1/zz_generated.conversion.go @@ -498,6 +498,9 @@ func autoConvert_v1alpha1_ServicePlan_To_servicecatalog_ServicePlan(in *ServiceP out.Bindable = (*bool)(unsafe.Pointer(in.Bindable)) out.Free = in.Free out.ExternalMetadata = (*runtime.RawExtension)(unsafe.Pointer(in.ExternalMetadata)) + out.AlphaInstanceCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.AlphaInstanceCreateParameterSchema)) + out.AlphaInstanceUpdateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.AlphaInstanceUpdateParameterSchema)) + out.AlphaBindingCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.AlphaBindingCreateParameterSchema)) return nil } @@ -512,6 +515,9 @@ func autoConvert_servicecatalog_ServicePlan_To_v1alpha1_ServicePlan(in *servicec out.Bindable = (*bool)(unsafe.Pointer(in.Bindable)) out.Free = in.Free out.ExternalMetadata = (*runtime.RawExtension)(unsafe.Pointer(in.ExternalMetadata)) + out.AlphaInstanceCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.AlphaInstanceCreateParameterSchema)) + out.AlphaInstanceUpdateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.AlphaInstanceUpdateParameterSchema)) + out.AlphaBindingCreateParameterSchema = (*runtime.RawExtension)(unsafe.Pointer(in.AlphaBindingCreateParameterSchema)) return nil } diff --git a/pkg/apis/servicecatalog/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/servicecatalog/v1alpha1/zz_generated.deepcopy.go index a6ab07e3919..f87b0c33e78 100644 --- a/pkg/apis/servicecatalog/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/servicecatalog/v1alpha1/zz_generated.deepcopy.go @@ -400,6 +400,30 @@ func DeepCopy_v1alpha1_ServicePlan(in interface{}, out interface{}, c *conversio *out = newVal.(*runtime.RawExtension) } } + if in.AlphaInstanceCreateParameterSchema != nil { + in, out := &in.AlphaInstanceCreateParameterSchema, &out.AlphaInstanceCreateParameterSchema + if newVal, err := c.DeepCopy(*in); err != nil { + return err + } else { + *out = newVal.(*runtime.RawExtension) + } + } + if in.AlphaInstanceUpdateParameterSchema != nil { + in, out := &in.AlphaInstanceUpdateParameterSchema, &out.AlphaInstanceUpdateParameterSchema + if newVal, err := c.DeepCopy(*in); err != nil { + return err + } else { + *out = newVal.(*runtime.RawExtension) + } + } + if in.AlphaBindingCreateParameterSchema != nil { + in, out := &in.AlphaBindingCreateParameterSchema, &out.AlphaBindingCreateParameterSchema + if newVal, err := c.DeepCopy(*in); err != nil { + return err + } else { + *out = newVal.(*runtime.RawExtension) + } + } return nil } } diff --git a/pkg/apis/servicecatalog/zz_generated.deepcopy.go b/pkg/apis/servicecatalog/zz_generated.deepcopy.go index 8e00a8b94ed..f009f838867 100644 --- a/pkg/apis/servicecatalog/zz_generated.deepcopy.go +++ b/pkg/apis/servicecatalog/zz_generated.deepcopy.go @@ -400,6 +400,30 @@ func DeepCopy_servicecatalog_ServicePlan(in interface{}, out interface{}, c *con *out = newVal.(*runtime.RawExtension) } } + if in.AlphaInstanceCreateParameterSchema != nil { + in, out := &in.AlphaInstanceCreateParameterSchema, &out.AlphaInstanceCreateParameterSchema + if newVal, err := c.DeepCopy(*in); err != nil { + return err + } else { + *out = newVal.(*runtime.RawExtension) + } + } + if in.AlphaInstanceUpdateParameterSchema != nil { + in, out := &in.AlphaInstanceUpdateParameterSchema, &out.AlphaInstanceUpdateParameterSchema + if newVal, err := c.DeepCopy(*in); err != nil { + return err + } else { + *out = newVal.(*runtime.RawExtension) + } + } + if in.AlphaBindingCreateParameterSchema != nil { + in, out := &in.AlphaBindingCreateParameterSchema, &out.AlphaBindingCreateParameterSchema + if newVal, err := c.DeepCopy(*in); err != nil { + return err + } else { + *out = newVal.(*runtime.RawExtension) + } + } return nil } } diff --git a/pkg/openapi/openapi_generated.go b/pkg/openapi/openapi_generated.go index 9f0fa4ee4c1..3cc7ddd6e1a 100644 --- a/pkg/openapi/openapi_generated.go +++ b/pkg/openapi/openapi_generated.go @@ -831,6 +831,24 @@ func GetOpenAPIDefinitions(ref openapi.ReferenceCallback) map[string]openapi.Ope Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), }, }, + "alphaInstanceCreateParameterSchema": { + 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\nAlphaInstanceCreateParameterSchema is the schema for the parameters that may be supplied when provisioning a new Instance on this plan.", + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + "alphaInstanceUpdateParameterSchema": { + 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\nAlphaInstanceUpdateParameterSchema is the schema for the parameters that may be updated once an Instance has been provisioned on this plan. This field only has meaning if the ServiceClass is PlanUpdatable.", + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, + "alphaBindingCreateParameterSchema": { + 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\nAlphaBindingCreateParameterSchema is the schema for the parameters that may be supplied binding to an Instance on this plan.", + Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"), + }, + }, }, Required: []string{"name", "externalID", "description", "free"}, }, From 58e9f2aea4280b658c25f6e733c4bdc06395050f Mon Sep 17 00:00:00 2001 From: Paul Morie Date: Thu, 18 May 2017 23:19:14 -0400 Subject: [PATCH 3/3] godoc --- pkg/brokerapi/schemas.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/brokerapi/schemas.go b/pkg/brokerapi/schemas.go index 98b551ce55c..a026ca4e1f0 100644 --- a/pkg/brokerapi/schemas.go +++ b/pkg/brokerapi/schemas.go @@ -23,6 +23,8 @@ type Schemas struct { ServiceBindings *Schema `json:"service_bindings,omitempty"` } +// Schema represents a plan's schemas for a create and update of an API +// resource. type Schema struct { Create interface{} `json:"create,omitempty"` Update interface{} `json:"update,omitempty"`