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

feat: add volume format property (#397) [Backport release-1.x] #444

Merged
merged 1 commit into from
May 22, 2024
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
1 change: 1 addition & 0 deletions hcloud/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ func VolumeFromSchema(s schema.Volume) *Volume {
Name: s.Name,
Location: LocationFromSchema(s.Location),
Size: s.Size,
Format: s.Format,
Status: VolumeStatus(s.Status),
LinuxDevice: s.LinuxDevice,
Protection: VolumeProtection{
Expand Down
1 change: 1 addition & 0 deletions hcloud/schema/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Volume struct {
Status string `json:"status"`
Location Location `json:"location"`
Size int `json:"size"`
Format *string `json:"format"`
Protection VolumeProtection `json:"protection"`
Labels map[string]string `json:"labels"`
LinuxDevice string `json:"linux_device"`
Expand Down
4 changes: 4 additions & 0 deletions hcloud/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,7 @@ func TestVolumeFromSchema(t *testing.T) {
"name": "db-storage",
"status": "creating",
"server": 2,
"format": "xfs",
"location": {
"id": 1,
"name": "fsn1",
Expand Down Expand Up @@ -1277,6 +1278,9 @@ func TestVolumeFromSchema(t *testing.T) {
if volume.Server != nil && volume.Server.ID != 2 {
t.Errorf("unexpected server ID: %v", volume.Server.ID)
}
if volume.Format == nil || *volume.Format != "xfs" {
t.Errorf("unexpected format: %v", volume.Format)
}
if volume.Location == nil || volume.Location.ID != 1 {
t.Errorf("unexpected location: %v", volume.Location)
}
Expand Down
6 changes: 6 additions & 0 deletions hcloud/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ type Volume struct {
Server *Server
Location *Location
Size int
Format *string
Protection VolumeProtection
Labels map[string]string
LinuxDevice string
Created time.Time
}

const (
VolumeFormatExt4 = "ext4"
VolumeFormatXFS = "xfs"
)

// VolumeProtection represents the protection level of a volume.
type VolumeProtection struct {
Delete bool
Expand Down
Loading