Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Annotation option #185

Merged
merged 8 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ See complete Ubuntu, Windows, and macOS templates in the [examples folder](https
### VM Location

* `vm_name`(string) - Name of the new VM to create.
* `annotation`(string) - Add some note.
* `folder`(string) - VM folder to create the VM in.
* `host`(string) - ESXi host where target VM is created. A full path must be specified if the host is in a folder. For example `folder/host`. See the `Specifying Clusters and Hosts` section above for more details.
* `cluster`(string) - ESXi cluster where target VM is created. See [Working with Clusters](#working-with-clusters) section.
Expand Down
6 changes: 6 additions & 0 deletions clone/step_clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type CloneConfig struct {
Template string `mapstructure:"template"`
DiskSize int64 `mapstructure:"disk_size"`
LinkedClone bool `mapstructure:"linked_clone"`
Annoation string `mapstructure:"annotation"`
}

func (c *CloneConfig) Prepare() []error {
Expand All @@ -26,6 +27,10 @@ func (c *CloneConfig) Prepare() []error {
errs = append(errs, fmt.Errorf("'linked_clone' and 'disk_size' cannot be used together"))
}

if c.Annotation == "" {
c.Annotation = "generate by jetbrains-infra/packer-builder-vsphere"
}

return errs
}

Expand Down Expand Up @@ -54,6 +59,7 @@ func (s *StepCloneVM) Run(ctx context.Context, state multistep.StateBag) multist
ResourcePool: s.Location.ResourcePool,
Datastore: s.Location.Datastore,
LinkedClone: s.Config.LinkedClone,
Annotation: s.Config.Annotation,
})
if err != nil {
state.Put("error", err)
Expand Down
7 changes: 7 additions & 0 deletions iso/step_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type CreateConfig struct {
Network string `mapstructure:"network"`
NetworkCard string `mapstructure:"network_card"`
USBController bool `mapstructure:"usb_controller"`

Annotation string `mapstructure:"annotation"`
}

func (c *CreateConfig) Prepare() []error {
Expand All @@ -38,6 +40,10 @@ func (c *CreateConfig) Prepare() []error {
errs = append(errs, fmt.Errorf("'firmware' must be 'bios' or 'efi'"))
}

if c.Annotation == "" {
c.Annotation = "generate by jetbrains-infra/packer-builder-vsphere"
}

return errs
}

Expand Down Expand Up @@ -67,6 +73,7 @@ func (s *StepCreateVM) Run(_ context.Context, state multistep.StateBag) multiste
USBController: s.Config.USBController,
Version: s.Config.Version,
Firmware: s.Config.Firmware,
Annotation: s.Config.Annotation,
})
if err != nil {
state.Put("error", fmt.Errorf("error creating vm: %v", err))
Expand Down