Skip to content

ListKubernetesClusters isn't returning the new ClusterType field #138

@hookenz

Description

@hookenz

ClusterType is not being populated after calling ListAllKubernetesVersions. This means it's not possible to know what ClusterType to use when provisioning specific versions. We need this fix to correctly provision CIVO clusters in Portainer.

The problem is caused by the json tag on the KubernetesVersion type

It should be

ClusterType string `json:"clusterType,omitempty"

and not

ClusterType string `json:"cluster_type,omitempty"`

The rules of naming being.

To unmarshal JSON into a struct, Unmarshal matches incoming object keys to the keys used by Marshal (either the struct field name or its tag), preferring an exact match but also accepting a case-insensitive match. By default, object keys which don't have a corresponding struct field are ignored (see Decoder.DisallowUnknownFields for an alternative).

In the case above, it uses the case-insensitive match. All the other fields following the same pattern even thought the API returns Pascal case field names.

example response from the versions API.

[
  {
    "Label": "1.22.2-k3s1",
    "Release": "1.22.2+k3s1",
    "Version": "1.22.2-k3s1",
    "Type": "deprecated",
    "Default": false,
    "ClusterType": "k3s"
  },
  {
    "Label": "1.20.2-k3s1",
    "Release": "1.20.2+k3s1",
    "Version": "1.20.2-k3s1",
    "Type": "deprecated",
    "Default": false,
    "ClusterType": "k3s"
  },
  {
    "Label": "1.21.2-k3s1",
    "Release": "1.21.2+k3s1",
    "Version": "1.21.2-k3s1",
    "Type": "deprecated",
    "Default": false,
    "ClusterType": "k3s"
  },
  {
    "Label": "1.24.4-k3s1",
    "Release": "1.24.4+k3s1",
    "Version": "1.24.4-k3s1",
    "Type": "development",
    "Default": false,
    "ClusterType": "k3s"
  },
  {
    "Label": "1.22.11-k3s1",
    "Release": "1.22.11+k3s1",
    "Version": "1.22.11-k3s1",
    "Type": "deprecated",
    "Default": false,
    "ClusterType": "k3s"
  },
  {
    "Label": "1.23.6-k3s1",
    "Release": "1.23.6+k3s1",
    "Version": "1.23.6-k3s1",
    "Type": "stable",
    "Default": true,
    "ClusterType": "k3s"
  },
  {
    "Label": "talos-v1.2.8",
    "Release": "1.2.8",
    "Version": "1.25.5",
    "Type": "stable",
    "Default": true,
    "ClusterType": "talos"
  },
  {
    "Label": "1.25.0-k3s1",
    "Release": "1.25.0+k3s1",
    "Version": "1.25.0-k3s1",
    "Type": "development",
    "Default": false,
    "ClusterType": "k3s"
  },
  {
    "Label": "1.20.0-k3s1",
    "Release": "1.20.0+k3s1",
    "Version": "1.20.0-k3s1",
    "Type": "deprecated",
    "Default": false,
    "ClusterType": "k3s"
  }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions