diff --git a/builder/xenserver/common/config.go b/builder/xenserver/common/config.go index 53e76b7..fdd31b5 100644 --- a/builder/xenserver/common/config.go +++ b/builder/xenserver/common/config.go @@ -1,4 +1,4 @@ -//go:generate mapstructure-to-hcl2 -type Config +//go:generate packer-sdc mapstructure-to-hcl2 -type Config package common import ( @@ -21,11 +21,10 @@ type Config struct { CloneTemplate string `mapstructure:"clone_template"` VMOtherConfig map[string]string `mapstructure:"vm_other_config"` - ISOChecksum string `mapstructure:"iso_checksum"` - ISOChecksumType string `mapstructure:"iso_checksum_type"` - ISOUrls []string `mapstructure:"iso_urls"` - ISOUrl string `mapstructure:"iso_url"` - ISOName string `mapstructure:"iso_name"` + ISOChecksum string `mapstructure:"iso_checksum"` + ISOUrls []string `mapstructure:"iso_urls"` + ISOUrl string `mapstructure:"iso_url"` + ISOName string `mapstructure:"iso_name"` PlatformArgs map[string]string `mapstructure:"platform_args"` diff --git a/builder/xenserver/common/config.hcl2spec.go b/builder/xenserver/common/config.hcl2spec.go index 65644ea..04d4479 100644 --- a/builder/xenserver/common/config.hcl2spec.go +++ b/builder/xenserver/common/config.hcl2spec.go @@ -1,4 +1,4 @@ -// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT. +// Code generated by "packer-sdc mapstructure-to-hcl2"; DO NOT EDIT. package common @@ -12,6 +12,7 @@ import ( type FlatConfig struct { PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"` PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"` + PackerCoreVersion *string `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"` PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"` PackerForce *bool `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"` PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"` @@ -100,7 +101,6 @@ type FlatConfig struct { CloneTemplate *string `mapstructure:"clone_template" cty:"clone_template" hcl:"clone_template"` VMOtherConfig map[string]string `mapstructure:"vm_other_config" cty:"vm_other_config" hcl:"vm_other_config"` ISOChecksum *string `mapstructure:"iso_checksum" cty:"iso_checksum" hcl:"iso_checksum"` - ISOChecksumType *string `mapstructure:"iso_checksum_type" cty:"iso_checksum_type" hcl:"iso_checksum_type"` ISOUrls []string `mapstructure:"iso_urls" cty:"iso_urls" hcl:"iso_urls"` ISOUrl *string `mapstructure:"iso_url" cty:"iso_url" hcl:"iso_url"` ISOName *string `mapstructure:"iso_name" cty:"iso_name" hcl:"iso_name"` @@ -124,6 +124,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { s := map[string]hcldec.Spec{ "packer_build_name": &hcldec.AttrSpec{Name: "packer_build_name", Type: cty.String, Required: false}, "packer_builder_type": &hcldec.AttrSpec{Name: "packer_builder_type", Type: cty.String, Required: false}, + "packer_core_version": &hcldec.AttrSpec{Name: "packer_core_version", Type: cty.String, Required: false}, "packer_debug": &hcldec.AttrSpec{Name: "packer_debug", Type: cty.Bool, Required: false}, "packer_force": &hcldec.AttrSpec{Name: "packer_force", Type: cty.Bool, Required: false}, "packer_on_error": &hcldec.AttrSpec{Name: "packer_on_error", Type: cty.String, Required: false}, @@ -212,7 +213,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "clone_template": &hcldec.AttrSpec{Name: "clone_template", Type: cty.String, Required: false}, "vm_other_config": &hcldec.AttrSpec{Name: "vm_other_config", Type: cty.Map(cty.String), Required: false}, "iso_checksum": &hcldec.AttrSpec{Name: "iso_checksum", Type: cty.String, Required: false}, - "iso_checksum_type": &hcldec.AttrSpec{Name: "iso_checksum_type", Type: cty.String, Required: false}, "iso_urls": &hcldec.AttrSpec{Name: "iso_urls", Type: cty.List(cty.String), Required: false}, "iso_url": &hcldec.AttrSpec{Name: "iso_url", Type: cty.String, Required: false}, "iso_name": &hcldec.AttrSpec{Name: "iso_name", Type: cty.String, Required: false}, diff --git a/builder/xenserver/iso/builder.go b/builder/xenserver/iso/builder.go index 7ef6950..9a0d1d1 100644 --- a/builder/xenserver/iso/builder.go +++ b/builder/xenserver/iso/builder.go @@ -95,12 +95,11 @@ func (self *Builder) Prepare(raws ...interface{}) (params []string, warns []stri // Template substitution templates := map[string]*string{ - "clone_template": &self.config.CloneTemplate, - "iso_checksum": &self.config.ISOChecksum, - "iso_checksum_type": &self.config.ISOChecksumType, - "iso_url": &self.config.ISOUrl, - "iso_name": &self.config.ISOName, - "install_timeout": &self.config.RawInstallTimeout, + "clone_template": &self.config.CloneTemplate, + "iso_checksum": &self.config.ISOChecksum, + "iso_url": &self.config.ISOUrl, + "iso_name": &self.config.ISOName, + "install_timeout": &self.config.RawInstallTimeout, } for i := range self.config.ISOUrls { templates[fmt.Sprintf("iso_urls[%d]", i)] = &self.config.ISOUrls[i] @@ -121,7 +120,7 @@ func (self *Builder) Prepare(raws ...interface{}) (params []string, warns []stri if len(self.config.ISOUrls) == 0 { if self.config.ISOUrl == "" { errs = packer.MultiErrorAppend( - errs, errors.New("One of iso_url or iso_urls must be specified.")) + errs, errors.New("One of iso_url or iso_urls must be specified.")) } else { self.config.ISOUrls = []string{self.config.ISOUrl} } @@ -132,16 +131,16 @@ func (self *Builder) Prepare(raws ...interface{}) (params []string, warns []stri } //The SDK can validate the ISO checksum and other sanity checks on the url. - iso_config := commonsteps.ISOConfig { + iso_config := commonsteps.ISOConfig{ ISOChecksum: self.config.ISOChecksum, - ISOUrls: self.config.ISOUrls, + ISOUrls: self.config.ISOUrls, } _, iso_errs := iso_config.Prepare(nil) if iso_errs != nil { - for _, this_err := range iso_errs { - errs = packer.MultiErrorAppend(errs, this_err) - } + for _, this_err := range iso_errs { + errs = packer.MultiErrorAppend(errs, this_err) + } } } else { diff --git a/examples/centos/centos8-local.pkr.hcl b/examples/centos/centos8-local.pkr.hcl index c21eb8f..5dc693e 100644 --- a/examples/centos/centos8-local.pkr.hcl +++ b/examples/centos/centos8-local.pkr.hcl @@ -47,8 +47,7 @@ locals { } source "xenserver-iso" "centos8-local" { - iso_checksum = "aaf9d4b3071c16dbbda01dfe06085e5d0fdac76df323e3bbe87cce4318052247" - iso_checksum_type = "sha1" + iso_checksum = "sha1:aaf9d4b3071c16dbbda01dfe06085e5d0fdac76df323e3bbe87cce4318052247" iso_url = "http://mirrors.ocf.berkeley.edu/centos/8.3.2011/isos/x86_64/CentOS-8.3.2011-x86_64-dvd1.iso" sr_iso_name = var.sr_iso_name diff --git a/examples/centos/centos8-netinstall.pkr.hcl b/examples/centos/centos8-netinstall.pkr.hcl index e34d369..c2abbfe 100644 --- a/examples/centos/centos8-netinstall.pkr.hcl +++ b/examples/centos/centos8-netinstall.pkr.hcl @@ -47,8 +47,7 @@ locals { } source "xenserver-iso" "centos8-netinstall" { - iso_checksum = "07a8e59c42cc086ec4c49bdce4fae5a17b077dea" - iso_checksum_type = "sha1" + iso_checksum = "sha1:07a8e59c42cc086ec4c49bdce4fae5a17b077dea" iso_url = "http://mirrors.ocf.berkeley.edu/centos/8.3.2011/isos/x86_64/CentOS-8.3.2011-x86_64-boot.iso" sr_iso_name = var.sr_iso_name diff --git a/examples/ubuntu/ubuntu-2004.pkr.hcl b/examples/ubuntu/ubuntu-2004.pkr.hcl index 3373c46..c9ebfa8 100644 --- a/examples/ubuntu/ubuntu-2004.pkr.hcl +++ b/examples/ubuntu/ubuntu-2004.pkr.hcl @@ -74,8 +74,7 @@ variable "sr_name" { } source "xenserver-iso" "ubuntu-2004" { - iso_checksum = local.ubuntu_sha256.0 - iso_checksum_type = "sha256" + iso_checksum = "sha256:${local.ubuntu_sha256.0}" iso_url = "https://releases.ubuntu.com/${local.ubuntu_version}/ubuntu-${local.ubuntu_version}.${local.ubuntu_url_path.0}-live-server-amd64.iso" sr_iso_name = var.sr_iso_name