Skip to content

Commit

Permalink
recursive state dir creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ManishaKumari295 committed Mar 27, 2024
1 parent ec1d37c commit f05a8f8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/sirupsen/logrus"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -312,12 +311,13 @@ 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)
//err := os.Mkdir(plugin.StateDir, os.ModePerm)
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
//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)
}
}
Expand Down

0 comments on commit f05a8f8

Please sign in to comment.