Skip to content

Commit

Permalink
try it the ugly way, to see if it work
Browse files Browse the repository at this point in the history
Signed-off-by: matthias.gatto <matthias.gatto@outscale.com>
  • Loading branch information
outscale-mgo committed Jun 11, 2024
1 parent 8a4a37e commit 344cca4
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion builder/common/step_update_omi.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,34 @@ func (s *StepUpdateOMIAttributes) Run(_ context.Context, state multistep.StateBa
valid := false
valid = valid || (s.AccountIds != nil && len(s.AccountIds) > 0)
valid = valid || (s.SnapshotAccountIds != nil && len(s.SnapshotAccountIds) > 0)
valid = valid || (s.GlobalPermission != false)

if !valid {
if s.GlobalPermission {
updateImageRequest := oscgo.UpdateImageRequest{
PermissionsToLaunch: oscgo.PermissionsOnResourceCreation{
Additions: &oscgo.PermissionsOnResource{
GlobalPermission: &s.GlobalPermission,
},
},
}

// Updating image attributes
for region, omi := range omis {
ui.Say(fmt.Sprintf("Updating attributes on OMI (%s)...", omi))
regionconn := config.NewOSCClientByRegion(region)

ui.Message(fmt.Sprintf("Updating: %s", omi))
updateImageRequest.ImageId = omi
_, _, err := regionconn.Api.ImageApi.UpdateImage(regionconn.Auth).UpdateImageRequest(updateImageRequest).Execute()
if err != nil {
err := fmt.Errorf("Error updating OMI: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
}

}
return multistep.ActionContinue
}

Expand Down

0 comments on commit 344cca4

Please sign in to comment.