From 1eb40e22b2d2b18e843f97aff2f2797812097438 Mon Sep 17 00:00:00 2001 From: Andrea Cedraro Date: Mon, 6 Nov 2023 23:13:36 +0100 Subject: [PATCH] Check InitSleep validity before spawning the container --- builder/lxd/step_lxd_launch.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/builder/lxd/step_lxd_launch.go b/builder/lxd/step_lxd_launch.go index 406e83a..5307573 100644 --- a/builder/lxd/step_lxd_launch.go +++ b/builder/lxd/step_lxd_launch.go @@ -33,17 +33,18 @@ func (s *stepLxdLaunch) Run(ctx context.Context, state multistep.StateBag) multi launch_args = append(launch_args, "--config", fmt.Sprintf("%s=%s", k, v)) } - ui.Say("Creating container...") - _, err := LXDCommand(launch_args...) + sleep_seconds, err := strconv.Atoi(config.InitSleep) if err != nil { - err := fmt.Errorf("Error creating container: %s", err) + err := fmt.Errorf("Error parsing InitSleep into int: %s", err) state.Put("error", err) ui.Error(err.Error()) return multistep.ActionHalt } - sleep_seconds, err := strconv.Atoi(config.InitSleep) + + ui.Say("Creating container...") + _, err = LXDCommand(launch_args...) if err != nil { - err := fmt.Errorf("Error parsing InitSleep into int: %s", err) + err := fmt.Errorf("Error creating container: %s", err) state.Put("error", err) ui.Error(err.Error()) return multistep.ActionHalt