Skip to content

Instantly share code, notes, and snippets.

@indradhanush
Created April 3, 2018 05:34
Show Gist options
  • Save indradhanush/deac6e9407284fa3eadfcd51d7e584ad to your computer and use it in GitHub Desktop.
Save indradhanush/deac6e9407284fa3eadfcd51d7e584ad to your computer and use it in GitHub Desktop.
Test unmarshalling OSB spec
package main
import (
"fmt"
"os"
// osb "github.com/pmorie/go-open-service-broker-client/v2"
"github.com/pmorie/osb-broker-lib/pkg/broker"
"gopkg.in/yaml.v2"
)
func main() {
data := `
---
services:
- name: redis-habitat
id: 50e86479-4c66-4236-88fb-a1e61b4c9448
description: Redis packaged with Habitat
bindable: false
plan_updateable: false
metadata:
displayName: "Habitat Redis service"
imageUrl: https://avatars2.githubusercontent.com/u/19862012?s=200&v=4
plans:
- name: default
id: 002341cf-f895-49f4-ba04-bb70291b895c
description: The default plan for the Redis Habitat example service
free: true
schemas:
service_instance:
create:
"$schema": "http://json-schema.org/draft-04/schema"
"type": "object"
"title": "Parameters"
"properties":
- "name":
"title": "Some Name"
"type": "string"
"maxLength": 63
"default": "My Name"
- "color":
"title": "Color"
"type": "string"
"default": "Clear"
"enum":
- "Clear"
- "Beige"
- "Grey"
`
response := &broker.CatalogResponse{}
// response = &osb.CatalogResponse{}
err := yaml.Unmarshal([]byte(data), &response)
if err != nil {
fmt.Printf("Error: %q", err)
os.Exit(1)
}
fmt.Printf("Struct: %#+v", response)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment