Skip to content

Commit

Permalink
Drop the iso_checksum_type & iso_checksum_url fields (#8437)
Browse files Browse the repository at this point in the history
* Drop the iso_checksum_type & iso_checksum_url fields

In favor of simply using iso_checksum that will know what to do.

* fix after master merge

* Update builder_test.go

* Update builder_test.go

* Update builder_test.go

* Update builder_test.go

* Update builder_test.go

* remove checksum lowercasing tests

* Update builder_test.go

* Update builder_test.go

* better docs

* Update builder_test.go

* even better docs

* Update config.go

* Update builder_test.go

* Update step_create_vmx_test.go

* make generate

* better docs

* fix imports

* up tests

* Update _ISOConfig-required.html.md

* Update builder_test.go

* don't use sha1.Sum("none") as a caching path

* Update builder_test.go

* better docs

* Update iso_config_test.go

remove ISOChecksumType/ISOChecksumURL references

* Update step_download_test.go

* add iso_checksum_url and iso_checksum_type fixers + tests

* add concrete examples of checksum values

* add examples of checksumming from local file

* update go-getter dep

* up deps

* use new go-getter version

* up ESX5Driver.VerifyChecksum: use go-getter's checksumming

* ISOConfig.Prepare: get checksum there in case we need it as a string in ESX5Driver.VerifyChecksum

* Update iso_config.go

* get go-getter from v2 branch

* Update driver_esx5.go

add more comments

* Update driver_esx5.go

* show better error message when the checksum is invalid

* Update builder_test.go

put in a valid checksum to fix tests, checksum is md5("packer")

* Update builder_test.go

test invalid and valid checksum

* more test updating

* fix default md5 string to be a valid md5

* TestChecksumFileNameMixedCaseBug: use 'file:' prefix for file checksumming

* Update iso_config_test.go

* Update iso_config_test.go

* Update builder_test.go

* Update builder_test.go

* Update builder_test.go

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update go.mod

* Update go.mod

* Update CHANGELOG.md
  • Loading branch information
azr authored May 28, 2020
1 parent 3dc4ba2 commit 0fa60c6
Show file tree
Hide file tree
Showing 350 changed files with 74,845 additions and 34,084 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
removed. Run `packer fix template.json` to migrate an existig template
[GH-9149]

* For all iso based builders, the `iso_checksum_type` and `iso_checksum_url`
fields have been removed in favor of simply setting the `iso_checksum`
field. Use the [packer fix](https://www.packer.io/docs/commands/fix/)
command to update a config file. See any [iso_checksum field
docs](https://www.packer.io/docs/builders/virtualbox/iso/#iso_checksum) to
read more about this[GH-8437]

### FEATURES:
* **New post-processor** Yandex Export [GH-9124]

Expand Down
13 changes: 6 additions & 7 deletions builder/hyperv/iso/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
Path: b.config.OutputDir,
},
&common.StepDownload{
Checksum: b.config.ISOChecksum,
ChecksumType: b.config.ISOChecksumType,
Description: "ISO",
ResultKey: "iso_path",
Url: b.config.ISOUrls,
Extension: b.config.TargetExtension,
TargetPath: b.config.TargetPath,
Checksum: b.config.ISOChecksum,
Description: "ISO",
ResultKey: "iso_path",
Url: b.config.ISOUrls,
Extension: b.config.TargetExtension,
TargetPath: b.config.TargetPath,
},
&common.StepCreateFloppy{
Files: b.config.FloppyConfig.FloppyFiles,
Expand Down
4 changes: 0 additions & 4 deletions builder/hyperv/iso/builder.hcl2spec.go

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

32 changes: 16 additions & 16 deletions builder/hyperv/iso/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import (

func testConfig() map[string]interface{} {
return map[string]interface{}{
"iso_checksum": "foo",
"iso_checksum_type": "md5",
"iso_checksum": "md5:0B0F137F17AC10944716020B018F8126",
"iso_url": "http://www.packer.io",
"shutdown_command": "yes",
"ssh_username": "foo",
Expand Down Expand Up @@ -275,8 +274,18 @@ func TestBuilderPrepare_ISOChecksum(t *testing.T) {
t.Fatal("should have error")
}

// Test good
// Test invalid checksum
config["iso_checksum"] = "FOo"
_, warns, err = b.Prepare(config)
if len(warns) > 0 {
t.Fatalf("bad: %#v", warns)
}
if err == nil {
t.Fatal("should have error")
}

// Test good
config["iso_checksum"] = "md5:0B0F137F17AC10944716020B018F8126"
b = Builder{}
_, warns, err = b.Prepare(config)
if len(warns) > 0 {
Expand All @@ -292,8 +301,7 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
var b Builder
config := testConfig()

// Test bad
config["iso_checksum_type"] = ""
config["iso_checksum"] = "0B0F137F17AC10944716020B018F8126"
_, warns, err := b.Prepare(config)
if len(warns) > 0 {
t.Fatalf("bad: %#v", warns)
Expand All @@ -303,7 +311,7 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
}

// Test good
config["iso_checksum_type"] = "mD5"
config["iso_checksum"] = "mD5:0B0F137F17AC10944716020B018F8126"
b = Builder{}
_, warns, err = b.Prepare(config)
if len(warns) > 0 {
Expand All @@ -313,12 +321,8 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
t.Fatalf("should not have error: %s", err)
}

if b.config.ISOChecksumType != "md5" {
t.Fatalf("should've lowercased: %s", b.config.ISOChecksumType)
}

// Test unknown
config["iso_checksum_type"] = "fake"
config["iso_checksum"] = "fake:foo"
b = Builder{}
_, warns, err = b.Prepare(config)
if len(warns) > 0 {
Expand All @@ -329,7 +333,7 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
}

// Test none
config["iso_checksum_type"] = "none"
config["iso_checksum"] = "none"
b = Builder{}
_, warns, err = b.Prepare(config)
if len(warns) == 0 {
Expand All @@ -338,10 +342,6 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
if err != nil {
t.Fatalf("should not have error: %s", err)
}

if b.config.ISOChecksumType != "none" {
t.Fatalf("should've lowercased: %s", b.config.ISOChecksumType)
}
}

func TestBuilderPrepare_ISOUrl(t *testing.T) {
Expand Down
13 changes: 6 additions & 7 deletions builder/hyperv/vmcx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
Path: b.config.OutputDir,
},
&common.StepDownload{
Checksum: b.config.ISOChecksum,
ChecksumType: b.config.ISOChecksumType,
Description: "ISO",
ResultKey: "iso_path",
Url: b.config.ISOUrls,
Extension: b.config.TargetExtension,
TargetPath: b.config.TargetPath,
Checksum: b.config.ISOChecksum,
Description: "ISO",
ResultKey: "iso_path",
Url: b.config.ISOUrls,
Extension: b.config.TargetExtension,
TargetPath: b.config.TargetPath,
},
&common.StepCreateFloppy{
Files: b.config.FloppyFiles,
Expand Down
4 changes: 0 additions & 4 deletions builder/hyperv/vmcx/builder.hcl2spec.go

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

19 changes: 5 additions & 14 deletions builder/hyperv/vmcx/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import (

func testConfig() map[string]interface{} {
return map[string]interface{}{
"iso_checksum": "foo",
"iso_checksum_type": "md5",
"iso_checksum": "md5:0B0F137F17AC10944716020B018F8126",
"iso_url": "http://www.packer.io",
"shutdown_command": "yes",
"ssh_username": "foo",
Expand Down Expand Up @@ -193,7 +192,7 @@ func TestBuilderPrepare_ISOChecksum(t *testing.T) {
}

// Test good
config["iso_checksum"] = "FOo"
config["iso_checksum"] = "0B0F137F17AC10944716020B018F8126"
b = Builder{}
_, warns, err = b.Prepare(config)
if len(warns) > 0 {
Expand All @@ -217,8 +216,7 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
defer os.RemoveAll(td)
config["clone_from_vmcx_path"] = td

// Test bad
config["iso_checksum_type"] = ""
config["iso_checksum"] = "0B0F137F17AC10944716020B018F8126"
_, warns, err := b.Prepare(config)
if len(warns) > 0 {
t.Fatalf("bad: %#v", warns)
Expand All @@ -228,7 +226,7 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
}

// Test good
config["iso_checksum_type"] = "mD5"
config["iso_checksum"] = "mD5:0B0F137F17AC10944716020B018F8126"
b = Builder{}
_, warns, err = b.Prepare(config)
if len(warns) > 0 {
Expand All @@ -238,12 +236,8 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
t.Fatalf("should not have error: %s", err)
}

if b.config.ISOChecksumType != "md5" {
t.Fatalf("should've lowercased: %s", b.config.ISOChecksumType)
}

// Test none
config["iso_checksum_type"] = "none"
config["iso_checksum"] = "none"
b = Builder{}
_, warns, err = b.Prepare(config)
if len(warns) == 0 {
Expand All @@ -253,9 +247,6 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
t.Fatalf("should not have error: %s", err)
}

if b.config.ISOChecksumType != "none" {
t.Fatalf("should've lowercased: %s", b.config.ISOChecksumType)
}
}

func TestBuilderPrepare_ISOUrl(t *testing.T) {
Expand Down
13 changes: 6 additions & 7 deletions builder/parallels/iso/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
ParallelsToolsMode: b.config.ParallelsToolsMode,
},
&common.StepDownload{
Checksum: b.config.ISOChecksum,
ChecksumType: b.config.ISOChecksumType,
Description: "ISO",
Extension: b.config.TargetExtension,
ResultKey: "iso_path",
TargetPath: b.config.TargetPath,
Url: b.config.ISOUrls,
Checksum: b.config.ISOChecksum,
Description: "ISO",
Extension: b.config.TargetExtension,
ResultKey: "iso_path",
TargetPath: b.config.TargetPath,
Url: b.config.ISOUrls,
},
&parallelscommon.StepOutputDir{
Force: b.config.PackerForce,
Expand Down
4 changes: 0 additions & 4 deletions builder/parallels/iso/builder.hcl2spec.go

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

3 changes: 1 addition & 2 deletions builder/parallels/iso/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (

func testConfig() map[string]interface{} {
return map[string]interface{}{
"iso_checksum": "foo",
"iso_checksum_type": "md5",
"iso_checksum": "md5:0B0F137F17AC10944716020B018F8126",
"iso_url": "http://www.google.com/",
"shutdown_command": "yes",
"ssh_username": "foo",
Expand Down
13 changes: 6 additions & 7 deletions builder/proxmox/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
// Build the steps
steps := []multistep.Step{
&common.StepDownload{
Checksum: b.config.ISOChecksum,
ChecksumType: b.config.ISOChecksumType,
Description: "ISO",
Extension: b.config.TargetExtension,
ResultKey: downloadPathKey,
TargetPath: b.config.TargetPath,
Url: b.config.ISOUrls,
Checksum: b.config.ISOChecksum,
Description: "ISO",
Extension: b.config.TargetExtension,
ResultKey: downloadPathKey,
TargetPath: b.config.TargetPath,
Url: b.config.ISOUrls,
},
&stepUploadISO{},
&stepStartVM{},
Expand Down
4 changes: 0 additions & 4 deletions builder/proxmox/config.hcl2spec.go

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

15 changes: 7 additions & 8 deletions builder/qemu/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
}

if b.config.ISOSkipCache {
b.config.ISOChecksumType = "none"
b.config.ISOChecksum = "none"
}
isoWarnings, isoErrs := b.config.ISOConfig.Prepare(&b.config.ctx)
warnings = append(warnings, isoWarnings...)
Expand Down Expand Up @@ -588,13 +588,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
steps := []multistep.Step{}
if !b.config.ISOSkipCache {
steps = append(steps, &common.StepDownload{
Checksum: b.config.ISOChecksum,
ChecksumType: b.config.ISOChecksumType,
Description: "ISO",
Extension: b.config.TargetExtension,
ResultKey: "iso_path",
TargetPath: b.config.TargetPath,
Url: b.config.ISOUrls,
Checksum: b.config.ISOChecksum,
Description: "ISO",
Extension: b.config.TargetExtension,
ResultKey: "iso_path",
TargetPath: b.config.TargetPath,
Url: b.config.ISOUrls,
},
)
} else {
Expand Down
4 changes: 0 additions & 4 deletions builder/qemu/builder.hcl2spec.go

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

3 changes: 1 addition & 2 deletions builder/qemu/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ eHLc1nkCgYEApm/motCTPN32nINZ+Vvywbv64ZD+gtpeMNP3CLrbe1X9O+H52AXa

func testConfig() map[string]interface{} {
return map[string]interface{}{
"iso_checksum": "foo",
"iso_checksum_type": "md5",
"iso_checksum": "md5:0B0F137F17AC10944716020B018F8126",
"iso_url": "http://www.google.com/",
"ssh_username": "foo",
packer.BuildNameConfigKey: "foo",
Expand Down
Loading

0 comments on commit 0fa60c6

Please sign in to comment.