Skip to content

Commit

Permalink
added recursive directory handling for state-dir flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ManishaKumari295 committed Mar 28, 2024
1 parent f05a8f8 commit 94ad9cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 2 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 94ad9cc

Please sign in to comment.