-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4283 from mitchellh/openstackhacks
builder/openstack: Add image visibility & members
- Loading branch information
Showing
128 changed files
with
4,202 additions
and
5,144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package openstack | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/gophercloud/gophercloud/openstack/imageservice/v2/members" | ||
"github.com/mitchellh/multistep" | ||
"github.com/mitchellh/packer/packer" | ||
) | ||
|
||
type stepAddImageMembers struct{} | ||
|
||
func (s *stepAddImageMembers) Run(state multistep.StateBag) multistep.StepAction { | ||
imageId := state.Get("image").(string) | ||
ui := state.Get("ui").(packer.Ui) | ||
config := state.Get("config").(Config) | ||
|
||
if len(config.ImageMembers) == 0 { | ||
return multistep.ActionContinue | ||
} | ||
|
||
imageClient, err := config.imageV2Client() | ||
if err != nil { | ||
err = fmt.Errorf("Error initializing image service client: %s", err) | ||
state.Put("error", err) | ||
return multistep.ActionHalt | ||
} | ||
|
||
for _, member := range config.ImageMembers { | ||
ui.Say(fmt.Sprintf("Adding member '%s' to image %s", member, imageId)) | ||
r := members.Create(imageClient, imageId, member) | ||
if _, err = r.Extract(); err != nil { | ||
err = fmt.Errorf("Error adding member to image: %s", err) | ||
state.Put("error", err) | ||
return multistep.ActionHalt | ||
} | ||
} | ||
|
||
return multistep.ActionContinue | ||
} | ||
|
||
func (s *stepAddImageMembers) Cleanup(multistep.StateBag) { | ||
// No cleanup... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.