apache / cloudstack-go

CloudStack Go SDK

Home Page:https://cloudstack.apache.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GetKubernetesClusterConfigResponse is incorrect resulting in empty parsing

saffronjam opened this issue · comments

type GetKubernetesClusterConfigResponse struct {
	Configdata string `json:"configdata"`
	Id         string `json:"id"`
	JobID      string `json:"jobid"`
	Jobstatus  int    `json:"jobstatus"`
	Name       string `json:"name"`
}

Should be:

type GetKubernetesClusterConfigResponse struct {
	ClusterConfig struct {
		Configdata string `json:"configdata"`
		Id         string `json:"id"`
		JobID      string `json:"jobid"`
		Jobstatus  int    `json:"jobstatus"`
		Name       string `json:"name"`
	} `json:"clusterconfig"`
}

Since the response is this (showing only the start since that is the only relevant part):
image

CloudStack version: 4.18

Thanks for reporting @saffronjam any PRs are welcome, I've also pinged @shwstppr to investigate and advise.

Hi! I have now provided a PR to fix this (that also added the missing test-data for the getKubernetesClusterConfig)

For visibility, my comments from the base cloudstack issue:

I checked three different 'get' APIs via the golang client and they all either unmarshaled to an empty struct (since the response didn't match the struct), or threw an unmarshal error.

There's no formulaic way to determine what this base key should be, for getPathForVolume it is apipathforvolume. For getCloudIdentifier it is cloudidentifier, for getKubernetesClusterConfig it is clusterconfig.

We can enhance listApis possibly in CloudStack to return these properly, though looking through the code it is not straightforward to discover these so in the interim we may be able to create special handling for "get" APIs and just code in the variances.

For example in the getKubernetesClusterConfig the "clusterconfig" key is being set dynamically here rather than something that is discoverable.

For getCloudIdentifier it is set here