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

[Backport release-1.x] feat(iso): support deprecation info API #333

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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