Skip to content

Commit

Permalink
[Backport release-1.x] feat(iso): support deprecation info API (#333)
Browse files Browse the repository at this point in the history
Backport b3a3621 from #331.

Co-authored-by: Julian Tölle <julian.toelle@hetzner-cloud.de>
  • Loading branch information
github-actions[bot] and apricote authored Oct 12, 2023
1 parent f2d5292 commit 5f89c57
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
9 changes: 3 additions & 6 deletions hcloud/iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ type ISO struct {
Description string
Type ISOType
Architecture *Architecture
Deprecated time.Time
}

// IsDeprecated returns true if the ISO is deprecated.
func (iso *ISO) IsDeprecated() bool {
return !iso.Deprecated.IsZero()
// Deprecated: Use [ISO.Deprecation] instead.
Deprecated time.Time
DeprecatableResource
}

// ISOType specifies the type of an ISO image.
Expand Down
2 changes: 1 addition & 1 deletion hcloud/iso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestISOIsDeprecated(t *testing.T) {

t.Run("deprecated", func(t *testing.T) {
iso := &ISO{
Deprecated: time.Now(),
DeprecatableResource: DeprecatableResource{Deprecation: &DeprecationInfo{Announced: time.Now()}},
}
if !iso.IsDeprecated() {
t.Errorf("unexpected value for IsDeprecated: %v", iso.IsDeprecated())
Expand Down
3 changes: 3 additions & 0 deletions hcloud/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ func ISOFromSchema(s schema.ISO) *ISO {
Description: s.Description,
Type: ISOType(s.Type),
Deprecated: s.Deprecated,
DeprecatableResource: DeprecatableResource{
DeprecationFromSchema(s.Deprecation),
},
}
if s.Architecture != nil {
iso.Architecture = Ptr(Architecture(*s.Architecture))
Expand Down
1 change: 1 addition & 0 deletions hcloud/schema/iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type ISO struct {
Type string `json:"type"`
Architecture *string `json:"architecture"`
Deprecated time.Time `json:"deprecated"`
DeprecatableResource
}

// ISOGetResponse defines the schema of the response when retrieving a single ISO.
Expand Down

0 comments on commit 5f89c57

Please sign in to comment.