Allow accepting image for the members in OpenStack builder (#8931)
* Allow accepting image for the members in OS builder * Add more documentation to image_auto_accept_members parameter
This commit is contained in:
parent
b81800db2f
commit
2c6f0968b3
|
@ -40,6 +40,7 @@ type FlatConfig struct {
|
|||
ImageMetadata map[string]string `mapstructure:"metadata" required:"false" cty:"metadata"`
|
||||
ImageVisibility *images.ImageVisibility `mapstructure:"image_visibility" required:"false" cty:"image_visibility"`
|
||||
ImageMembers []string `mapstructure:"image_members" required:"false" cty:"image_members"`
|
||||
ImageAutoAcceptMembers *bool `mapstructure:"image_auto_accept_members" required:"false" cty:"image_auto_accept_members"`
|
||||
ImageDiskFormat *string `mapstructure:"image_disk_format" required:"false" cty:"image_disk_format"`
|
||||
ImageTags []string `mapstructure:"image_tags" required:"false" cty:"image_tags"`
|
||||
ImageMinDisk *int `mapstructure:"image_min_disk" required:"false" cty:"image_min_disk"`
|
||||
|
@ -158,6 +159,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
|||
"metadata": &hcldec.BlockAttrsSpec{TypeName: "metadata", ElementType: cty.String, Required: false},
|
||||
"image_visibility": &hcldec.AttrSpec{Name: "image_visibility", Type: cty.String, Required: false},
|
||||
"image_members": &hcldec.AttrSpec{Name: "image_members", Type: cty.List(cty.String), Required: false},
|
||||
"image_auto_accept_members": &hcldec.AttrSpec{Name: "image_auto_accept_members", Type: cty.Bool, Required: false},
|
||||
"image_disk_format": &hcldec.AttrSpec{Name: "image_disk_format", Type: cty.String, Required: false},
|
||||
"image_tags": &hcldec.AttrSpec{Name: "image_tags", Type: cty.List(cty.String), Required: false},
|
||||
"image_min_disk": &hcldec.AttrSpec{Name: "image_min_disk", Type: cty.Number, Required: false},
|
||||
|
|
|
@ -22,6 +22,10 @@ type ImageConfig struct {
|
|||
// usually a project (also called the "tenant") with whom the image is
|
||||
// shared.
|
||||
ImageMembers []string `mapstructure:"image_members" required:"false"`
|
||||
// When true, perform the image accept so the members can see the image in their
|
||||
// project. This requires a user with priveleges both in the build project and
|
||||
// in the members provided. Defaults to false.
|
||||
ImageAutoAcceptMembers bool `mapstructure:"image_auto_accept_members" required:"false"`
|
||||
// Disk format of the resulting image. This option works if
|
||||
// use_blockstorage_volume is true.
|
||||
ImageDiskFormat string `mapstructure:"image_disk_format" required:"false"`
|
||||
|
|
|
@ -37,6 +37,18 @@ func (s *stepAddImageMembers) Run(ctx context.Context, state multistep.StateBag)
|
|||
}
|
||||
}
|
||||
|
||||
if config.ImageAutoAcceptMembers {
|
||||
for _, member := range config.ImageMembers {
|
||||
ui.Say(fmt.Sprintf("Accepting image %s for member '%s'", imageId, member))
|
||||
r := members.Update(imageClient, imageId, member, members.UpdateOpts{Status: "accepted"})
|
||||
if _, err = r.Extract(); err != nil {
|
||||
err = fmt.Errorf("Error accepting image for member: %s", err)
|
||||
state.Put("error", err)
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
usually a project (also called the "tenant") with whom the image is
|
||||
shared.
|
||||
|
||||
- `image_auto_accept_members` (bool) - When true, perform the image accept so the members can see the image in their
|
||||
project. This requires a user with priveleges both in the build project and
|
||||
in the members provided. Defaults to false.
|
||||
|
||||
- `image_disk_format` (string) - Disk format of the resulting image. This option works if
|
||||
use_blockstorage_volume is true.
|
||||
|
||||
|
|
Loading…
Reference in New Issue