From f0fd18eec9d85e6b818a296c85f06dbc9af2b080 Mon Sep 17 00:00:00 2001 From: aiordache Date: Thu, 4 Mar 2021 18:38:09 +0100 Subject: [PATCH] set current context to default when -H flag is set Signed-off-by: aiordache --- cli/main.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cli/main.go b/cli/main.go index 0153823a..6812661d 100644 --- a/cli/main.go +++ b/cli/main.go @@ -195,6 +195,10 @@ func main() { ctx = config.WithDir(ctx, configDir) currentContext := determineCurrentContext(opts.Context, configDir) + if len(opts.Hosts) > 0 { + opts.Context = "" + currentContext = "default" + } s, err := store.New(configDir) if err != nil { @@ -213,8 +217,6 @@ func main() { volume.Command(ctype), ) - ctx = apicontext.WithCurrentContext(ctx, currentContext) - cnxOptions := cliflags.CommonOptions{ Context: opts.Context, Debug: opts.Debug, @@ -223,13 +225,12 @@ func main() { TLS: opts.TLS, TLSVerify: opts.TLSVerify, } - if len(opts.Hosts) == 0 { - cnxOptions.Context = currentContext - } + if opts.TLSVerify { cnxOptions.TLSOptions = opts.TLSOptions } ctx = apicontext.WithCliOptions(ctx, cnxOptions) + ctx = apicontext.WithCurrentContext(ctx, currentContext) ctx = store.WithContextStore(ctx, s) if err = root.ExecuteContext(ctx); err != nil {