Skip to content

Commit

Permalink
Remove remaining usages of iso_checksum_type, fix config.hcl2spec.go …
Browse files Browse the repository at this point in the history
…generation and re-run it
  • Loading branch information
ddelnano committed Apr 7, 2023
1 parent 6b0b4ba commit 6c808da
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 27 deletions.
11 changes: 5 additions & 6 deletions builder/xenserver/common/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:generate mapstructure-to-hcl2 -type Config
//go:generate packer-sdc mapstructure-to-hcl2 -type Config
package common

import (
Expand All @@ -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"`

Expand Down
6 changes: 3 additions & 3 deletions builder/xenserver/common/config.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 11 additions & 12 deletions builder/xenserver/iso/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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}
}
Expand All @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions examples/centos/centos8-local.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions examples/centos/centos8-netinstall.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions examples/ubuntu/ubuntu-2004.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6c808da

Please sign in to comment.