result, err := crdclient.Create(example)
if err == nil {
fmt.Printf("CREATED: %#v\n", result)
} else if apierrors.IsAlreadyExists(err) {
fmt.Printf("ALREADY EXISTS: %#v\n", result)
} else {
panic(err)
}
// List all Example objects
items, err := crdclient.List(meta_v1.ListOptions{})
if err != nil {
panic(err)
}
fmt.Printf("List:\n%s\n", items)
result, err = crdclient.Get("example123")
if err != nil {
panic(err)
}
fmt.Printf("Get:\n%v\n", result)
result.Status.Message = "Hello There"
fmt.Println("\n Result is: %v \n", result)
up, uperr := crdclient.Update(result)
if uperr != nil {
panic(uperr)
}
In the above example for CRD with kubernetes API I get the error. "In Update call panic: name must be provided"
What am I missing? The code is based out the sample given @ https://github.com/yaronha/kube-crd
I looked at the code, you need to update the Update API in the client.go file with the following code:
func (f *crdclient) Update(obj *crd.Example) (*crd.Example, error) {
var result crd.Example
err := f.cl.Put().
Namespace(f.ns).Resource(f.plural).
Name(obj.Name).
Body(obj).Do().Into(&result)
return &result, err
}
After that your code should be working as expected.