Skip to content

Commit

Permalink
add zone in requests
Browse files Browse the repository at this point in the history
  • Loading branch information
yfodil committed Jul 9, 2024
1 parent 2808572 commit f9f8fb7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions builder/scaleway/step_create_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (s *stepCreateServer) Run(ctx context.Context, state multistep.StateBag) mu
Name: c.ServerName,
Image: c.Image,
Tags: tags,
Zone: scw.Zone(c.Zone),
}

if c.ImageSizeInGB != 0 {
Expand Down
1 change: 1 addition & 0 deletions builder/scaleway/step_remove_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (s *stepRemoveVolume) Cleanup(state multistep.StateBag) {

err := instanceAPI.DeleteVolume(&instance.DeleteVolumeRequest{
VolumeID: volumeID,
Zone: scw.Zone(c.Zone),
})
if err != nil {
err := fmt.Errorf("error removing volume: %s", err)
Expand Down
2 changes: 2 additions & 0 deletions builder/scaleway/step_server_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ type stepServerInfo struct{}

func (s *stepServerInfo) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
instanceAPI := instance.NewAPI(state.Get("client").(*scw.Client))
c := state.Get("config").(*Config)
ui := state.Get("ui").(packersdk.Ui)
serverID := state.Get("server_id").(string)

ui.Say("Waiting for server to become active...")

instanceResp, err := instanceAPI.WaitForServer(&instance.WaitForServerRequest{
ServerID: serverID,
Zone: scw.Zone(c.Zone),
}, scw.WithContext(ctx))
if err != nil {
err := fmt.Errorf("error waiting for server to become booted: %s", err)
Expand Down
1 change: 1 addition & 0 deletions builder/scaleway/step_shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func (s *stepShutdown) Run(ctx context.Context, state multistep.StateBag) multis
_, err := instanceAPI.ServerAction(&instance.ServerActionRequest{
Action: instance.ServerActionPoweroff,
ServerID: serverID,
Zone: scw.Zone(c.Zone),
}, scw.WithContext(ctx))
if err != nil {
err := fmt.Errorf("error stopping server: %s", err)
Expand Down
3 changes: 3 additions & 0 deletions builder/scaleway/step_sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ func (s *stepSweep) Run(_ context.Context, _ multistep.StateBag) multistep.StepA
func (s *stepSweep) Cleanup(state multistep.StateBag) {
instanceAPI := instance.NewAPI(state.Get("client").(*scw.Client))
ui := state.Get("ui").(packersdk.Ui)
c := state.Get("config").(*Config)
snapshots := state.Get("snapshots").([]ArtifactSnapshot)
imageID := state.Get("image_id").(string)

ui.Say("Deleting Image...")

err := instanceAPI.DeleteImage(&instance.DeleteImageRequest{
ImageID: imageID,
Zone: scw.Zone(c.Zone),
})
if err != nil {
err := fmt.Errorf("error deleting image: %s", err)
Expand All @@ -39,6 +41,7 @@ func (s *stepSweep) Cleanup(state multistep.StateBag) {
for _, snapshot := range snapshots {
err = instanceAPI.DeleteSnapshot(&instance.DeleteSnapshotRequest{
SnapshotID: snapshot.ID,
Zone: scw.Zone(c.Zone),
})
if err != nil {
err := fmt.Errorf("error deleting snapshot: %s", err)
Expand Down

0 comments on commit f9f8fb7

Please sign in to comment.