Remove remaining usages of iso_checksum_type, fix config.hcl2spec.go generation and re-run it

This commit is contained in:
Dom Del Nano 2023-04-06 23:23:51 -07:00
parent 6b0b4baf2f
commit 6c808da038
6 changed files with 22 additions and 27 deletions

View File

@ -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"`

View File

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

View File

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

View File

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

View File

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

View File

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