Skip to content

Commit

Permalink
feat: default config file location
Browse files Browse the repository at this point in the history
Construct a default config file location from yggdrasil constants.
  • Loading branch information
subpop committed Feb 7, 2024
1 parent 78570aa commit 06eb0d5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"net"
"os"
"path/filepath"
"strconv"
"strings"
"time"
Expand All @@ -14,14 +15,15 @@ import (

"github.com/peterbourgon/ff/v3"
"github.com/peterbourgon/ff/v3/fftoml"
"github.com/redhatinsights/yggdrasil"
pb "github.com/redhatinsights/yggdrasil/protocol"
"github.com/sgreben/flagvar"
"github.com/zcalusic/sysinfo"
"google.golang.org/grpc"
)

func main() {
fs := flag.NewFlagSet("yggd-package-manager-worker", flag.ExitOnError)
fs := flag.NewFlagSet(filepath.Base(os.Args[0]), flag.ExitOnError)

var (
socketAddr = ""
Expand All @@ -32,7 +34,7 @@ func main() {
fs.StringVar(&socketAddr, "socket-addr", "", "dispatcher socket address")
fs.Var(&logLevel, "log-level", "log verbosity level (error (default), warn, info, debug, trace)")
fs.Var(&allowPatterns, "allow-pattern", "regular expression pattern to allow package operations\n(can be specified multiple times)")
_ = fs.String("config", "", "path to `file` containing configuration values (optional)")
_ = fs.String("config", filepath.Join(yggdrasil.SysconfDir, yggdrasil.LongName, "workers", fs.Name()+".toml"), "path to `file` containing configuration values (optional)")

ff.Parse(fs, os.Args[1:], ff.WithEnvVarPrefix("YGG"), ff.WithConfigFileFlag("config"), ff.WithConfigFileParser(fftoml.Parser))

Expand Down

0 comments on commit 06eb0d5

Please sign in to comment.