Skip to content

Commit

Permalink
fix: primary ip assignee id not mapped to nil (#395)
Browse files Browse the repository at this point in the history
See hetznercloud/cli#701

Co-authored-by: pauhull <[email protected]>
  • Loading branch information
phm07 and phm07 authored Mar 5, 2024
1 parent 0f187ce commit b5fea38
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hcloud/schema/primary_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type PrimaryIP struct {
Type string `json:"type"`
Protection PrimaryIPProtection `json:"protection"`
DNSPtr []PrimaryIPDNSPTR `json:"dns_ptr"`
AssigneeID int64 `json:"assignee_id"`
AssigneeID *int64 `json:"assignee_id"`
AssigneeType string `json:"assignee_type"`
AutoDelete bool `json:"auto_delete"`
Blocked bool `json:"blocked"`
Expand Down
8 changes: 8 additions & 0 deletions hcloud/schema_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ type converter interface {
PrimaryIPFromSchema(schema.PrimaryIP) *PrimaryIP

// goverter:map . IP | primaryIPToIPString
// goverter:map AssigneeID | mapZeroInt64ToNil
SchemaFromPrimaryIP(*PrimaryIP) schema.PrimaryIP

ISOFromSchema(schema.ISO) *ISO
Expand Down Expand Up @@ -874,6 +875,13 @@ func stringPtrFromNetworkZone(z NetworkZone) *string {
return mapEmptyStringToNil(string(z))
}

func mapZeroInt64ToNil(i int64) *int64 {
if i == 0 {
return nil
}
return &i
}

func mapZeroUint64ToNil(i uint64) *uint64 {
if i == 0 {
return nil
Expand Down
8 changes: 6 additions & 2 deletions hcloud/zz_schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b5fea38

Please sign in to comment.