Skip to content

Commit 5f89c57

Browse files
[Backport release-1.x] feat(iso): support deprecation info API (#333)
Backport b3a3621 from #331. Co-authored-by: Julian Tölle <[email protected]>
1 parent f2d5292 commit 5f89c57

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

hcloud/iso.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ type ISO struct {
1717
Description string
1818
Type ISOType
1919
Architecture *Architecture
20-
Deprecated time.Time
21-
}
22-
23-
// IsDeprecated returns true if the ISO is deprecated.
24-
func (iso *ISO) IsDeprecated() bool {
25-
return !iso.Deprecated.IsZero()
20+
// Deprecated: Use [ISO.Deprecation] instead.
21+
Deprecated time.Time
22+
DeprecatableResource
2623
}
2724

2825
// ISOType specifies the type of an ISO image.

hcloud/iso_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestISOIsDeprecated(t *testing.T) {
2020

2121
t.Run("deprecated", func(t *testing.T) {
2222
iso := &ISO{
23-
Deprecated: time.Now(),
23+
DeprecatableResource: DeprecatableResource{Deprecation: &DeprecationInfo{Announced: time.Now()}},
2424
}
2525
if !iso.IsDeprecated() {
2626
t.Errorf("unexpected value for IsDeprecated: %v", iso.IsDeprecated())

hcloud/schema.go

+3
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ func ISOFromSchema(s schema.ISO) *ISO {
124124
Description: s.Description,
125125
Type: ISOType(s.Type),
126126
Deprecated: s.Deprecated,
127+
DeprecatableResource: DeprecatableResource{
128+
DeprecationFromSchema(s.Deprecation),
129+
},
127130
}
128131
if s.Architecture != nil {
129132
iso.Architecture = Ptr(Architecture(*s.Architecture))

hcloud/schema/iso.go

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type ISO struct {
1010
Type string `json:"type"`
1111
Architecture *string `json:"architecture"`
1212
Deprecated time.Time `json:"deprecated"`
13+
DeprecatableResource
1314
}
1415

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

0 commit comments

Comments
 (0)