Merge pull request #7046 from nferch/hcloud_snapshot_labels

add snapshot_labels to hcloud builder
This commit is contained in:
Adrien Delorme 2018-11-29 13:48:57 +01:00 committed by GitHub
commit c29268a5d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View file

@ -30,10 +30,11 @@ type Config struct {
ServerType string `mapstructure:"server_type"`
Image string `mapstructure:"image"`
SnapshotName string `mapstructure:"snapshot_name"`
UserData string `mapstructure:"user_data"`
UserDataFile string `mapstructure:"user_data_file"`
SSHKeys []string `mapstructure:"ssh_keys"`
SnapshotName string `mapstructure:"snapshot_name"`
SnapshotLabels map[string]string `mapstructure:"snapshot_labels"`
UserData string `mapstructure:"user_data"`
UserDataFile string `mapstructure:"user_data_file"`
SSHKeys []string `mapstructure:"ssh_keys"`
RescueMode string `mapstructure:"rescue"`

View file

@ -21,6 +21,7 @@ func (s *stepCreateSnapshot) Run(_ context.Context, state multistep.StateBag) mu
ui.Say("This can take some time")
result, _, err := client.Server.CreateImage(context.TODO(), &hcloud.Server{ID: serverID}, &hcloud.ServerCreateImageOpts{
Type: hcloud.ImageTypeSnapshot,
Labels: c.SnapshotLabels,
Description: hcloud.String(c.SnapshotName),
})
if err != nil {

View file

@ -58,6 +58,9 @@ builder.
appear in your account. Defaults to "packer-{{timestamp}}" (see
[configuration templates](/docs/templates/engine.html) for more info).
- `snapshot_labels` (map of key/value strings) - Key/value pair labels to
apply to the created image.
- `poll_interval` (string) - Configures the interval in which actions are
polled by the client. Default `500ms`. Increase this interval if you run
into rate limiting errors.