equinix-labs / metal-go

[Deprecated] Golang client for Equinix Metal
https://deploy.equinix.com/labs/equinix-sdk-go/
MIT License
3 stars 2 forks source link

fix: remove plan drive type and nic type enums #156

Closed ctreatma closed 1 year ago

ctreatma commented 1 year ago

The previous fix for plan drive type did not work; it turns out that the API plan data includes plans with drive type NVMe and plans with drive type NVME. As mentioned on the previous PR, adding both options to the enum generates invalid code, and we don't have a practical way to enable case-insensitive comparisons for string enums.

Reverting the plan drive type to a plain string uncovered a different issue with the nic type enum: some plans (storage type, possibly others) include the following for drives and nics:

                "drives": [
                    {
                        "count": 0,
                        "size": "",
                        "type": ""
                    }
                ],
                "nics": [
                    {
                        "count": 0,
                        "type": ""
                    }
                ]

Rather than test nullable: true here, I opted to change the nic type to a plain string as well.

ctreatma commented 1 year ago

In terms of data quality, I think the values we're seeing for drive type and nic type indicate that 2 long-term fixes are needed:

  1. The fact that both NVMe and NVME exist as drive types indicates a lack of input validation and/or data normalization in the API; if the spec says NVME then NVMe should be rejected as an input, or at least the API should convert the drive type to uppercase in response JSON
  2. For plans that have no drives or no nics, it would be better to return an empty array (drives: []) or omit the field entirely
displague commented 1 year ago

Bye, enums 😢 (I wonder if Redoc x- extensions offer a way to list the likely values)

github-actions[bot] commented 1 year ago

This PR is included in version 0.22.2 :tada: