Open drewmullen opened 3 months ago
When trying to use the client to query for a list of VMs, marshaling fails due to a series of fields missing from the object struct (example code at bottom):
$ go run main.go panic: json: unknown field "annotations"
Generated object (missing fields): https://github.com/drewmullen/harvester-go-sdk/blob/main/model_k8s_io_v1_object_meta.go#L21-L26
swagger spec (missing fields): https://github.com/harvester/harvester/blob/master/api/openapi-spec/swagger.json#L10547-L10555
should have many other fields, such as annotations (complete field list): https://github.com/harvester/harvester/blob/master/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types.go#L111-L272
annotations
package main import ( "context" "fmt" "os" openapiclient "github.com/drewmullen/harvester-go-sdk" ) func main() { api_token, server_url, namespace := os.Getenv("HARVESTER_API_TOKEN"), os.Getenv("HARVESTER_SERVER_URL"), os.Getenv("HARVESTER_NAMESPACE") if namespace == "" { namespace = "default" } if server_url == "" { fmt.Print("HARVESTER_SERVER_URL is not set") os.Exit(1) } if api_token == "" { fmt.Print("HARVESTER_API_TOKEN is not set") os.Exit(1) } configuration := &openapiclient.Configuration{ DefaultHeader: make(map[string]string), UserAgent: "OpenAPI-Generator/1.0.0/go", Debug: false, Servers: openapiclient.ServerConfigurations{ { URL: server_url, Description: "Harvester API Server", }, }, } auth := context.WithValue(context.Background(), openapiclient.ContextAccessToken, api_token) apiClient := openapiclient.NewAPIClient(configuration) resp, r, err := apiClient.VirtualMachinesAPI.ListNamespacedVirtualMachine(auth, namespace).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `VirtualMachinesAPI.ListNamespacedVirtualMachine``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } // response from `ListNamespacedVirtualMachine`: KubevirtIoApiCoreV1VirtualMachineList fmt.Fprintf(os.Stdout, "Response from `VirtualMachinesAPI.ListNamespacedVirtualMachine`: %v\n", resp) }
fixed by: https://github.com/harvester/harvester/pull/5512
When trying to use the client to query for a list of VMs, marshaling fails due to a series of fields missing from the object struct (example code at bottom):
Generated object (missing fields): https://github.com/drewmullen/harvester-go-sdk/blob/main/model_k8s_io_v1_object_meta.go#L21-L26
swagger spec (missing fields): https://github.com/harvester/harvester/blob/master/api/openapi-spec/swagger.json#L10547-L10555
should have many other fields, such as
annotations
(complete field list): https://github.com/harvester/harvester/blob/master/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types.go#L111-L272