hetznercloud / hcloud-go

A Go library for the Hetzner Cloud API
https://pkg.go.dev/github.com/hetznercloud/hcloud-go/v2/hcloud
MIT License
390 stars 45 forks source link

feat: use custom IDOrName type for schemas #545

Closed jooola closed 2 weeks ago

jooola commented 3 weeks ago

Add typing information to the fields that support passing either an ID as int, an ID as string or a Name as string. An empty value will be marshalled to null to reflect the behavior of an empty interface.

After this change, we do not have to cast IDs to float64 or to string to be able to read the values.

Since this is part of the schema package, this is not a breaking change for our customers, but might break our tests that rely on casting the interface to the desired type.

codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 94.44444% with 3 lines in your changes missing coverage. Please review.

Project coverage is 68.08%. Comparing base (9903f4d) to head (4b6096f). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
hcloud/schema/id_or_name.go 92.50% 2 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #545 +/- ## ========================================== + Coverage 67.71% 68.08% +0.36% ========================================== Files 46 47 +1 Lines 4882 4900 +18 ========================================== + Hits 3306 3336 +30 + Misses 1166 1158 -8 + Partials 410 406 -4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.