Merge pull request #8280 from blinohod/cloudstack-display-name

[WIP] Add instance_display_name for cloudstack builder
This commit is contained in:
Adrien Delorme 2019-10-29 12:19:50 +01:00 committed by GitHub
commit b2b12d6b04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 1 deletions

View File

@ -78,6 +78,8 @@ type Config struct {
// The name of the instance. Defaults to
// "packer-UUID" where UUID is dynamically generated.
InstanceName string `mapstructure:"instance_name" required:"false"`
// The display name of the instance. Defaults to "Created by Packer".
InstanceDisplayName string `mapstructure:"instance_display_name" required:"false"`
// The name or ID of the network to connect the instance
// to.
Network string `mapstructure:"network" required:"true"`
@ -210,6 +212,10 @@ func NewConfig(raws ...interface{}) (*Config, error) {
c.InstanceName = fmt.Sprintf("packer-%s", uuid.TimeOrderedUUID())
}
if c.InstanceDisplayName == "" {
c.InstanceDisplayName = "Created by Packer"
}
if c.TemplateName == "" {
name, err := interpolate.Render("packer-{{timestamp}}", nil)
if err != nil {

View File

@ -74,6 +74,7 @@ type FlatConfig struct {
Expunge *bool `mapstructure:"expunge" required:"false" cty:"expunge"`
Hypervisor *string `mapstructure:"hypervisor" required:"false" cty:"hypervisor"`
InstanceName *string `mapstructure:"instance_name" required:"false" cty:"instance_name"`
InstanceDisplayName *string `mapstructure:"instance_display_name" required:"false" cty:"instance_display_name"`
Network *string `mapstructure:"network" required:"true" cty:"network"`
Project *string `mapstructure:"project" required:"false" cty:"project"`
PublicIPAddress *string `mapstructure:"public_ip_address" required:"false" cty:"public_ip_address"`
@ -174,6 +175,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"expunge": &hcldec.AttrSpec{Name: "expunge", Type: cty.Bool, Required: false},
"hypervisor": &hcldec.AttrSpec{Name: "hypervisor", Type: cty.String, Required: false},
"instance_name": &hcldec.AttrSpec{Name: "instance_name", Type: cty.String, Required: false},
"instance_display_name": &hcldec.AttrSpec{Name: "instance_display_name", Type: cty.String, Required: false},
"network": &hcldec.AttrSpec{Name: "network", Type: cty.String, Required: false},
"project": &hcldec.AttrSpec{Name: "project", Type: cty.String, Required: false},
"public_ip_address": &hcldec.AttrSpec{Name: "public_ip_address", Type: cty.String, Required: false},

View File

@ -44,7 +44,7 @@ func (s *stepCreateInstance) Run(ctx context.Context, state multistep.StateBag)
// Configure the instance.
p.SetName(config.InstanceName)
p.SetDisplayname("Created by Packer")
p.SetDisplayname(config.InstanceDisplayName)
if len(config.Comm.SSHKeyPairName) != 0 {
ui.Message(fmt.Sprintf("Using keypair: %s", config.Comm.SSHKeyPairName))

View File

@ -45,6 +45,8 @@
- `instance_name` (string) - The name of the instance. Defaults to
"packer-UUID" where UUID is dynamically generated.
- `instance_display_name` (string) - The display name of the instance. Defaults to "Created by Packer".
- `project` (string) - The name or ID of the project to deploy the instance
to.