HCL2: version block: test validation & document version/availability (#10298)

* HCL2: Test that the packer block passes in packer validate

* HCL2: Test invalid packer blocks are invalid

* docs: state from which version the packer block is available
This commit is contained in:
Adrien Delorme 2020-11-23 16:27:26 +01:00 committed by GitHub
parent c5da8c5c37
commit 73b7499811
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 0 deletions

View File

@ -1,3 +1,7 @@
packer {
required_version = ">= v1.0.0"
}
source "file" "chocolate" {
target = "chocolate.txt"
content = "chocolate"

View File

@ -0,0 +1,3 @@
packer {
version = ">= v1.0.0"
}

View File

@ -26,6 +26,9 @@ func TestValidateCommand(t *testing.T) {
// wrong version field
{path: filepath.Join(testFixture("version_req", "wrong_field_name")), exitCode: 1},
// wrong packer block
{path: filepath.Join(testFixture("validate", "invalid_packer_block.pkr.hcl")), exitCode: 1},
}
for _, tc := range tt {

View File

@ -11,6 +11,8 @@ description: |-
`@include 'from-1.5/beta-hcl2-note.mdx'`
-> **Note:** The Packer block is only available in Packer v1.6.5 and later.
The `packer` configuration block type is used to configure some
behaviors of Packer itself, such as the minimum required Packer version needed to
apply your configuration.