Skip to content

Commit

Permalink
Add config folder checker
Browse files Browse the repository at this point in the history
  • Loading branch information
g41797 committed Oct 5, 2023
1 parent c6fac50 commit df28d5c
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions sidecar/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,33 @@ import (
"github.com/g41797/sputnik"
)

func Start(cntr sputnik.ServerConnector) {

var confFolder string
func ConfFolder() (confFolder string, err error) {
flag.StringVar(&confFolder, "cf", "", "Path of folder with config files")
flag.Parse()

if len(confFolder) == 0 {
fmt.Fprintln(os.Stderr, fmt.Errorf("-cf <path of config folder> - was not set!!!"))
os.Exit(1)
err = fmt.Errorf("-cf <path of config folder> - was not set")
return "", err
}

info, err := os.Stat(confFolder)
if err != nil {
return "", err
}
if !info.IsDir() {
return "", fmt.Errorf("%s is not the folder", confFolder)
}

return confFolder, nil
}

func Start(cntr sputnik.ServerConnector) {

confFolder, err := ConfFolder()

if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}

rnr, err := StartRunner(confFolder, cntr)
Expand Down

0 comments on commit df28d5c

Please sign in to comment.