-
Notifications
You must be signed in to change notification settings - Fork 80
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
Inconsistent resource objects when output format is json #461
Comments
This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs. |
This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs. |
phm07
added a commit
to hetznercloud/hcloud-go
that referenced
this issue
Dec 12, 2023
This PR adds automatic generation of schema conversion methods in `schema.go` with [goverter](https://github.com/jmattheis/goverter). Previously, `schema.go` was manually written. This is a tedious task and is also prone to errors. This PR also adds new methods to convert `hcloud` objects back into schemas. This allows for round trip testing (converting `schema -> hcloud -> schema` or `hcloud -> schema -> hcloud` and testing for equality) and allows for removal of redundant code in [hcloud/cli](https://github.com/hetznercloud/cli). Since the round trip tests ensure that a schema converts into an `hcloud` object and back, formatting will be consistent between conversions. This would fix issues like hetznercloud/cli#461.
phm07
added a commit
to hetznercloud/hcloud-go
that referenced
this issue
Dec 12, 2023
In some places the schema definitions are not consistent with the API documentation, for example properties may not have pointer receivers even though they are marked as optional in the documentation. This results in inconsistent JSON when converting `JSON -> Schema -> JSON` (as seen for example in hetznercloud/cli#461, where one output is the exact API response and one is serialized and then converted back to JSON). This PR aims to fix this issue by making the schema definitions consistent.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When setting the output format to json, the resource object is rendered differently between the corresponding
list
anddescribe
command.The following json output is just an example, this behaviour is not limited to the iso resource.
After digging a bit into this, I noticed that a ListCmd has a
JSONSchema
attribute which converts the resource into a hcloud-go api schema object before decoding it into a JSON string. In contrast theDescribeCmd
just decodes the resource object directly.The text was updated successfully, but these errors were encountered: