Commit Graph

615 Commits

Author SHA1 Message Date
Adrien Delorme 40947c2bf6
HCL2: generate hcl tags with go-cty tags too (#9306)
This will allow to generate the config files:

```go
package main

import (
	"fmt"

	"github.com/hashicorp/hcl/v2/gohcl"
	"github.com/hashicorp/hcl/v2/hclwrite"
	"github.com/hashicorp/packer/builder/alicloud/ecs"
)

func main() {
	name := "name"
	app := ecs.FlatConfig{
		AlicloudImageName: &name,
		ECSSystemDiskMapping: &ecs.FlatAlicloudDiskDevice{
			DiskName: &name,
		},
	}

	f := hclwrite.NewEmptyFile()
	block := gohcl.EncodeAsBlock(&app, `source "something" "something"`)
	f.Body().AppendBlock(block)
	fmt.Printf("%s", f.Bytes())
}

```

Will output:

```
source "something" "something" {
  packer_user_variables      = null
  packer_sensitive_variables = null
  image_name                 = "name"
  image_share_account        = null
  image_unshare_account      = null
  image_copy_regions         = null
  image_copy_names           = null
  tags                       = null
  tag                        = null
  system_disk_mapping        = { disk_category = null, disk_delete_with_instance = null, disk_descri
ption = null, disk_device = null, disk_encrypted = null, disk_name = "name", disk_size = null, disk_
snapshot_id = null }
  image_disk_mappings        = null
  ssh_remote_tunnels         = null
  ssh_local_tunnels          = null
  ssh_public_key             = null
  ssh_private_key            = null
}
```

This is a good first step for #9015 and #9282 

fix #9304
2020-05-28 11:19:00 +02:00
Adrien Delorme 0fa60c68fb
Drop the iso_checksum_type & iso_checksum_url fields (#8437)
* 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
2020-05-28 11:02:09 +02:00
Sylvia Moss 1c30a71d09
Replace file shared state by statebag (#9238) 2020-05-19 11:49:48 +02:00
Sylvia Moss 25971b3b5c
Add pwd to gogetter ChecksumFromFile (#9129) 2020-05-11 11:14:50 +02:00
Rui Lopes 86ac132056
hyperv: add support for setting the boot order (#9046) 2020-04-30 13:31:41 +02:00
Adrien Delorme 840e67f775
HCL2: when we see a map generate an attribute spec instead of a block spec (#9035)
* mapstructure-to-hcl2: when we see a map generate an attribute spec and not a block spec

this will alow to do

tags = {
 key = "value"
}

instead of

tags {
  key = "value"
}

This will also enable using variables directly for those tags

* generate code

* update tests
2020-04-14 16:05:13 +02:00
Megan Marsh 6fc3c4eb49 properly document how to set boot_wait to 0s 2020-04-07 16:43:33 -07:00
Jeff Escalante 9165be87da
packer.io prefix removal, html extension remove for in-code errors 2020-04-07 17:53:22 -04:00
Jeff Escalante 4afd107eeb
patch source files for extensions changes 2020-04-07 17:50:51 -04:00
Megan Marsh ca5814ab74 move proxy behind feature flag 2020-04-01 11:31:48 -07:00
Megan Marsh 65b64d04d0 remove docs about windows symlinks which are now inaccurage 2020-03-26 15:51:51 -07:00
Sylvia Moss e6368b9246
Fix azure winrm_password attribution and allow to set winrm_username (#8928) 2020-03-24 14:43:24 +01:00
Sylvia Moss 2319521aa5
Add iso config test for checksum from file specific case (#8897) 2020-03-18 11:32:51 +01:00
Wilken Rivera 7b705545d9
docs: Various doc clean-ups to fix code block formatting and syntax highlighting (#8868) 2020-03-12 15:05:08 +01:00
Sylvia Moss 76f13deaf4
Make template variables SSHPublicKey and SSHPrivateKey as strings (#8829) 2020-03-09 17:25:05 +01:00
Wilken Rivera e1a46ec293
Fix gosimple S1025 linting errors (#8838)
Remove unneeded use of fmt.Sprintf for variables that are already strings.
2020-03-04 15:31:30 -05:00
Lars Lehtonen f808d1d968
common/powershell: fix dropped error 2020-03-02 14:45:22 -08:00
Megan Marsh 9c9826ee4b
Merge pull request #8714 from williamb1024/hyperv-gen1-boot-order
WIP: Add Hyper-V builder `first_boot_device` setting to allow the selection of the initial device or device class used for booting the VM.
2020-03-02 12:27:25 -08:00
Ben Brown 0936f8bc03 Fix Hyper-V compacted disk size comparison
Prior to this the code compares the length of the path, which of course
doesn't change.
2020-03-02 09:55:13 +00:00
Megan Marsh 66a1cdb8d2 regenerate boot command code 2020-02-28 09:50:50 -08:00
William Brooks 7f38ce0686 test and correct gen2 SetFirstBootDeviceGen2 scripts 2020-02-21 11:09:49 -06:00
William Brooks dd8f4370c6 initial support for gen2 and fix driver_mock 2020-02-21 01:30:59 -06:00
William Brooks 5e1e4ec701 fmt && generate 2020-02-21 01:07:58 -06:00
William Brooks d7300f4635 Remove legacy_boot and replace with first_boot_device (initial) 2020-02-21 01:01:09 -06:00
Megan Marsh dde74232f2
Clearly document all template-engine-enabled options (#8770) 2020-02-20 11:05:27 +01:00
William 807f39284d
Merge pull request #2 from hashicorp/master
merge from hashicorp/packer
2020-02-15 23:13:38 -06:00
Wilken Rivera 9ec8b67392
Add golangci-lint to project (#8686)
* Add golangci-lint as linting tool

* Disable failing staticchecks to start; GitHub issue to handle coming soon

* Run `goimports -w` to repair all source files that have improperly
formatted imports

* makefile: Add ci-lint target to run on travis

This change adds a new make target for running golangci-lint on newly
added Go files only. This target is expected to run during Packer ci builds.

* .github/contributing: Add code linting instructions

* travis: Update job configuration to run parallel builds
2020-02-14 11:42:29 -05:00
Megan Marsh 00dfb79c88
Merge pull request #7627 from hashicorp/inplace_isos
Inplace isos
2020-02-11 11:19:10 -08:00
Adrien Delorme 08f394604c Update iso_config.go
use defaultGetterClient instead of getter.DefaultClient
2020-02-11 12:07:06 +01:00
Adrien Delorme cc3d941853 iso checksumming: use checksum or checksum url if set to handle all cases
fix #8322
2020-02-10 17:54:11 +01:00
William Brooks 31622b50ac applied fmt 2020-02-09 15:22:36 -06:00
William Brooks 55ae803852 Add Hyper-V support for Gen-1 boot order with ISO 2020-02-09 13:08:22 -06:00
Adrien Delorme 72c2731f7b Update step_download_test.go 2020-02-06 18:24:13 +01:00
Adrien Delorme 973a1ea103 remove comented code 2020-02-06 18:23:08 +01:00
Adrien Delorme f91429f256 fix goimports 2020-02-06 18:18:03 +01:00
Adrien Delorme d45eca5cdc update tests 2020-02-06 18:17:57 +01:00
Adrien Delorme a8e717ae09 ISOConfig.Prepare: fix ChecksumFromFile usage 2020-02-06 17:51:15 +01:00
Adrien Delorme 8e6bad209b try to use isos inplace whatever the os 2020-02-06 17:50:29 +01:00
Chris Cunningham e94ed9a683 update the note about Windows symlinks
GH-7534 and GH-7545 disabled the use of symlinks for copying local ISOs, 
per:

https://github.com/hashicorp/packer/blob/master/common/step_download.go#L106

Update the documentation to match, as without reading the source it is 
implied that this should work.
2020-02-06 17:38:57 +01:00
Adrien Delorme a19214afeb Allow to use isos in place 2020-02-06 17:07:58 +01:00
Megan Marsh dde7302265
Merge pull request #8689 from hashicorp/fix_8530
Add iso file name when targetPath is a directory
2020-02-04 13:43:09 -08:00
Moss f2c8e8491c Fix format 2020-02-04 18:22:43 +01:00
Moss e020da49f3 Add iso file name when targetPath is absolute 2020-02-04 18:06:47 +01:00
Wilken Rivera 561f02cc2f
builder/azure-arm: Update logic for setting subscriptionID (#8685)
* builder/azure-arm: Update logic for setting subscriptionID

Previously, when using managed identities, the Azure builder would set the SubscriptionID in the Prepare method. But would not update it after getting the updated SubscriptionID from the metadata server. This change updates the Run method to ensure a valid subscriptionID is saved to the statebag before continuing with an image build.

Co-authored-by: Paul Meyer <paul.meyer@outlook.com>
2020-02-04 10:54:58 -05:00
Sylvia Moss dc31bad539
Sharing info with post-processors via artifact (#8632) 2020-01-30 11:27:58 +01:00
Moss 0566f1f999 Extract http ip discover to a new step 2020-01-27 17:06:56 +01:00
Sylvia Moss 0b7251a4bb
Share .Device and .MountPath between builders, provisioners and post-processors (#8621) 2020-01-20 16:29:38 +01:00
Sylvia Moss 0677b02e18
Share SourceImageName with provisioners and manifest post-processor (#8603) 2020-01-16 12:04:03 +01:00
Megan Marsh 90bdcf58bd update step_download to return an ActionContinue if the URls field is empty. this allows us to simplify the hyperv builder, and is still safe because all other builders and uses of step_download already validate that the iso url is not empty if that's what they need, most of them inside of the IsoConfig prepare function. 2020-01-07 10:45:24 -08:00
Adrien Delorme 4b7132c87c Merge remote-tracking branch 'origin/master' into sharing_info 2019-12-17 11:57:09 +01:00