Commit Graph

15121 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
Megan Marsh 3dc4ba2d68
Json vs HCL2 parity refactor (#9301)
* refactor so that json and hcl2 templates are both prepared in the same place in the build call, to make code easier to reason about. Remove overly verbose error output which isn't useful in vast majority of cases

* fix tests

* check err msg

* hcl2template.PackerConfig.GetBuilds: raise a diagnostic in case the packer core build perpare call errors

Co-authored-by: Adrien Delorme <adrien.delorme@icloud.com>
2020-05-28 10:43:58 +02:00
Megan Marsh d3859cf592
Merge pull request #9305 from hashicorp/azr-docs-fix-guide
HCL2: Update guide example to fix broken example
2020-05-27 16:04:31 -07:00
Megan Marsh 7b9a33d385
Merge pull request #9100 from jhawk28/bug_9076
dont set the host for the datastore upload
2020-05-27 15:39:09 -07:00
Joshua Foster 828440d852 rebase and run generate 2020-05-27 15:05:23 -07:00
Joshua Foster 43714049e8 add set_host_for_datastore_uploads flag 2020-05-27 15:00:08 -07:00
Joshua Foster 9895f90451 dont set the host for the datastore upload 2020-05-27 15:00:08 -07:00
Adrien Delorme 851b354ac9 more fixes 2020-05-27 16:51:44 +02:00
Adrien Delorme 4d8a5e1c72
Update from-json-v1.mdx 2020-05-27 16:40:47 +02:00
Megan Marsh 077d34f12c
Merge pull request #9279 from gamethis/fix_arg_order
[WIP] Anisble-Remote fix arg order
2020-05-26 16:03:31 -07:00
Megan Marsh 01839e272e
Merge pull request #9277 from nitrocode/add-source-ami-creation-date
Added SourceAMICreationDate
2020-05-26 12:24:47 -07:00
nitrocode 6d29ec956b Added SourceAMICreationDate 2020-05-26 15:04:03 -04:00
Wilken Rivera 230fa34909
Merge pull request #9273 from hashicorp/fix_secretsmanager_tests
un-bypass secretsmanager tests
2020-05-26 12:37:45 -04:00
Megan Marsh 4a058dfd19 un-bypass secretsmanager tests 2020-05-26 11:50:46 -04:00
Wilken Rivera 80cd6b4047
Merge pull request #9286 from overdrive3000/fix-multikey
Fix aws_secretsmanager multiple keys support
2020-05-26 11:48:52 -04:00
Adrien Delorme a2e9439ee6
provisioner/salt-masterless: ignore the CmdArgs field in hcl2 (#9290)
fix #9233
2020-05-26 16:46:31 +02:00
Alexandra Freeman 3e7d0a5388
Update index.jsx (#9263)
Updating Community resources to move Forum to the top, remove IRC and update language for general help. These changes are to align with other .io sites, and the initiative to point the community to a consolidated location (Discuss Forum). 


Co-authored-by: Wilken Rivera <dev@wilkenrivera.com>
2020-05-26 10:35:04 -04:00
Wilken Rivera 1e90165a56
Add source URL to test fixture script (#9296) 2020-05-26 10:24:12 -04:00
Sylvia Moss 601d3638f6
add communicator config reference to hyperv docs (#9289) 2020-05-25 15:18:14 +02:00
Lukas Kämmerling 26d309c88c
Clarify the correct usage of the snapshot_name field on the hcloud builder (#9276) 2020-05-25 14:52:13 +02:00
Megan Marsh 5dfd2a763e
send logs about floppy failure directly to UI not just logs (#9272) 2020-05-25 12:02:29 +02:00
Megan Marsh fecb040bf4
fix bug where build vars couldn't be properly interpolated into this execute command (#9275) 2020-05-25 11:54:27 +02:00
jmarcelletti 67df9f778a
Update index.mdx (#9278)
Unclosed quotes kill builds
2020-05-25 11:18:03 +02:00
Juan Mesa cc34da365a Add error check
Thrown an error if no key is given when secret has mutliple values
2020-05-23 15:15:06 +02:00
Lane, Larry f4254e9cbf updated test 2020-05-22 08:12:14 -05:00
Lane, Larry c689eb9694 added test 2020-05-22 08:07:25 -05:00
Lane, Larry de12432e6b add test 2020-05-22 07:58:57 -05:00
Lane, Larry e6670fc4a0 fix arg order 2020-05-21 21:15:13 -05:00
Megan Marsh 688ed63edf update changelog 2020-05-21 11:42:28 -07:00
Megan Marsh 8f73a44410 stop failing flaky test until I can fix it 2020-05-21 10:24:42 -07:00
Megan Marsh 334f399ee3
Merge pull request #9040 from hashicorp/powershell-exit-code-fix-4916
provisioner/powershell: Update default execute command to handle script errors
2020-05-21 09:55:25 -07:00
Megan Marsh 45a5d28bad
Merge pull request #9159 from rgl/feature-qemu-add-support-for-network-bridge
qemu: add support for using a network bridge
2020-05-21 09:52:49 -07:00
Megan Marsh 082d806b1f fix httpip acquisition 2020-05-21 09:39:54 -07:00
Wilken Rivera 2e326ef334 Switch back to call operator as opposed to dot sourcing
* Ensure child scope doesn't conflict with parent scope
* Add elevated user options to tests case.
2020-05-21 09:07:55 -04:00
Wilken Rivera 38f799df3e Add conditional to check if LastExitCode is defined
* Add broken requires statement test case
* Add test case to reproduce invalid LastExitCode
2020-05-21 09:07:43 -04:00
Wilken Rivera 35df3914d2 provisioner/powershell: Update default execute command to handle script errors
This change sets the ErrorActionPreference and wraps the script execution in a Try/Catch statement so that the provisioner can capture any errors encountered when running the script. In addition to the try/catch the `&` operator is replaced by the `.` sourcing operator to ensure the script is executed in the same scope as the parent command (so that errors bubble up properly).

Tests after change
```
⇶  ACC_TEST_BUILDERS=amazon-ebs ACC_TEST_PROVISIONERS=powershell go test ./provisioner/powershell/... -timeout=1h
ok      github.com/hashicorp/packer/provisioner/powershell      915.865s
```
2020-05-21 09:05:43 -04:00
Wilken Rivera 13e0c1a097 tests/provisioner/powershell: Add acceptance test to reproduce issue 4916 2020-05-21 09:05:43 -04:00
Rui Lopes 06fad6cc4f qemu: add support for using a network bridge 2020-05-20 16:46:32 -07:00
Megan Marsh 6ad67f6800 update changelog 2020-05-20 15:10:40 -07:00
Megan Marsh b3ece95f27
Merge pull request #9254 from ad-m/hyperone-builder-hcl
HCL compliance for HyperOne builder
2020-05-20 13:15:21 -07:00
Megan Marsh 782342a707
Merge pull request #9202 from overdrive3000/improve-secrets-manager
Add support for specifying key to fetch from AWS Secrets Manager
2020-05-20 13:13:28 -07:00
Sylvia Moss be9dbaacd7
Interpolate generatedData in the Inspec provisioner (#9262)
* Interpolate generatedData in the Inspec provisioner

* Add inspec license section to inspec docs

* add user arg if user config it not empty

* increase resource size for check-lint pipeline

* update changelog

* Update provisioner/inspec/provisioner.go

* Update provisioner/inspec/provisioner.go

Co-authored-by: Megan Marsh <megan@hashicorp.com>
2020-05-20 15:43:41 -04:00
Wilken Rivera c084be974b
Merge pull request #9264 from hashicorp/update-cty-funcs
Update github.com/hashicorp/go-cty-funcs to master
2020-05-20 15:10:09 -04:00
Megan Marsh 24dd7e9dbb
Merge pull request #9257 from hashicorp/azr-hcl2-use-source-type-and-name
HCL2: use source type and name as Name of a CoreBuild
2020-05-20 11:36:15 -07:00
Megan Marsh 3c782e9d03
Merge pull request #9239 from hashicorp/enable_artifice
Add Artifice postprocessor ID to valid artifacts for postprocessors t…
2020-05-20 10:46:44 -07:00
Adrien Delorme 5fdd1d1dee get github.com/hashicorp/go-cty-funcs@0d04eb807361 2020-05-20 15:51:34 +02:00
Adrien Delorme b01fb30c36 Update CHANGELOG.md 2020-05-20 12:28:13 +02:00
Adrien Delorme 1e8e8a4e45 Update CHANGELOG.md 2020-05-20 12:27:54 +02:00
Wilken Rivera d3aa53c9da
docs/hcl2: Update HCL2 beta note link (#9258)
This change updates the Beta notes on the Packer docs site with a link
to the pinned HCL2 implementations list issue.

Closes #9175
2020-05-20 12:24:45 +02:00