canonical / gomaasclient

Go MAAS client
Apache License 2.0
19 stars 27 forks source link

Incorrect Struct Tag Results in Missing Values in Request #5

Closed MrFlynn closed 8 months ago

MrFlynn commented 2 years ago

Hello,

While using this library, I encountered an issue caused by this omitempty tag. If the Commission field is set to false, the querystring library will exclude this key-value pair from the resulting query parameters.

https://github.com/maas/gomaasclient/blob/14c6f5604abb9429d1a31aea883365656eaee635/entity/machine.go#L110

Creating a machine without automatically commissioning it is a valid action, so removing the omitempty would be necessary to make the library compliant with that behavior.

SK1Y101 commented 1 year ago

Hey @MrFlynn. Have you tried creating a machine with your changes in place? if so: did it fix the issue you've highlighted?

If you create a PR with the changes we could get it reviewed.

MrFlynn commented 1 year ago

It's been about a year since I filed this issue, so I might be misremembering, but as I recall I passed the commission value through the powerParams map in Machines.Create since that allowed me to set the value properly.

skatsaounis commented 8 months ago

Hi @MrFlynn,

As you can observe in the MAAS codebase here, the default value for commission is false, if it is not set in the parameters. As a result, it is fine to exclude it with omitempty if user has not set it, or it is set to false. Thank you for opening the issue in the first place and also coming back to respond. I will close this issue and if you encounter any problem with the latest release of gomaasclient please let us know. :slightly_smiling_face: