From c0940afce9eb01c0e6838502c91aa569ab411a03 Mon Sep 17 00:00:00 2001 From: phm07 <22707808+phm07@users.noreply.github.com> Date: Thu, 7 Mar 2024 15:29:45 +0100 Subject: [PATCH] feat: add volume format property (#397) This property was previously missing, although it was already used in VolumeCreateOpts. It's now a string pointer with common values (ext4 and xfs) available as string constants. --------- Co-authored-by: pauhull <22707808+pauhull@users.noreply.github.com> Co-authored-by: Jonas L. --- hcloud/schema/volume.go | 1 + hcloud/schema_test.go | 1 + hcloud/volume.go | 6 ++++++ hcloud/zz_schema.go | 2 ++ 4 files changed, 10 insertions(+) diff --git a/hcloud/schema/volume.go b/hcloud/schema/volume.go index 0dd391bc..1de64595 100644 --- a/hcloud/schema/volume.go +++ b/hcloud/schema/volume.go @@ -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"` diff --git a/hcloud/schema_test.go b/hcloud/schema_test.go index 73bf4f66..c28938e8 100644 --- a/hcloud/schema_test.go +++ b/hcloud/schema_test.go @@ -662,6 +662,7 @@ func TestVolumeSchema(t *testing.T) { "name": "db-storage", "status": "creating", "server": 2, + "format": "xfs", "location": { "id": 1, "name": "fsn1", diff --git a/hcloud/volume.go b/hcloud/volume.go index 3f23c6da..c744b5a8 100644 --- a/hcloud/volume.go +++ b/hcloud/volume.go @@ -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 diff --git a/hcloud/zz_schema.go b/hcloud/zz_schema.go index 5b593e42..64a16fd8 100755 --- a/hcloud/zz_schema.go +++ b/hcloud/zz_schema.go @@ -1215,6 +1215,7 @@ func (c *converterImpl) SchemaFromVolume(source *Volume) schema.Volume { schemaVolume2.Status = string((*source).Status) schemaVolume2.Location = c.SchemaFromLocation((*source).Location) schemaVolume2.Size = (*source).Size + schemaVolume2.Format = (*source).Format schemaVolume2.Protection = c.hcloudVolumeProtectionToSchemaVolumeProtection((*source).Protection) schemaVolume2.Labels = (*source).Labels schemaVolume2.LinuxDevice = (*source).LinuxDevice @@ -1397,6 +1398,7 @@ func (c *converterImpl) VolumeFromSchema(source schema.Volume) *Volume { hcloudVolume.Server = pHcloudServer hcloudVolume.Location = c.LocationFromSchema(source.Location) hcloudVolume.Size = source.Size + hcloudVolume.Format = source.Format hcloudVolume.Protection = c.schemaVolumeProtectionToHcloudVolumeProtection(source.Protection) hcloudVolume.Labels = source.Labels hcloudVolume.LinuxDevice = source.LinuxDevice