Skip to content

Commit

Permalink
Fix cd_content is ignored (#30)
Browse files Browse the repository at this point in the history
* Fix cd_content is ignored

This implements support for cd_content
(https://www.packer.io/docs/builders/vmware/vmx#cd_content)
by adding an omitted struct member. Closes #29

* add cd_content test

Co-authored-by: Adrien Delorme <azr@users.noreply.github.com>
  • Loading branch information
puetzk and azr authored Aug 9, 2021
1 parent 7b40a76 commit e38fb92
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
5 changes: 3 additions & 2 deletions builder/vmware/iso/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook)
Label: b.config.FloppyConfig.FloppyLabel,
},
&commonsteps.StepCreateCD{
Files: b.config.CDConfig.CDFiles,
Label: b.config.CDConfig.CDLabel,
Files: b.config.CDConfig.CDFiles,
Content: b.config.CDConfig.CDContent,
Label: b.config.CDConfig.CDLabel,
},
&vmwcommon.StepRemoteUpload{
Key: "floppy_path",
Expand Down
5 changes: 3 additions & 2 deletions builder/vmware/vmx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook)
Label: b.config.FloppyConfig.FloppyLabel,
},
&commonsteps.StepCreateCD{
Files: b.config.CDConfig.CDFiles,
Label: b.config.CDConfig.CDLabel,
Files: b.config.CDConfig.CDFiles,
Content: b.config.CDConfig.CDContent,
Label: b.config.CDConfig.CDLabel,
},
&vmwcommon.StepRemoteUpload{
Key: "floppy_path",
Expand Down
18 changes: 18 additions & 0 deletions builder/vmware/vmx/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,21 @@ func TestBuilderPrepare_InvalidFloppies(t *testing.T) {
t.Fatalf("Multierror should work and report 2 errors")
}
}

func TestBuilderPrepare_CDContent(t *testing.T) {
var b Builder
config := testConfig(t)
config["cd_content"] = map[string]string{
"something.txt": "foo!",
}
b = Builder{}
_, _, errs := b.Prepare(config)
if errs != nil {
t.Fatalf("using cd_content should just work")
}

if len(b.config.CDConfig.CDContent) == 0 {
t.Fatalf("cd_content is empty")
}

}

0 comments on commit e38fb92

Please sign in to comment.