diff --git a/command/inspect_test.go b/command/inspect_test.go index 27f8474da..573b99680 100644 --- a/command/inspect_test.go +++ b/command/inspect_test.go @@ -29,6 +29,10 @@ local.fruit: "banana" > : + sources: + + null.builder + provisioners: shell-local @@ -38,7 +42,7 @@ local.fruit: "banana" `}, - {[]string{"inspect", "-var=fruit=peach", filepath.Join(testFixture("hcl"), "vars", "fruit_string.pkr.hcl")}, nil, `Packer Inspect: HCL2 mode + {[]string{"inspect", "-var=fruit=peach", filepath.Join(testFixture("hcl"), "inspect", "fruit_string.pkr.hcl")}, nil, `Packer Inspect: HCL2 mode > input-variables: @@ -49,6 +53,39 @@ var.fruit: "peach" [debug: {Type:cty.String,CmdValue:peach,VarfileValue:null,Env > builds: +`}, + {[]string{"inspect", "-var=fruit=peach", filepath.Join(testFixture("hcl"), "inspect")}, nil, `Packer Inspect: HCL2 mode + +> input-variables: + +var.fruit: "peach" [debug: {Type:cty.String,CmdValue:peach,VarfileValue:null,EnvValue:null,DefaultValue:banana}] + +> local-variables: + + +> builds: + + > aws_example_builder: + + > Description: The builder of clouds !! + +Use it at will. + + + sources: + + amazon-ebs.example-1 + + amazon-ebs.example-2 + + provisioners: + + shell + + post-processors: + + manifest + `}, } diff --git a/command/test-fixtures/hcl/inspect/aws-builds.pkr.hcl b/command/test-fixtures/hcl/inspect/aws-builds.pkr.hcl new file mode 100644 index 000000000..60385b31f --- /dev/null +++ b/command/test-fixtures/hcl/inspect/aws-builds.pkr.hcl @@ -0,0 +1,29 @@ + + +build { + name = "aws_example_builder" + description = <", i) } fmt.Fprintf(out, "\n > %s:\n", name) + if build.Description != "" { + fmt.Fprintf(out, "\n > Description: %s\n", build.Description) + } + fmt.Fprintf(out, "\n sources:\n") + if len(build.Sources) == 0 { + fmt.Fprintf(out, "\n \n") + } + for _, source := range build.Sources { + fmt.Fprintf(out, "\n %s\n", source) + } fmt.Fprintf(out, "\n provisioners:\n\n") if len(build.ProvisionerBlocks) == 0 { fmt.Fprintf(out, " \n") @@ -485,7 +495,7 @@ func (p *PackerConfig) printBuilds() string { fmt.Fprintf(out, " \n") } for _, pp := range build.PostProcessors { - str := strings.Join([]string{pp.PType, pp.PName}, ".") + str := pp.PType if pp.PName != "" { str = strings.Join([]string{pp.PType, pp.PName}, ".") }