From 34e19af383c2e200758583842ba813ee12424d86 Mon Sep 17 00:00:00 2001 From: Ketan Umare <16888709+kumare3@users.noreply.github.com> Date: Tue, 2 Nov 2021 15:19:53 -0700 Subject: [PATCH] Fix command line config parsing (#23) Signed-off-by: Ketan Umare --- .gitignore | 1 + Makefile | 5 ++--- cmd/root.go | 7 ++++++- go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 474488e..6f17a62 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ # Dependency directories (remove the comment below to include it) # vendor/ .idea +artifacts/* diff --git a/Makefile b/Makefile index d160d43..e9905ab 100755 --- a/Makefile +++ b/Makefile @@ -20,9 +20,8 @@ linux_compile: .PHONY: compile compile: mkdir -p ./artifacts - go build -o ../artifacts/flyte-copilot . + go build -o ./artifacts/flyte-copilot . cross_compile: - @glide install @mkdir -p ./artifacts/cross - GOOS=linux GOARCH=amd64 go build -o ../artifacts/flyte-copilot . + GOOS=linux GOARCH=amd64 go build -o ./artifacts/flyte-copilot . diff --git a/cmd/root.go b/cmd/root.go index e673cfb..babd93c 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -168,8 +168,13 @@ func (r *RootOptions) initConfig(cmd *cobra.Command, _ []string) error { SearchPaths: []string{r.cfgFile}, }) + rootCmd := cmd + for rootCmd.Parent() != nil { + rootCmd = rootCmd.Parent() + } + // persistent flags were initially bound to the root command so we must bind to the same command to avoid - r.configAccessor.InitializePflags(cmd.PersistentFlags()) + r.configAccessor.InitializePflags(rootCmd.PersistentFlags()) err := r.configAccessor.UpdateConfig(context.TODO()) if err != nil { diff --git a/go.mod b/go.mod index 0d03431..55fa809 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.13 require ( github.com/aws/aws-sdk-go v1.37.1 github.com/flyteorg/flyteidl v0.18.15 - github.com/flyteorg/flytestdlib v0.3.33 + github.com/flyteorg/flytestdlib v0.4.2 github.com/fsnotify/fsnotify v1.4.9 github.com/ghodss/yaml v1.0.0 github.com/golang/protobuf v1.4.3 diff --git a/go.sum b/go.sum index ad7fbbc..63d65dd 100644 --- a/go.sum +++ b/go.sum @@ -174,8 +174,8 @@ github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4 github.com/flyteorg/flyteidl v0.18.15 h1:sXrlwTRaRjQsXYMNrY/S930SKdKtu4XnpNFEu8I4tn4= github.com/flyteorg/flyteidl v0.18.15/go.mod h1:b5Fq4Z8a5b0mF6pEwTd48ufvikUGVkWSjZiMT0ZtqKI= github.com/flyteorg/flytestdlib v0.3.13/go.mod h1:Tz8JCECAbX6VWGwFT6cmEQ+RJpZ/6L9pswu3fzWs220= -github.com/flyteorg/flytestdlib v0.3.33 h1:+oCx3zXUIldL7CWmNMD7PMFPXvGqaPgYkSKn9wB6qvY= -github.com/flyteorg/flytestdlib v0.3.33/go.mod h1:7cDWkY3v7xsoesFcDdu6DSW5Q2U2W5KlHUbUHSwBG1Q= +github.com/flyteorg/flytestdlib v0.4.2 h1:3xYcxOj6ltMCR8weuXhV8hp5UTsAqb7uS3q8LZGvEKA= +github.com/flyteorg/flytestdlib v0.4.2/go.mod h1:7cDWkY3v7xsoesFcDdu6DSW5Q2U2W5KlHUbUHSwBG1Q= github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=