Use Trilean for boolean value, and allow for missing values for defaults

This commit is contained in:
Jeff Wong 2020-10-06 17:24:45 -07:00
parent 977022fb35
commit fdda18e392
No known key found for this signature in database
GPG Key ID: D4EEB78E484F8A83
3 changed files with 5 additions and 4 deletions

View File

@ -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
}

View File

@ -4,6 +4,7 @@ package proxmoxclone
import (
proxmox "github.com/hashicorp/packer/builder/proxmox/common"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/packer"
)
@ -11,7 +12,7 @@ type Config struct {
proxmox.Config `mapstructure:",squash"`
CloneVM string `mapstructure:"clone_vm"`
FullClone bool `mapstructure:"full_clone"`
FullClone config.Trilean `mapstructure:"full_clone" required:"false"`
}
func (c *Config) Prepare(raws ...interface{}) ([]string, []string, error) {

View File

@ -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.