diff --git a/.web-docs/components/builder/scaleway/README.md b/.web-docs/components/builder/scaleway/README.md index 06b85de..5d15e53 100644 --- a/.web-docs/components/builder/scaleway/README.md +++ b/.web-docs/components/builder/scaleway/README.md @@ -142,6 +142,8 @@ can also be supplied to override the typical auto-generated key: - `size` (uint64) - Size of the newly created volume +- `iops` (\*uint32) - IOPS is the number of requested iops for the server's volume. This will not impact created snapshot. + diff --git a/builder/scaleway/config.go b/builder/scaleway/config.go index e1d0a9f..8337a4f 100644 --- a/builder/scaleway/config.go +++ b/builder/scaleway/config.go @@ -37,6 +37,8 @@ type ConfigBlockVolume struct { SnapshotID string `mapstructure:"snapshot_id"` // Size of the newly created volume Size uint64 `mapstructure:"size"` + // IOPS is the number of requested iops for the server's volume. This will not impact created snapshot. + IOPS *uint32 `mapstructure:"iops"` } type Config struct { diff --git a/builder/scaleway/config.hcl2spec.go b/builder/scaleway/config.hcl2spec.go index 6d611bf..18e888f 100644 --- a/builder/scaleway/config.hcl2spec.go +++ b/builder/scaleway/config.hcl2spec.go @@ -200,6 +200,7 @@ type FlatConfigBlockVolume struct { Name *string `mapstructure:"name" cty:"name" hcl:"name"` SnapshotID *string `mapstructure:"snapshot_id" cty:"snapshot_id" hcl:"snapshot_id"` Size *uint64 `mapstructure:"size" cty:"size" hcl:"size"` + IOPS *uint32 `mapstructure:"iops" cty:"iops" hcl:"iops"` } // FlatMapstructure returns a new FlatConfigBlockVolume. @@ -217,6 +218,7 @@ func (*FlatConfigBlockVolume) HCL2Spec() map[string]hcldec.Spec { "name": &hcldec.AttrSpec{Name: "name", Type: cty.String, Required: false}, "snapshot_id": &hcldec.AttrSpec{Name: "snapshot_id", Type: cty.String, Required: false}, "size": &hcldec.AttrSpec{Name: "size", Type: cty.Number, Required: false}, + "iops": &hcldec.AttrSpec{Name: "iops", Type: cty.Number, Required: false}, } return s } diff --git a/builder/scaleway/step_backup.go b/builder/scaleway/step_backup.go index ab1c1b1..8bc68be 100644 --- a/builder/scaleway/step_backup.go +++ b/builder/scaleway/step_backup.go @@ -99,9 +99,7 @@ func backupVolumesFromServer(server *instance.Server) map[string]*instance.Serve backupVolumes := map[string]*instance.ServerActionRequestVolumeBackupTemplate{} for _, volume := range server.Volumes { - backupVolumes[volume.ID] = &instance.ServerActionRequestVolumeBackupTemplate{ - //VolumeType: instance.SnapshotVolumeTypeUnified, - } + backupVolumes[volume.ID] = &instance.ServerActionRequestVolumeBackupTemplate{} } return backupVolumes } diff --git a/builder/scaleway/step_create_volume.go b/builder/scaleway/step_create_volume.go index e222387..910cf32 100644 --- a/builder/scaleway/step_create_volume.go +++ b/builder/scaleway/step_create_volume.go @@ -24,17 +24,20 @@ func (s *stepCreateVolume) Run(ctx context.Context, state multistep.StateBag) mu volumeTemplates := []*instance.VolumeServerTemplate(nil) for _, requestedVolume := range c.BlockVolumes { - volume, err := blockAPI.CreateVolume(&block.CreateVolumeRequest{ + req := &block.CreateVolumeRequest{ Zone: scw.Zone(c.Zone), Name: requestedVolume.Name, - PerfIops: scw.Uint32Ptr(5000), // TODO: configuration + PerfIops: requestedVolume.IOPS, ProjectID: c.ProjectID, - FromEmpty: &block.CreateVolumeRequestFromEmpty{ + } + if requestedVolume.SnapshotID != "" { + req.FromSnapshot = &block.CreateVolumeRequestFromSnapshot{} + } else { + req.FromEmpty = &block.CreateVolumeRequestFromEmpty{ Size: scw.Size(requestedVolume.Size), - }, - FromSnapshot: nil, // TODO - Tags: nil, // TODO - }, scw.WithContext(ctx)) + } + } + volume, err := blockAPI.CreateVolume(req, scw.WithContext(ctx)) if err != nil { state.Put("error", err) ui.Error(err.Error()) diff --git a/docs-partials/builder/scaleway/ConfigBlockVolume-not-required.mdx b/docs-partials/builder/scaleway/ConfigBlockVolume-not-required.mdx index 41b9919..d39cea0 100644 --- a/docs-partials/builder/scaleway/ConfigBlockVolume-not-required.mdx +++ b/docs-partials/builder/scaleway/ConfigBlockVolume-not-required.mdx @@ -6,4 +6,6 @@ - `size` (uint64) - Size of the newly created volume +- `iops` (\*uint32) - IOPS is the number of requested iops for the server's volume. This will not impact created snapshot. +