- install all crd files by
make install
go run pkg/examples/extendworkload/main.go
When we install component.yaml
, we will get such output:
2019-12-23T16:12:31.720+0800 INFO setup hello oam from pre hook: comp
settings: {"Description":"xxx","Protocol":"Example","Type":"Performance"}
Description: xxx
Protocol: Example
Type: Performance
Raw json data is stored in component.Spec.WorkloadSettings.Raw
. In fact you could get the real type.
You could see our workloadType in pkg/examples/extendworkload/workloadtype.yaml
, our schema is:
{
"$schema":"http://json-schema.org/draft-07/schema#",
"type":"object",
"description":"",
"required":[
"Protocol"
],
"properties":{
"Protocol":{
"type":"string",
"description":""
},
"Type":{
"type":"string",
"description":""
},
"Description":{
"type":"string",
"description":""
}
}
}
So we could use map[string]interface{}
to parse our output, so we could get more concrete data struct.
kubectl apply -f pkg/examples/extendworkload/new-crd.yaml
go run main.go --new-crd=true
kubectl apply -f pkg/examples/extendworkload/app-new-crd.yaml