Skip to content

Commit e22eb3a

Browse files
committed
packer: export template RawConfig
1 parent 02987f6 commit e22eb3a

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

packer/template.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type RawBuilderConfig struct {
3838
Name string
3939
Type string
4040

41-
rawConfig interface{}
41+
RawConfig interface{}
4242
}
4343

4444
// RawPostProcessorConfig represents a raw, unprocessed post-processor
@@ -47,7 +47,7 @@ type RawBuilderConfig struct {
4747
type RawPostProcessorConfig struct {
4848
Type string
4949
KeepInputArtifact bool `mapstructure:"keep_input_artifact"`
50-
rawConfig interface{}
50+
RawConfig interface{}
5151
}
5252

5353
// RawProvisionerConfig represents a raw, unprocessed provisioner configuration.
@@ -57,7 +57,7 @@ type RawProvisionerConfig struct {
5757
Type string
5858
Override map[string]interface{}
5959

60-
rawConfig interface{}
60+
RawConfig interface{}
6161
}
6262

6363
// ParseTemplate takes a byte slice and parses a Template from it, returning
@@ -150,7 +150,7 @@ func ParseTemplate(data []byte) (t *Template, err error) {
150150
// itself doesn't know about, and it will cause a validation error.
151151
delete(v, "name")
152152

153-
raw.rawConfig = v
153+
raw.RawConfig = v
154154

155155
t.Builders[raw.Name] = raw
156156
}
@@ -186,7 +186,7 @@ func ParseTemplate(data []byte) (t *Template, err error) {
186186
continue
187187
}
188188

189-
config.rawConfig = pp
189+
config.RawConfig = pp
190190
}
191191
}
192192

@@ -215,7 +215,7 @@ func ParseTemplate(data []byte) (t *Template, err error) {
215215
// actively reject them as invalid configuration.
216216
delete(v, "override")
217217

218-
raw.rawConfig = v
218+
raw.RawConfig = v
219219
}
220220

221221
if len(t.Builders) == 0 {
@@ -365,7 +365,7 @@ func (t *Template) Build(name string, components *ComponentFinder) (b Build, err
365365
current[i] = coreBuildPostProcessor{
366366
processor: pp,
367367
processorType: rawPP.Type,
368-
config: rawPP.rawConfig,
368+
config: rawPP.RawConfig,
369369
keepInputArtifact: rawPP.KeepInputArtifact,
370370
}
371371
}
@@ -388,7 +388,7 @@ func (t *Template) Build(name string, components *ComponentFinder) (b Build, err
388388
}
389389

390390
configs := make([]interface{}, 1, 2)
391-
configs[0] = rawProvisioner.rawConfig
391+
configs[0] = rawProvisioner.RawConfig
392392

393393
if rawProvisioner.Override != nil {
394394
if override, ok := rawProvisioner.Override[name]; ok {
@@ -403,7 +403,7 @@ func (t *Template) Build(name string, components *ComponentFinder) (b Build, err
403403
b = &coreBuild{
404404
name: name,
405405
builder: builder,
406-
builderConfig: builderConfig.rawConfig,
406+
builderConfig: builderConfig.RawConfig,
407407
builderType: builderConfig.Type,
408408
hooks: hooks,
409409
postProcessors: postProcessors,

packer/template_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,17 @@ func TestParseTemplate_BuilderWithName(t *testing.T) {
165165
assert.True(ok, "should have bob builder")
166166
assert.Equal(builder.Type, "amazon-ebs", "builder should be amazon-ebs")
167167

168-
rawConfig := builder.rawConfig
169-
if rawConfig == nil {
168+
RawConfig := builder.RawConfig
169+
if RawConfig == nil {
170170
t.Fatal("missing builder raw config")
171171
}
172172

173173
expected := map[string]interface{}{
174174
"type": "amazon-ebs",
175175
}
176176

177-
if !reflect.DeepEqual(rawConfig, expected) {
178-
t.Fatalf("bad raw: %#v", rawConfig)
177+
if !reflect.DeepEqual(RawConfig, expected) {
178+
t.Fatalf("bad raw: %#v", RawConfig)
179179
}
180180
}
181181

@@ -333,7 +333,7 @@ func TestParseTemplate_Provisioners(t *testing.T) {
333333
assert.NotNil(result, "template should not be nil")
334334
assert.Length(result.Provisioners, 1, "should have one provisioner")
335335
assert.Equal(result.Provisioners[0].Type, "shell", "provisioner should be shell")
336-
assert.NotNil(result.Provisioners[0].rawConfig, "should have raw config")
336+
assert.NotNil(result.Provisioners[0].RawConfig, "should have raw config")
337337
}
338338

339339
func TestParseTemplate_Variables(t *testing.T) {
@@ -631,17 +631,17 @@ func TestTemplate_Build_ProvisionerOverride(t *testing.T) {
631631
t.Fatalf("err: %s", err)
632632
}
633633

634-
rawConfig := template.Provisioners[0].rawConfig
635-
if rawConfig == nil {
634+
RawConfig := template.Provisioners[0].RawConfig
635+
if RawConfig == nil {
636636
t.Fatal("missing provisioner raw config")
637637
}
638638

639639
expected := map[string]interface{}{
640640
"type": "test-prov",
641641
}
642642

643-
if !reflect.DeepEqual(rawConfig, expected) {
644-
t.Fatalf("bad raw: %#v", rawConfig)
643+
if !reflect.DeepEqual(RawConfig, expected) {
644+
t.Fatalf("bad raw: %#v", RawConfig)
645645
}
646646

647647
builder := testBuilder()

0 commit comments

Comments
 (0)