Signed-off-by: aiordache <anca.iordache@docker.com>
This commit is contained in:
aiordache 2021-03-05 14:29:42 +01:00
parent f0fd18eec9
commit 6458b97089
3 changed files with 19 additions and 30 deletions

View file

@ -21,13 +21,11 @@ import (
"golang.org/x/net/context"
configfile "github.com/docker/cli/cli/config/configfile"
cliflags "github.com/docker/cli/cli/flags"
)
type currentContextKey struct{}
type cliOptionsKey struct{}
type configKey struct{}
// WithCurrentContext sets the name of the current docker context
func WithCurrentContext(ctx gocontext.Context, contextName string) context.Context {
@ -50,14 +48,3 @@ func CliOptions(ctx context.Context) cliflags.CommonOptions {
cc, _ := ctx.Value(cliOptionsKey{}).(cliflags.CommonOptions)
return cc
}
// WithConfig sets docker config
func WithConfig(ctx gocontext.Context, config configfile.ConfigFile) context.Context {
return context.WithValue(ctx, configKey{}, config)
}
// Config returns the docker config
func Config(ctx context.Context) configfile.ConfigFile {
cc, _ := ctx.Value(cliOptionsKey{}).(configfile.ConfigFile)
return cc
}