Skip to content
This repository was archived by the owner on Jun 2, 2022. It is now read-only.

Commit c584c65

Browse files
authored
Merge pull request #452 from ekinanp/fix-451
Make sure analytics config dir exists before writing analytics.yaml
2 parents 9a52626 + 464dc41 commit c584c65

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

analytics/config.go

+5
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ func GetConfig() (Config, error) {
7070
// This should never happen
7171
return config, fmt.Errorf("could not marshal the analytics config: %v", err)
7272
}
73+
// Make sure that the ~/.puppetlabs/wash directory exists. Otherwise, ioutil.WriteFile
74+
// will return an error.
75+
if err := os.MkdirAll(filepath.Dir(analyticsConfigFile), 0750); err != nil {
76+
return config, err
77+
}
7378
return config, ioutil.WriteFile(analyticsConfigFile, bytes, 0644)
7479
}
7580

0 commit comments

Comments
 (0)