Skip to content

Commit

Permalink
Added flytectl config by env variable (#91)
Browse files Browse the repository at this point in the history
* Added flytectl config by env variable
* remove -c short command from register flags

Signed-off-by: Yuvraj <[email protected]>
  • Loading branch information
yindia authored Jun 13, 2021
1 parent 3a07da0 commit 517beb9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions flytectl/cmd/register/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ the continueOnError flag.
Using short format of continueOnError flag
::
bin/flytectl register file _pb_output/* -d development -p flytesnacks -c
bin/flytectl register file _pb_output/* -d development -p flytesnacks --continueOnError
Overriding the default version v1 using version string.
::
Expand All @@ -54,25 +54,25 @@ Change the o/p format has not effect on registration. The O/p is currently avail
::
bin/flytectl register file _pb_output/* -d development -p flytesnacks -c -o yaml
bin/flytectl register file _pb_output/* -d development -p flytesnacks --continueOnError -o yaml
Override IamRole during registration.
::
bin/flytectl register file _pb_output/* -d development -p flytesnacks -c -v v2 -i "arn:aws:iam::123456789:role/dummy"
bin/flytectl register file _pb_output/* -d development -p flytesnacks --continueOnError -v v2 -i "arn:aws:iam::123456789:role/dummy"
Override Kubernetes service account during registration.
::
bin/flytectl register file _pb_output/* -d development -p flytesnacks -c -v v2 -k "kubernetes-service-account"
bin/flytectl register file _pb_output/* -d development -p flytesnacks --continueOnError -v v2 -k "kubernetes-service-account"
Override Output location prefix during registration.
::
bin/flytectl register file _pb_output/* -d development -p flytesnacks -c -v v2 -l "s3://dummy/prefix"
bin/flytectl register file _pb_output/* -d development -p flytesnacks --continueOnError -v v2 -l "s3://dummy/prefix"
Usage
`
Expand Down
13 changes: 10 additions & 3 deletions flytectl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"context"
"fmt"
"os"

f "github.com/flyteorg/flytectl/pkg/filesystemutils"

Expand Down Expand Up @@ -42,8 +43,7 @@ func newRootCmd() *cobra.Command {
DisableAutoGenTag: true,
}

rootCmd.PersistentFlags().StringVar(&cfgFile, "config", f.FilePathJoin(f.UserHomeDir(), configFileDir, configFileName),
"config file (default is $HOME/.flyte/config.yaml)")
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file (default is $HOME/.flyte/config.yaml)")

configAccessor.InitializePflags(rootCmd.PersistentFlags())

Expand All @@ -68,9 +68,16 @@ func newRootCmd() *cobra.Command {
}

func initConfig(_ *cobra.Command, _ []string) error {
configFile := f.FilePathJoin(f.UserHomeDir(), configFileDir, configFileName)
if len(os.Getenv("FLYTECTL_CONFIG")) > 0 {
configFile = os.Getenv("FLYTECTL_CONFIG")
}
if len(cfgFile) > 0 {
configFile = cfgFile
}
configAccessor = viper.NewAccessor(stdConfig.Options{
StrictMode: true,
SearchPaths: []string{cfgFile},
SearchPaths: []string{configFile},
})

err := configAccessor.UpdateConfig(context.TODO())
Expand Down

0 comments on commit 517beb9

Please sign in to comment.