Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop the iso_checksum_type & iso_checksum_url fields #8437

Merged
merged 61 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
a22608f
Drop the iso_checksum_type & iso_checksum_url fields
azr Dec 2, 2019
2d3c045
Merge remote-tracking branch 'origin/master' into drop_iso_checksum_t…
azr Feb 10, 2020
1b993b8
fix after master merge
azr Feb 10, 2020
aedd549
Update builder_test.go
azr Feb 10, 2020
fc60b59
Update builder_test.go
azr Feb 10, 2020
7bc47b8
Update builder_test.go
azr Feb 10, 2020
f6d39fc
Update builder_test.go
azr Feb 10, 2020
596b315
Update builder_test.go
azr Feb 10, 2020
6617f13
remove checksum lowercasing tests
azr Feb 10, 2020
5967c76
Update builder_test.go
azr Feb 10, 2020
61f751d
Update builder_test.go
azr Feb 10, 2020
271dde1
better docs
azr Feb 10, 2020
0ba1597
Update builder_test.go
azr Feb 10, 2020
8d3978b
even better docs
azr Feb 10, 2020
c3160e6
Update config.go
azr Feb 10, 2020
d44d7e2
Update builder_test.go
azr Feb 10, 2020
afe93ac
Update step_create_vmx_test.go
azr Feb 10, 2020
b293a09
make generate
azr Feb 10, 2020
39444b3
better docs
azr Feb 10, 2020
4535dec
fix imports
azr Feb 10, 2020
9615b3b
up tests
azr Feb 10, 2020
39b50a5
Update _ISOConfig-required.html.md
azr Feb 10, 2020
421ca5d
Update builder_test.go
azr Feb 10, 2020
558c0fa
don't use sha1.Sum("none") as a caching path
azr Feb 10, 2020
799bedf
Update builder_test.go
azr Feb 10, 2020
23fd311
Merge remote-tracking branch 'origin/master' into drop_iso_checksum_t…
azr May 4, 2020
9101ae0
better docs
azr May 4, 2020
bdb8b09
Update iso_config_test.go
azr May 4, 2020
3e60725
Update step_download_test.go
azr May 4, 2020
8d1aabb
add iso_checksum_url and iso_checksum_type fixers + tests
azr May 4, 2020
24758a1
add concrete examples of checksum values
azr May 6, 2020
43ece44
add examples of checksumming from local file
azr May 6, 2020
517718c
Merge remote-tracking branch 'origin/master' into drop_iso_checksum_t…
azr May 14, 2020
0513d38
update go-getter dep
azr May 14, 2020
49c2baa
up deps
azr May 14, 2020
594edd5
use new go-getter version
azr May 14, 2020
7c183d1
up ESX5Driver.VerifyChecksum: use go-getter's checksumming
azr May 14, 2020
1daf880
ISOConfig.Prepare: get checksum there in case we need it as a string …
azr May 14, 2020
368bcc1
Update iso_config.go
azr May 14, 2020
8bb8470
get go-getter from v2 branch
azr May 19, 2020
0a4d4e5
Merge remote-tracking branch 'origin/master' into drop_iso_checksum_t…
azr May 19, 2020
dd02f07
Update driver_esx5.go
azr May 19, 2020
6f97b5b
Update driver_esx5.go
azr May 19, 2020
0264368
show better error message when the checksum is invalid
azr May 19, 2020
ae6dd4f
Update builder_test.go
azr May 19, 2020
443456b
Update builder_test.go
azr May 19, 2020
cadbcca
more test updating
azr May 19, 2020
23c96d3
fix default md5 string to be a valid md5
azr May 19, 2020
486a967
TestChecksumFileNameMixedCaseBug: use 'file:' prefix for file checksu…
azr May 19, 2020
6bf844f
Update iso_config_test.go
azr May 19, 2020
cf25108
Update iso_config_test.go
azr May 19, 2020
a802561
Update builder_test.go
azr May 19, 2020
41aadc5
Update builder_test.go
azr May 19, 2020
90e6f08
Update builder_test.go
azr May 19, 2020
94399e9
Update CHANGELOG.md
azr May 19, 2020
eef3d7d
Update CHANGELOG.md
azr May 19, 2020
98af124
Merge branch 'master' into drop_iso_checksum_type_field
azr May 26, 2020
da5f794
Update go.mod
azr May 26, 2020
fc8b708
Update go.mod
azr May 26, 2020
8e432c9
Update CHANGELOG.md
azr May 26, 2020
3910f62
Merge branch 'master' into drop_iso_checksum_type_field
azr May 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

