Commit Graph

14546 Commits

Author SHA1 Message Date
Megan Marsh 52f03de0f0 adding tests 2020-03-11 10:49:45 -07:00
Megan Marsh 063dd5c133 fix interpolation when env vars interpolate before user vars 2020-03-11 09:55:40 -07:00
Wilken Rivera b9f1b3c8d4
Fix gosimple S1005 linting issue (#8870)
Results before change
```
⇶  golangci-lint run ./... --disable-all --enable=gosimple | grep 1005
fix/fixer_comm_config.go:48:4: S1005: should write `sshHostPortMinRaw := builders["ssh_host_port_min"]` instead of `sshHostPortMinRaw, _ := builders["ssh_host_port_min"]` (gosimple)
fix/fixer_comm_config.go:64:4: S1005: should write `sshHostPortMaxRaw := builders["ssh_host_port_max"]` instead of `sshHostPortMaxRaw, _ := builders["ssh_host_port_max"]` (gosimple)
fix/fixer_comm_config.go:81:4: S1005: should write `sshSkipNatMappingRaw := builders["ssh_skip_nat_mapping"]` instead of `sshSkipNatMappingRaw, _ := builders["ssh_skip_nat_mapping"]` (gosimple)
packer/artifact_mock.go:47:2: S1005: should write `value := a.StateValues[name]` instead of `value, _ := a.StateValues[name]` (gosimple)
packer/artifact_test.go:31:2: S1005: should write `value := a.state[name]` instead of `value, _ := a.state[name]` (gosimple)
```

Results after change
```
```
2020-03-11 10:30:08 +01:00
Wilken Rivera 66ad6f3483
builders: Fix gosimple S1007 linting issue (#8871)
Results before change
```
⇶  golangci-lint run ./... --disable-all --enable=gosimple | grep 1007
builder/alicloud/ecs/image_config.go:208:9: S1007: should use raw string
post-processor/vsphere-template/step_mark_as_template.go:130:8: S1007: shape twice (gosimple)
builder/azure/arm/config.go:58:27: S1007: should use raw string (`...`)
builder/azure/arm/config.go:59:27: S1007: should use raw string (`...`)
builder/qemu/driver.go:192:15: S1007: should use raw string (`...`)
```

Results after change
```
⇶  golangci-lint run ./... --disable-all --enable=gosimple | grep 1007
```
2020-03-11 10:29:22 +01:00
r_takaishi 4bb4f7617f need white spaces 2020-03-11 11:04:59 +09:00
r_takaishi 0230c078e0 write docs 2020-03-11 10:53:59 +09:00
r_takaishi 34bb0429d0 keyboard-interactive used when ssh_bastion_host is true. 2020-03-11 10:37:57 +09:00
Megan Marsh 072a71b419
Merge pull request #8863 from hashicorp/update_go-cty_regex
import new replace and regex_replace funcs from go-cty + documentation
2020-03-10 13:09:09 -07:00
Megan Marsh e518a0a8b7
Merge branch 'master' into update_go-cty_regex 2020-03-10 10:52:42 -07:00
Megan Marsh 68e083603d
Update website/source/docs/configuration/from-1.5/functions/string/replace.html.md
Co-Authored-By: Wilken Rivera <dev@wilkenrivera.com>
2020-03-10 10:51:25 -07:00
Megan Marsh 8a1caaa804
Merge pull request #8837 from hashicorp/fix_8730
Fix crash when an unset variable is used
2020-03-10 10:40:48 -07:00
Adrien Delorme 0c45bd8b4f import new replace and regex replace funcs from go-cty + documentation 2020-03-10 16:14:25 +01:00
Adrien Delorme d4d30127a3 Update variables.html.md 2020-03-10 14:53:48 +01:00
Adrien Delorme c4349f5a33 document variables behaviours with tables 2020-03-10 14:51:17 +01:00
Jaspal Chauhan b204687de9
Add VBoxManage config section to VirtualBox OVF builder docs (#8861) 2020-03-10 11:11:27 +01:00
Adrien Delorme 631f402d1e Merge branch 'master' into fix_8730 2020-03-09 17:49:33 +01:00
Megan Marsh 7873cabf63
Merge pull request #8858 from hashicorp/fix_8791
update spot price docs
2020-03-09 09:31:56 -07:00
Adrien Delorme 0ccff0d5b9 all variables must have a value.
A variable's default value can be set to null to force user to set it.
2020-03-09 17:25:56 +01:00
Sylvia Moss 76f13deaf4
Make template variables SSHPublicKey and SSHPrivateKey as strings (#8829) 2020-03-09 17:25:05 +01:00
Megan Marsh 4133acbdf3 update spot price docs 2020-03-09 08:46:30 -07:00
Sylvia Moss 4bdf30165a
Fix example json format in ansible provisioner doc (#8856) 2020-03-09 16:40:56 +01:00
Adrien Delorme 6d8cce501e tweak validation & add tests 2020-03-09 16:16:59 +01:00
Lars Lehtonen 74a94d8547
helper/builder/testing: prune unused functions (#8852) 2020-03-09 10:46:32 +01:00
r_takaishi a0dfcf3715 use log 2020-03-09 11:58:53 +09:00
r_takaishi 0c6249df7f use tty when IsTerminal is false 2020-03-09 11:54:53 +09:00
Adrien Delorme 9e6c94e141
circleci: VersionPrerelease: show tag or branch name and hash when building binary (#8850)
VersionPrerelease=${CIRCLE_TAG:=${CIRCLE_BRANCH}}-${CIRCLE_SHA1:0:9}"
2020-03-06 14:03:18 -05:00
jnsc 764b4cb50a
updated link to GuestOsIdentifier (#8849)
Co-authored-by: Adrien Delorme <adrien.delorme@icloud.com>
2020-03-06 15:30:11 +01:00
Wilken Rivera 9403b48a52
hcl2template/types.variables: Update logic for parsing literal value variables (#8834)
* hcl2template/types.variables: Update logic for parsing literal value variables

In running tests via the CLI it was determined that when using the variable block with no explicit type assigned the type of the default
value was not being set within the map. This change updates the `decodeConfig` method so that a type is always set for any defined variable if not specified.

The second change is to properly handle the evaluation of basic variable types (e.g String, Number, Bool). Previously variables defined on the
CLI or via PKR_VAR required some additional quoting to for proper evaluation. This change fixes that issue so that it works like it does in Terraform :)

Build results before the change
```
⇶  PKR_VAR_example='["one","two"]' ~/bin/packer build -var 'foo=home' .
Error: Variables not allowed

  on <value for var.foo from arguments> line 1:
  (source code not available)

Variables may not be used here.

==> Builds finished but no artifacts were created.

```

Build results after the change
```
⇶  PKR_VAR_example='["one","two"]' ~/bin/packer build -var 'foo="home"' .
null: output will be in this color.

==> null: Running local shell script: /tmp/packer-shell885249462
    null: two
    null: home
Build 'null' finished.

==> Builds finished. The artifacts of successful builds are:
--> null: Did not export anything. This is the null builder

⇶  ~/bin/packer build -var 'foo=home' -var 'example=["one","another variable"]' .
null: output will be in this color.

==> null: Running local shell script: /tmp/packer-shell123467506
    null: another variable
    null: home
Build 'null' finished.

==> Builds finished. The artifacts of successful builds are:
--> null: Did not export anything. This is the null builder

```

* tests/hcl2template/types.variables: Update test to use Bool

Turns out a string value won't actually complain if it's given a non
string looking value. It will just covert the value to a string literal
so using a type Bool which should fail if given anything that is not
true or false.

* tests/hcl2template/types.variables: Update unit tests

During testing it was found that by default the variable stanza were defaulting to a cty.NilType, and not the Type of it's default value.
This change sets the default type of the defined variable to ensure variable evaluation behaviors correctly.

* Add a simple cty.Bool test case

* tests/hcl2template/types.variables:  Enable quoted_string test case

* Update hcl2template/types.variables.go

space

Co-authored-by: Adrien Delorme <azr@users.noreply.github.com>
2020-03-06 15:12:26 +01:00
r_takaishi 4447d28938 fix lint 2020-03-06 15:23:06 +09:00
r_takaishi 7cdb2e89e4 use os.Stdin 2020-03-06 14:34:17 +09:00
r_takaishi 92c36eea8c delete unnecessary conversion 2020-03-06 14:22:08 +09:00
r_takaishi e2df4a80f8 support keyboard interactive auth 2020-03-06 12:38:31 +09:00
Wilken Rivera 698924f246
vSphere ISO supports more common options (#8845)
The `convert_to_template` and `create_snapshot` are supported across
both builders, but currently only shown in the vSphere Clone docs, this adds
them to it.
2020-03-05 15:04:15 -05:00
Megan Marsh 7e382d0df7
Merge pull request #8828 from mvitaly/fix_8816
Remove all floppy controllers before adding a new one
2020-03-05 09:35:20 -08:00
Megan Marsh 8832b3e2ca
Merge pull request #8787 from jhawk28/vsphere_iso_multiple_disks
(vsphere-iso) add ability to define multiple disks
2020-03-04 15:17:54 -08: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
Sylvia Moss 717b9047db
Fix boot command link in ssh communicator doc (#8839) 2020-03-04 16:28:39 +01:00
Joshua Foster 1dbe5abc14 update documentation based on feedback 2020-03-04 09:48:01 -05:00
Joshua Foster d7230827cd (vsphere-iso) add ability to define multiple disks
Closes #8749
2020-03-04 09:48:01 -05:00
Adrien Delorme e195c627fb vendor vendors 2020-03-04 13:50:15 +01:00
Adrien Delorme f013164298 bup modules 2020-03-04 13:49:38 +01:00
Adrien Delorme e9d3826219 variables: use Range instead of Block
because a variable can be defined in the Locals block
2020-03-04 13:19:07 +01:00
Adrien Delorme 9b649594c6 update tests 2020-03-04 13:01:18 +01:00
Adrien Delorme 8482c6c2e6 evaluateLocalVariable: also pass the variable name 2020-03-04 13:01:04 +01:00
Adrien Delorme bd3112fa7c parseLocalVariables: simplify loop 2020-03-04 13:00:51 +01:00
Adrien Delorme 23b940dbd5 fix this ! 2020-03-04 12:42:56 +01:00
Adrien Delorme e851050774 don't force to set unused variables too 2020-03-04 12:32:29 +01:00
Adrien Delorme 382f209b07 Update types.packer_config.go 2020-03-04 12:30:05 +01:00
Adrien Delorme 59cc246942 Merge remote-tracking branch 'origin/master' into fix_8730 2020-03-04 12:30:01 +01:00
Vitaly Polonetsky 25f59a1592 Add a simple test for the call to remove all floppy controllers 2020-03-03 20:58:09 -08:00