return early if no set visibility

This commit is contained in:
Matthew Hooker 2016-12-13 16:32:15 -08:00
parent 99667df17e
commit cbe7e9113a
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
1 changed files with 24 additions and 22 deletions

View File

@ -15,13 +15,16 @@ func (s *stepUpdateImageVisibility) Run(state multistep.StateBag) multistep.Step
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
config := state.Get("config").(Config) config := state.Get("config").(Config)
if config.ImageVisibility != "" { if config.ImageVisibility == "" {
return multistep.ActionContinue
}
imageClient, err := config.imageV2Client() imageClient, err := config.imageV2Client()
if err != nil { if err != nil {
err = fmt.Errorf("Error initializing image service client: %s", err) err = fmt.Errorf("Error initializing image service client: %s", err)
state.Put("error", err) state.Put("error", err)
return multistep.ActionHalt return multistep.ActionHalt
} }
ui.Say(fmt.Sprintf("Updating image visibility to %s", config.ImageVisibility)) ui.Say(fmt.Sprintf("Updating image visibility to %s", config.ImageVisibility))
r := imageservice.Update( r := imageservice.Update(
imageClient, imageClient,
@ -32,14 +35,13 @@ func (s *stepUpdateImageVisibility) Run(state multistep.StateBag) multistep.Step
}, },
}, },
) )
if _, err = r.Extract(); err != nil { if _, err = r.Extract(); err != nil {
err = fmt.Errorf("Error updating image visibility: %s", err) err = fmt.Errorf("Error updating image visibility: %s", err)
state.Put("error", err) state.Put("error", err)
return multistep.ActionHalt return multistep.ActionHalt
} }
}
return multistep.ActionContinue return multistep.ActionContinue
} }