Skip to content

Commit aa20c5f

Browse files
committed
Add working_direcotory
1 parent 4bff548 commit aa20c5f

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ sample is [here](./sample)
3333
- mitamae_version (string) : MItamae version. By default this is v1.4.5.
3434
- bin_dir (string) : bin_dir is is the path to download MItamae. By default this is `/usr/local/bin`
3535
- option (string) : It is an option when execute `mitamae local`. For example '-l debug'
36+
- working_directory (string): specify the directory at runtime.
37+

mitamae_provisioner.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ type Config struct {
2626

2727
RecipePath string `mapstructure:"recipe_path"`
2828

29+
WorkingDirectory string `mapstructure:"working_directory"`
30+
2931
ctx interpolate.Context
3032
}
3133

@@ -136,7 +138,11 @@ func (mp *MitamaeProvisioner) execRecipe(ui packer.Ui, comm packer.Communicator,
136138
binPath := fmt.Sprintf("%s/%s", mp.config.BinDir, filename)
137139

138140
var cmd packer.RemoteCmd
139-
cmd.Command = fmt.Sprintf("%s local %s %s", binPath, mp.config.Option, mp.config.RecipePath)
141+
command := fmt.Sprintf("%s local %s %s", binPath, mp.config.Option, mp.config.RecipePath)
142+
if mp.config.WorkingDirectory != "" {
143+
command = fmt.Sprintf("cd %s && ", mp.config.WorkingDirectory) + command
144+
}
145+
cmd.Command = command
140146
if err := cmd.StartWithUi(comm, ui); err != nil {
141147
return err
142148
}

0 commit comments

Comments
 (0)