19 changes: 5 additions & 14 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:foo",
"iso_url": "http://www.packer.io",
"shutdown_command": "yes",
"ssh_username": "foo",
Expand Down Expand Up @@ -293,7 +292,7 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
config := testConfig()

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

// Test good
config["iso_checksum_type"] = "mD5"
config["iso_checksum"] = "mD5:foo"
b = Builder{}
_, warns, err = b.Prepare(config)
if len(warns) > 0 {
Expand All @@ -313,12 +312,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 +324,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 +333,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.

16 changes: 4 additions & 12 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:foo",
"iso_url": "http://www.packer.io",
"shutdown_command": "yes",
"ssh_username": "foo",
Expand Down Expand Up @@ -218,7 +217,7 @@ func TestBuilderPrepare_ISOChecksumType(t *testing.T) {
config["clone_from_vmcx_path"] = td

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

// Test good
config["iso_checksum_type"] = "mD5"
config["iso_checksum"] = "mD5:foo"
b = Builder{}
_, warns, err = b.Prepare(config)
if len(warns) > 0 {
Expand All @@ -238,12 +237,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 +248,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:foo",
"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 @@ -579,13 +579,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:foo",
"iso_url": "http://www.google.com/",
"ssh_username": "foo",
packer.BuildNameConfigKey: "foo",
Expand Down
25 changes: 13 additions & 12 deletions builder/vagrant/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ type Config struct {
// simply launch the box directly using the global id.
GlobalID string `mapstructure:"global_id" required:"true"`
// The checksum for the .box file. The type of the checksum is specified
// with checksum_type, documented below.
// within the checksum as a prefix, ex: "md5:{$checksum}". The type of the
// checksum can also be omitted and Packer will try to infer it based on
// string length. Valid values are "none", "{$checksum}", "{$path}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path can be a URL and a file path, but does it work like file:http://foo.com/bar?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think giving an actual example with a real checksum hash will be helpful here so users don't get hung up on the variable syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added examples but for a checksum the go getter will first try to split the url with the first found semicolon and then what's left will be used to be fetched.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, weirdly enough a url can be: file:file://./path/to/file.sum

// "md5:{$checksum}", "sha1:{$checksum}", "sha256:{$checksum}",
// "sha512:{$checksum}" or "file:{$path}". Although the checksum will
// not be verified when it is set to "none", this is not recommended since
// these files can be very large and corruption does happen from time to
// time.
Checksum string `mapstructure:"checksum" required:"false"`
// The type of the checksum specified in checksum. Valid values are none,
// md5, sha1, sha256, or sha512. Although the checksum will not be verified
// when checksum_type is set to "none", this is not recommended since OVA
// files can be very large and corruption does happen from time to time.
ChecksumType string `mapstructure:"checksum_type" required:"false"`
// if your source_box is a boxfile that we need to add to Vagrant, this is
// the name to give it. If left blank, will default to "packer_" plus your
// buildname.
Expand Down Expand Up @@ -248,12 +250,11 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
// Download if source box isn't from vagrant cloud.
if strings.HasSuffix(b.config.SourceBox, ".box") {
steps = append(steps, &common.StepDownload{
Checksum: b.config.Checksum,
ChecksumType: b.config.ChecksumType,
Description: "Box",
Extension: "box",
ResultKey: "box_path",
Url: []string{b.config.SourceBox},
Checksum: b.config.Checksum,
Description: "Box",
Extension: "box",
ResultKey: "box_path",
Url: []string{b.config.SourceBox},
})
}
steps = append(steps,
Expand Down
Loading