diff --git a/CHANGELOG.md b/CHANGELOG.md index 896cbc2..a7b81ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Use summary output by default in generated events * Include files with zero matching lines in summary output * typo in long argument for invert-thresholds +* creation of `state-directory` with a provided recursive path is made possible. ## [0.6.0] - 2022-05-05 diff --git a/main.go b/main.go index 8fc818e..7a6810a 100644 --- a/main.go +++ b/main.go @@ -311,14 +311,10 @@ func checkArgs(event *corev2.Event) (int, error) { return sensu.CheckStateCritical, fmt.Errorf("--match-expr not specified") } if _, err := os.Stat(plugin.StateDir); errors.Is(err, os.ErrNotExist) { - //err := os.Mkdir(plugin.StateDir, os.ModePerm) + //creating recursive directories incase err := os.MkdirAll(plugin.StateDir, os.ModePerm) if err != nil { - err = fmt.Errorf("selected --state-directory %s does not exist and cannot be created.Expected a correct Path to create/reach the directory", plugin.StateDir) - fmt.Println(err.Error()) - //logrus.Exit(sensu.CheckStateCritical) - return sensu.CheckStateCritical, nil - //return sensu.CheckStateCritical, fmt.Errorf("selected --state-directory %s does not exist and cannot be created.Expected a correct Path to create/reach the directory", plugin.StateDir) + return sensu.CheckStateCritical, fmt.Errorf("selected --state-directory %s does not exist and cannot be created.Expected a correct Path to create/reach the directory", plugin.StateDir) } } if _, err := os.Stat(plugin.StateDir); err != nil {