Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Packer
Commits
76c10596
Commit
76c10596
authored
3 years ago
by
Megan Marsh
Browse files
Options
Download
Email Patches
Plain Diff
add tests, and simplify code
parent
cdde5cbb
main
actions/fix-check-links
azr/mini-dag
backport/brk.feat/remove-website-code/horribly-finer-bison
backport/clarify-builders-page/promptly-fun-cheetah
backport/nywilken/update-plugins-link/steadily-ace-bear
backport/update-docs-hcp-packer-ga/deeply-capital-malamute
backport/update-docs-hcp-packer-ga/slowly-golden-narwhal
backport/update-docs-hcp-packer-ga/solely-renewing-chipmunk
brk.feat/mdx-v2
bump_hcp_sdk_go
crt-onboarding-test
dependabot/github_actions/slackapi/slack-github-action-1.19.0
hcp-packer-registry-pps
improved-error-handling-hcp-packer
linode-hcp-ready
nywilken/update-external-plugins
release/1.7.x
release/1.8.x
stable-website
update-alert-banner
validate_locals
wilken/hcl2_upgrade-legacy-mode
wilken/implicitly-required-plugins-legacy-mode
wilken/packer-legacy-mode
zs.draft-empty-page-check-script
v1.8.0
v1.7.10
v1.7.9
v1.7.8
v1.7.7
nightly
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
hcl2template/testdata/complete/sources.pkr.hcl
+1
-1
hcl2template/testdata/complete/sources.pkr.hcl
hcl2template/types.packer_config_test.go
+35
-1
hcl2template/types.packer_config_test.go
hcl2template/types.source.go
+1
-4
hcl2template/types.source.go
with
37 additions
and
6 deletions
+37
-6
hcl2template/testdata/complete/sources.pkr.hcl
+
1
-
1
View file @
76c10596
...
...
@@ -13,7 +13,7 @@ source "amazon-ebs" "ubuntu-1604" {
}
source
"virtualbox-iso"
"ubuntu-1204"
{
string
=
"
string
"
string
=
"
${source.name}-${source.type}
"
int
=
42
int64
=
43
bool
=
true
...
...
This diff is collapsed.
Click to expand it.
hcl2template/types.packer_config_test.go
+
35
-
1
View file @
76c10596
...
...
@@ -3,9 +3,11 @@ package hcl2template
import
(
"path/filepath"
"testing"
"time"
"github.com/hashicorp/go-version"
packersdk
"github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/hashicorp/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer/hcl2template/addrs"
.
"github.com/hashicorp/packer/hcl2template/internal"
hcl2template
"github.com/hashicorp/packer/hcl2template/internal"
...
...
@@ -204,7 +206,39 @@ func TestParser_complete(t *testing.T) {
&
packer
.
CoreBuild
{
Type
:
"virtualbox-iso.ubuntu-1204"
,
Prepared
:
true
,
Builder
:
basicMockBuilder
,
Builder
:
&
MockBuilder
{
Config
:
MockConfig
{
NestedMockConfig
:
NestedMockConfig
{
// interpolates source and type in builder
String
:
"ubuntu-1204-virtualbox-iso"
,
Int
:
42
,
Int64
:
43
,
Bool
:
true
,
Trilean
:
config
.
TriTrue
,
Duration
:
10
*
time
.
Second
,
MapStringString
:
map
[
string
]
string
{
"a"
:
"b"
,
"c"
:
"d"
,
},
SliceString
:
[]
string
{
"a"
,
"b"
,
"c"
,
},
SliceSliceString
:
[][]
string
{
{
"a"
,
"b"
},
{
"c"
,
"d"
},
},
Tags
:
[]
MockTag
{},
Datasource
:
"string"
,
},
Nested
:
builderBasicNestedMockConfig
,
NestedSlice
:
[]
NestedMockConfig
{
builderBasicNestedMockConfig
,
builderBasicNestedMockConfig
,
},
},
},
Provisioners
:
[]
packer
.
CoreBuildProvisioner
{
{
PType
:
"shell"
,
...
...
This diff is collapsed.
Click to expand it.
hcl2template/types.source.go
+
1
-
4
View file @
76c10596
...
...
@@ -111,10 +111,7 @@ func (cfg *PackerConfig) startBuilder(source SourceUseBlock, ectx *hcl.EvalConte
body
:=
source
.
Body
// Add known values to source accessor in eval context.
ectx
.
Variables
[
sourcesAccessor
]
=
cty
.
ObjectVal
(
map
[
string
]
cty
.
Value
{
"type"
:
cty
.
StringVal
(
source
.
Type
),
"name"
:
cty
.
StringVal
(
source
.
Name
),
})
ectx
.
Variables
[
sourcesAccessor
]
=
cty
.
ObjectVal
(
source
.
ctyValues
())
decoded
,
moreDiags
:=
decodeHCL2Spec
(
body
,
ectx
,
builder
)
diags
=
append
(
diags
,
moreDiags
...
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help