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

fix: make JSON/YAML outputs consistent #622

Merged
merged 1 commit into from
Dec 13, 2023
Merged

fix: make JSON/YAML outputs consistent #622

merged 1 commit into from
Dec 13, 2023

Conversation

phm07
Copy link
Contributor

@phm07 phm07 commented Dec 7, 2023

This PR utilizes the new hcloud -> schema conversion methods introduced in hetznercloud/hcloud-go#343 to reduce boilerplate code and enforce consistent schema conversions (in combination with hetznercloud/hcloud-go#349 & hetznercloud/hcloud-go#348)

Fixes #461

@phm07 phm07 added the refactor label Dec 7, 2023
@phm07 phm07 self-assigned this Dec 7, 2023
@apricote
Copy link
Member

apricote commented Dec 7, 2023

Looks very nice already! I noticed that all JSONOutput methods are now basically the same, besides the method they are calling. Could we extract this into ListCmd to reduce the individual code even further?

@phm07
Copy link
Contributor Author

phm07 commented Dec 12, 2023

I don't think this is possible. You would need generic structs and generic type casts, none of which is possible in Go as of now.

@phm07 phm07 changed the title refactor: use new conversion methods in hcloud-go fix: make schema outputs consistent Dec 13, 2023
@phm07 phm07 marked this pull request as ready for review December 13, 2023 09:20
@phm07 phm07 requested a review from a team as a code owner December 13, 2023 09:20
Copy link

codecov bot commented Dec 13, 2023

Codecov Report

Attention: 17 lines in your changes are missing coverage. Please review.

Comparison is base (2ab9ce3) 43.75% compared to head (b8ef894) 46.27%.

Files Patch % Lines
internal/cmd/firewall/list.go 0.00% 2 Missing ⚠️
internal/cmd/certificate/list.go 0.00% 1 Missing ⚠️
internal/cmd/datacenter/list.go 0.00% 1 Missing ⚠️
internal/cmd/floatingip/list.go 0.00% 1 Missing ⚠️
internal/cmd/image/list.go 0.00% 1 Missing ⚠️
internal/cmd/iso/list.go 0.00% 1 Missing ⚠️
internal/cmd/loadbalancer/list.go 0.00% 1 Missing ⚠️
internal/cmd/loadbalancertype/list.go 0.00% 1 Missing ⚠️
internal/cmd/location/list.go 0.00% 1 Missing ⚠️
internal/cmd/network/list.go 0.00% 1 Missing ⚠️
... and 6 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #622      +/-   ##
==========================================
+ Coverage   43.75%   46.27%   +2.51%     
==========================================
  Files         171      171              
  Lines        7885     7456     -429     
==========================================
  Hits         3450     3450              
+ Misses       4012     3583     -429     
  Partials      423      423              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@apricote apricote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename this PR to change schema to json/yaml? Not all users know the implementation details

@phm07 phm07 changed the title fix: make schema outputs consistent fix: make JSON/YAML outputs consistent Dec 13, 2023
@phm07 phm07 merged commit 43944b8 into main Dec 13, 2023
3 checks passed
@phm07 phm07 deleted the goverter branch December 13, 2023 09:57
phm07 pushed a commit that referenced this pull request Dec 13, 2023
🤖 I have created a release *beep* *boop*
---


##
[1.41.0](v1.40.0...v1.41.0)
(2023-12-13)


### Features

* allow YAML output
([#628](#628))
([87552d2](87552d2))
* **server:** allow to filter list by server status
([#629](#629))
([1cb51f2](1cb51f2)),
closes [#623](#623)


### Bug Fixes

* make JSON/YAML outputs consistent
([#622](#622))
([43944b8](43944b8))
* **server:** properly format request-console JSON output
([#626](#626))
([40641b6](40641b6))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent resource objects when output format is json
2 participants