Skip to content

Commit

Permalink
add default config file itself into search path
Browse files Browse the repository at this point in the history
Signed-off-by: Yee Hing Tong <[email protected]>
  • Loading branch information
wild-endeavor committed Oct 11, 2023
1 parent fa997eb commit 3f88f17
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions flyteartifacts/artifact_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
artifactsServer:
myTestValue: "test from file"
10 changes: 7 additions & 3 deletions flyteartifacts/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,20 @@ func init() {
}

func initConfig(flags *pflag.FlagSet) error {
fmt.Println("initConfig called")
configAccessor = viper.NewAccessor(config.Options{
SearchPaths: []string{cfgFile, ".", "/etc/flyte/config", "$GOPATH/src/github.com/flyteorg/flyte/flyteartifacts"},
SearchPaths: []string{cfgFile, "./artifact_config.yaml", ".", "/etc/flyte/config", "$GOPATH/src/github.com/flyteorg/flyte/flyteartifacts"},
StrictMode: false,
})

logger.Infof(context.TODO(), "Using config file: %v", configAccessor.ConfigFilesUsed())

configAccessor.InitializePflags(flags)
fmt.Println("initConfig finish")

err := flag.CommandLine.Parse([]string{})
if err != nil {
fmt.Println(err)
os.Exit(-1)
}

return configAccessor.UpdateConfig(context.TODO())
}
Expand Down
6 changes: 5 additions & 1 deletion flyteartifacts/pkg/configuration/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ type ApplicationConfiguration struct {
MyTestValue string `json:"myTestValue" pflag:",Test config value"`
}

var ApplicationConfig = config.MustRegisterSection(artifactsServer, &ApplicationConfiguration{})
var defaultApplicationConfiguration = ApplicationConfiguration{
MyTestValue: "default",
}

var ApplicationConfig = config.MustRegisterSection(artifactsServer, &defaultApplicationConfiguration)

0 comments on commit 3f88f17

Please sign in to comment.