Skip to content

Commit

Permalink
Ensure config dir exists before writing the wash.yaml file
Browse files Browse the repository at this point in the history
Fixes puppetlabs-toy-chest#712

Signed-off-by: Enis Inan <[email protected]>
  • Loading branch information
ekinanp committed Feb 6, 2020
1 parent 8e36868 commit b0cb040
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ func writeEnabledPlugins(enabledPlugins []string, configFile string) error {
if err != nil {
return err
}
// Make sure that the Wash config file's directory exists. Otherwise,
// OpenFile will return an error.
if err := os.MkdirAll(filepath.Dir(configFile), 0750); err != nil {
return err
}
// Note that we do a raw append of "plugins: <enabled_plugins>" to preserve any
// existing data, including comments. The append should be OK because we know that
// the config file doesn't have a "plugins" key, so adding it will not mess anything
Expand Down

0 comments on commit b0cb040

Please sign in to comment.