From fdda18e392a0816a6d9839e39eff3f4e95a3d3ea Mon Sep 17 00:00:00 2001 From: Jeff Wong Date: Tue, 6 Oct 2020 17:24:45 -0700 Subject: [PATCH] Use Trilean for boolean value, and allow for missing values for defaults --- builder/proxmox/clone/builder.go | 2 +- builder/proxmox/clone/config.go | 5 +++-- builder/proxmox/clone/config.hcl2spec.go | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/builder/proxmox/clone/builder.go b/builder/proxmox/clone/builder.go index 0e21f05b6..8f088f81d 100644 --- a/builder/proxmox/clone/builder.go +++ b/builder/proxmox/clone/builder.go @@ -54,7 +54,7 @@ func (*cloneVMCreator) Create(vmRef *proxmoxapi.VmRef, config proxmoxapi.ConfigQ comm := state.Get("comm").(*communicator.Config) fullClone := 1 - if c.FullClone == false { + if c.FullClone.False() { fullClone = 0 } diff --git a/builder/proxmox/clone/config.go b/builder/proxmox/clone/config.go index 0fce27b4e..e9a8721d6 100644 --- a/builder/proxmox/clone/config.go +++ b/builder/proxmox/clone/config.go @@ -4,14 +4,15 @@ package proxmoxclone import ( proxmox "github.com/hashicorp/packer/builder/proxmox/common" + "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" ) type Config struct { proxmox.Config `mapstructure:",squash"` - CloneVM string `mapstructure:"clone_vm"` - FullClone bool `mapstructure:"full_clone"` + CloneVM string `mapstructure:"clone_vm"` + FullClone config.Trilean `mapstructure:"full_clone" required:"false"` } func (c *Config) Prepare(raws ...interface{}) ([]string, []string, error) { diff --git a/builder/proxmox/clone/config.hcl2spec.go b/builder/proxmox/clone/config.hcl2spec.go index 4c946c17f..879549542 100644 --- a/builder/proxmox/clone/config.hcl2spec.go +++ b/builder/proxmox/clone/config.hcl2spec.go @@ -100,7 +100,7 @@ type FlatConfig struct { AdditionalISOFiles []proxmox.FlatstorageConfig `mapstructure:"additional_iso_files" cty:"additional_iso_files" hcl:"additional_iso_files"` VMInterface *string `mapstructure:"vm_interface" cty:"vm_interface" hcl:"vm_interface"` CloneVM *string `mapstructure:"clone_vm" cty:"clone_vm" hcl:"clone_vm"` - FullClone *bool `mapstructure:"full_clone" cty:"full_clone" hcl:"full_clone"` + FullClone *bool `mapstructure:"full_clone" required:"false" cty:"full_clone" hcl:"full_clone"` } // FlatMapstructure returns a new FlatConfig.