Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListKubernetesClusters isn't returning the new ClusterType field #138

Open
hookenz opened this issue Mar 5, 2023 · 1 comment
Open

ListKubernetesClusters isn't returning the new ClusterType field #138

hookenz opened this issue Mar 5, 2023 · 1 comment

Comments

@hookenz
Copy link
Contributor

hookenz commented Mar 5, 2023

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"
  }
]

@uzaxirr
Copy link
Member

uzaxirr commented Feb 6, 2024

This issue should be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants