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

Commit

Permalink
backend changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pmorie committed May 18, 2017
1 parent 86fae52 commit 512bd1a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pkg/brokerapi/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
35 changes: 35 additions & 0 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1734,6 +1734,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
Expand All @@ -1749,6 +1750,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
}
Expand Down

0 comments on commit 512bd1a

Please sign in to comment.