From 22d4d250a92d411d9f3966324cd51230150f83b4 Mon Sep 17 00:00:00 2001 From: Djordje Lukic Date: Sat, 6 Jun 2020 22:22:30 +0200 Subject: [PATCH 1/3] Move the config into own package and outside of cli --- cli/cmd/context/use.go | 4 ++-- cli/config/flags.go | 13 +++---------- cli/main.go | 12 +++++------- cli/main_test.go | 2 +- {cli/config => config}/config.go | 0 {cli/config => config}/config_test.go | 0 {cli/config => config}/keys.go | 9 +++++++++ 7 files changed, 20 insertions(+), 20 deletions(-) rename {cli/config => config}/config.go (100%) rename {cli/config => config}/config_test.go (100%) rename {cli/config => config}/keys.go (82%) diff --git a/cli/cmd/context/use.go b/cli/cmd/context/use.go index 09126685a..7b1c75524 100644 --- a/cli/cmd/context/use.go +++ b/cli/cmd/context/use.go @@ -33,7 +33,7 @@ import ( "github.com/spf13/cobra" - cliconfig "github.com/docker/api/cli/config" + "github.com/docker/api/config" "github.com/docker/api/context/store" ) @@ -56,7 +56,7 @@ func runUse(ctx context.Context, name string) error { return err } } - if err := cliconfig.WriteCurrentContext(cliconfig.Dir(ctx), name); err != nil { + if err := config.WriteCurrentContext(config.Dir(ctx), name); err != nil { return err } fmt.Println(name) diff --git a/cli/config/flags.go b/cli/config/flags.go index b9b3b3ffc..25c2405e5 100644 --- a/cli/config/flags.go +++ b/cli/config/flags.go @@ -32,15 +32,8 @@ import ( "path/filepath" "github.com/spf13/pflag" -) -const ( - // ConfigFileName is the name of config file - ConfigFileName = "config.json" - // ConfigFileDir is the default folder where the config file is stored - ConfigFileDir = ".docker" - // ConfigFlagName is the name of the config flag - ConfigFlagName = "config" + "github.com/docker/api/config" ) // ConfigFlags are the global CLI flags @@ -51,7 +44,7 @@ type ConfigFlags struct { // AddConfigFlags adds persistent (global) flags func (c *ConfigFlags) AddConfigFlags(flags *pflag.FlagSet) { - flags.StringVar(&c.Config, ConfigFlagName, confDir(), "Location of the client config files `DIRECTORY`") + flags.StringVar(&c.Config, config.ConfigFlagName, confDir(), "Location of the client config files `DIRECTORY`") } func confDir() string { @@ -60,5 +53,5 @@ func confDir() string { return env } home, _ := os.UserHomeDir() - return filepath.Join(home, ConfigFileDir) + return filepath.Join(home, config.ConfigFileDir) } diff --git a/cli/main.go b/cli/main.go index 5a2d88d55..ef84a534c 100644 --- a/cli/main.go +++ b/cli/main.go @@ -38,10 +38,6 @@ import ( "syscall" "time" - "github.com/docker/api/cli/cmd/login" - - "github.com/docker/api/cli/dockerclassic" - "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -54,9 +50,11 @@ import ( "github.com/docker/api/cli/cmd" "github.com/docker/api/cli/cmd/compose" contextcmd "github.com/docker/api/cli/cmd/context" + "github.com/docker/api/cli/cmd/login" "github.com/docker/api/cli/cmd/run" - cliconfig "github.com/docker/api/cli/config" + "github.com/docker/api/cli/dockerclassic" cliopts "github.com/docker/api/cli/options" + "github.com/docker/api/config" apicontext "github.com/docker/api/context" "github.com/docker/api/context/store" ) @@ -151,7 +149,7 @@ func main() { fatal(errors.New("config path cannot be empty")) } configDir := opts.Config - ctx = cliconfig.WithDir(ctx, configDir) + ctx = config.WithDir(ctx, configDir) currentContext, err := determineCurrentContext(opts.Context, configDir) if err != nil { @@ -206,7 +204,7 @@ func newSigContext() (context.Context, func()) { func determineCurrentContext(flag string, configDir string) (string, error) { res := flag if res == "" { - config, err := cliconfig.LoadFile(configDir) + config, err := config.LoadFile(configDir) if err != nil { return "", err } diff --git a/cli/main_test.go b/cli/main_test.go index b0448b4b2..e616c3169 100644 --- a/cli/main_test.go +++ b/cli/main_test.go @@ -40,7 +40,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/docker/api/cli/config" + "github.com/docker/api/config" ) var contextSetConfig = []byte(`{ diff --git a/cli/config/config.go b/config/config.go similarity index 100% rename from cli/config/config.go rename to config/config.go diff --git a/cli/config/config_test.go b/config/config_test.go similarity index 100% rename from cli/config/config_test.go rename to config/config_test.go diff --git a/cli/config/keys.go b/config/keys.go similarity index 82% rename from cli/config/keys.go rename to config/keys.go index 5ac2f5982..21ef56f35 100644 --- a/cli/config/keys.go +++ b/config/keys.go @@ -27,6 +27,15 @@ package config +const ( + // ConfigFileName is the name of config file + ConfigFileName = "config.json" + // ConfigFileDir is the default folder where the config file is stored + ConfigFileDir = ".docker" + // ConfigFlagName is the name of the config flag + ConfigFlagName = "config" +) + const ( // currentContextKey is the key used in the Docker config file to set the // default context From bb69de1db3ec9f4a6811c3c781063a9886a65e8b Mon Sep 17 00:00:00 2001 From: Djordje Lukic Date: Sat, 6 Jun 2020 22:30:04 +0200 Subject: [PATCH 2/3] Add context endpoint to set the current context --- cli/cmd/serve.go | 6 +- protos/contexts/v1/contexts.pb.go | 240 +++++++++++++++++++++++++----- protos/contexts/v1/contexts.proto | 13 +- server/contexts.go | 35 ----- server/proxy/contexts.go | 39 +++++ server/proxy/proxy.go | 18 ++- server/server.go | 5 +- 7 files changed, 275 insertions(+), 81 deletions(-) delete mode 100644 server/contexts.go create mode 100644 server/proxy/contexts.go diff --git a/cli/cmd/serve.go b/cli/cmd/serve.go index 0ab492c6f..66d6d9c7a 100644 --- a/cli/cmd/serve.go +++ b/cli/cmd/serve.go @@ -7,6 +7,7 @@ import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" + apicontext "github.com/docker/api/context" containersv1 "github.com/docker/api/protos/containers/v1" contextsv1 "github.com/docker/api/protos/contexts/v1" streamsv1 "github.com/docker/api/protos/streams/v1" @@ -45,12 +46,11 @@ func runServe(ctx context.Context, opts serveOpts) error { // nolint errcheck defer listener.Close() - p := proxy.New() - contextsService := server.NewContexts() + p := proxy.New(apicontext.CurrentContext(ctx)) containersv1.RegisterContainersServer(s, p) streamsv1.RegisterStreamingServer(s, p) - contextsv1.RegisterContextsServer(s, contextsService) + contextsv1.RegisterContextsServer(s, p.ContextsProxy()) go func() { <-ctx.Done() diff --git a/protos/contexts/v1/contexts.pb.go b/protos/contexts/v1/contexts.pb.go index 08ba25f67..a5cda1d40 100644 --- a/protos/contexts/v1/contexts.pb.go +++ b/protos/contexts/v1/contexts.pb.go @@ -62,6 +62,7 @@ type Context struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` ContextType string `protobuf:"bytes,2,opt,name=contextType,proto3" json:"contextType,omitempty"` + Current bool `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` } func (x *Context) Reset() { @@ -110,6 +111,98 @@ func (x *Context) GetContextType() string { return "" } +func (x *Context) GetCurrent() bool { + if x != nil { + return x.Current + } + return false +} + +type SetCurrentRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *SetCurrentRequest) Reset() { + *x = SetCurrentRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_protos_contexts_v1_contexts_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SetCurrentRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetCurrentRequest) ProtoMessage() {} + +func (x *SetCurrentRequest) ProtoReflect() protoreflect.Message { + mi := &file_protos_contexts_v1_contexts_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetCurrentRequest.ProtoReflect.Descriptor instead. +func (*SetCurrentRequest) Descriptor() ([]byte, []int) { + return file_protos_contexts_v1_contexts_proto_rawDescGZIP(), []int{1} +} + +func (x *SetCurrentRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type SetCurrentResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *SetCurrentResponse) Reset() { + *x = SetCurrentResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_protos_contexts_v1_contexts_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SetCurrentResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetCurrentResponse) ProtoMessage() {} + +func (x *SetCurrentResponse) ProtoReflect() protoreflect.Message { + mi := &file_protos_contexts_v1_contexts_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetCurrentResponse.ProtoReflect.Descriptor instead. +func (*SetCurrentResponse) Descriptor() ([]byte, []int) { + return file_protos_contexts_v1_contexts_proto_rawDescGZIP(), []int{2} +} + type ListRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -119,7 +212,7 @@ type ListRequest struct { func (x *ListRequest) Reset() { *x = ListRequest{} if protoimpl.UnsafeEnabled { - mi := &file_protos_contexts_v1_contexts_proto_msgTypes[1] + mi := &file_protos_contexts_v1_contexts_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -132,7 +225,7 @@ func (x *ListRequest) String() string { func (*ListRequest) ProtoMessage() {} func (x *ListRequest) ProtoReflect() protoreflect.Message { - mi := &file_protos_contexts_v1_contexts_proto_msgTypes[1] + mi := &file_protos_contexts_v1_contexts_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -145,7 +238,7 @@ func (x *ListRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListRequest.ProtoReflect.Descriptor instead. func (*ListRequest) Descriptor() ([]byte, []int) { - return file_protos_contexts_v1_contexts_proto_rawDescGZIP(), []int{1} + return file_protos_contexts_v1_contexts_proto_rawDescGZIP(), []int{3} } type ListResponse struct { @@ -159,7 +252,7 @@ type ListResponse struct { func (x *ListResponse) Reset() { *x = ListResponse{} if protoimpl.UnsafeEnabled { - mi := &file_protos_contexts_v1_contexts_proto_msgTypes[2] + mi := &file_protos_contexts_v1_contexts_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -172,7 +265,7 @@ func (x *ListResponse) String() string { func (*ListResponse) ProtoMessage() {} func (x *ListResponse) ProtoReflect() protoreflect.Message { - mi := &file_protos_contexts_v1_contexts_proto_msgTypes[2] + mi := &file_protos_contexts_v1_contexts_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -185,7 +278,7 @@ func (x *ListResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListResponse.ProtoReflect.Descriptor instead. func (*ListResponse) Descriptor() ([]byte, []int) { - return file_protos_contexts_v1_contexts_proto_rawDescGZIP(), []int{2} + return file_protos_contexts_v1_contexts_proto_rawDescGZIP(), []int{4} } func (x *ListResponse) GetContexts() []*Context { @@ -202,28 +295,41 @@ var file_protos_contexts_v1_contexts_proto_rawDesc = []byte{ 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x20, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, - 0x78, 0x74, 0x2e, 0x76, 0x31, 0x22, 0x3f, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, + 0x78, 0x74, 0x2e, 0x76, 0x31, 0x22, 0x59, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, - 0x78, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x0d, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x55, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x6f, - 0x63, 0x6b, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, - 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x78, 0x74, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x73, 0x32, 0x71, 0x0a, 0x08, - 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x73, 0x12, 0x65, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, - 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2e, 0x61, 0x70, + 0x78, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x22, 0x27, 0x0a, 0x11, 0x53, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x14, 0x0a, 0x12, 0x53, 0x65, 0x74, + 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x0d, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x55, + 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, + 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x29, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, - 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x2e, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2e, - 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, - 0x2c, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x6f, - 0x63, 0x6b, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, - 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x08, 0x63, 0x6f, 0x6e, + 0x74, 0x65, 0x78, 0x74, 0x73, 0x32, 0xea, 0x01, 0x0a, 0x08, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, + 0x74, 0x73, 0x12, 0x77, 0x0a, 0x0a, 0x53, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x12, 0x33, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, + 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x6f, 0x63, 0x6b, + 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x63, 0x6f, + 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x65, 0x0a, 0x04, 0x4c, + 0x69, 0x73, 0x74, 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x65, 0x78, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x78, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x42, 0x2c, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -238,18 +344,22 @@ func file_protos_contexts_v1_contexts_proto_rawDescGZIP() []byte { return file_protos_contexts_v1_contexts_proto_rawDescData } -var file_protos_contexts_v1_contexts_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_protos_contexts_v1_contexts_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_protos_contexts_v1_contexts_proto_goTypes = []interface{}{ - (*Context)(nil), // 0: com.docker.api.protos.context.v1.Context - (*ListRequest)(nil), // 1: com.docker.api.protos.context.v1.ListRequest - (*ListResponse)(nil), // 2: com.docker.api.protos.context.v1.ListResponse + (*Context)(nil), // 0: com.docker.api.protos.context.v1.Context + (*SetCurrentRequest)(nil), // 1: com.docker.api.protos.context.v1.SetCurrentRequest + (*SetCurrentResponse)(nil), // 2: com.docker.api.protos.context.v1.SetCurrentResponse + (*ListRequest)(nil), // 3: com.docker.api.protos.context.v1.ListRequest + (*ListResponse)(nil), // 4: com.docker.api.protos.context.v1.ListResponse } var file_protos_contexts_v1_contexts_proto_depIdxs = []int32{ 0, // 0: com.docker.api.protos.context.v1.ListResponse.contexts:type_name -> com.docker.api.protos.context.v1.Context - 1, // 1: com.docker.api.protos.context.v1.Contexts.List:input_type -> com.docker.api.protos.context.v1.ListRequest - 2, // 2: com.docker.api.protos.context.v1.Contexts.List:output_type -> com.docker.api.protos.context.v1.ListResponse - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] is the sub-list for method input_type + 1, // 1: com.docker.api.protos.context.v1.Contexts.SetCurrent:input_type -> com.docker.api.protos.context.v1.SetCurrentRequest + 3, // 2: com.docker.api.protos.context.v1.Contexts.List:input_type -> com.docker.api.protos.context.v1.ListRequest + 2, // 3: com.docker.api.protos.context.v1.Contexts.SetCurrent:output_type -> com.docker.api.protos.context.v1.SetCurrentResponse + 4, // 4: com.docker.api.protos.context.v1.Contexts.List:output_type -> com.docker.api.protos.context.v1.ListResponse + 3, // [3:5] is the sub-list for method output_type + 1, // [1:3] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name @@ -274,7 +384,7 @@ func file_protos_contexts_v1_contexts_proto_init() { } } file_protos_contexts_v1_contexts_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListRequest); i { + switch v := v.(*SetCurrentRequest); i { case 0: return &v.state case 1: @@ -286,6 +396,30 @@ func file_protos_contexts_v1_contexts_proto_init() { } } file_protos_contexts_v1_contexts_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SetCurrentResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_protos_contexts_v1_contexts_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_protos_contexts_v1_contexts_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ListResponse); i { case 0: return &v.state @@ -304,7 +438,7 @@ func file_protos_contexts_v1_contexts_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_protos_contexts_v1_contexts_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, @@ -330,6 +464,8 @@ const _ = grpc.SupportPackageIsVersion6 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type ContextsClient interface { + // Sets the current request for all calls + SetCurrent(ctx context.Context, in *SetCurrentRequest, opts ...grpc.CallOption) (*SetCurrentResponse, error) // Returns the list of existing contexts List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) } @@ -342,6 +478,15 @@ func NewContextsClient(cc grpc.ClientConnInterface) ContextsClient { return &contextsClient{cc} } +func (c *contextsClient) SetCurrent(ctx context.Context, in *SetCurrentRequest, opts ...grpc.CallOption) (*SetCurrentResponse, error) { + out := new(SetCurrentResponse) + err := c.cc.Invoke(ctx, "/com.docker.api.protos.context.v1.Contexts/SetCurrent", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *contextsClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) { out := new(ListResponse) err := c.cc.Invoke(ctx, "/com.docker.api.protos.context.v1.Contexts/List", in, out, opts...) @@ -353,6 +498,8 @@ func (c *contextsClient) List(ctx context.Context, in *ListRequest, opts ...grpc // ContextsServer is the server API for Contexts service. type ContextsServer interface { + // Sets the current request for all calls + SetCurrent(context.Context, *SetCurrentRequest) (*SetCurrentResponse, error) // Returns the list of existing contexts List(context.Context, *ListRequest) (*ListResponse, error) } @@ -361,6 +508,9 @@ type ContextsServer interface { type UnimplementedContextsServer struct { } +func (*UnimplementedContextsServer) SetCurrent(context.Context, *SetCurrentRequest) (*SetCurrentResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetCurrent not implemented") +} func (*UnimplementedContextsServer) List(context.Context, *ListRequest) (*ListResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method List not implemented") } @@ -369,6 +519,24 @@ func RegisterContextsServer(s *grpc.Server, srv ContextsServer) { s.RegisterService(&_Contexts_serviceDesc, srv) } +func _Contexts_SetCurrent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SetCurrentRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ContextsServer).SetCurrent(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.docker.api.protos.context.v1.Contexts/SetCurrent", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ContextsServer).SetCurrent(ctx, req.(*SetCurrentRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Contexts_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ListRequest) if err := dec(in); err != nil { @@ -391,6 +559,10 @@ var _Contexts_serviceDesc = grpc.ServiceDesc{ ServiceName: "com.docker.api.protos.context.v1.Contexts", HandlerType: (*ContextsServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "SetCurrent", + Handler: _Contexts_SetCurrent_Handler, + }, { MethodName: "List", Handler: _Contexts_List_Handler, diff --git a/protos/contexts/v1/contexts.proto b/protos/contexts/v1/contexts.proto index 74f42b0cf..3a432974d 100644 --- a/protos/contexts/v1/contexts.proto +++ b/protos/contexts/v1/contexts.proto @@ -32,17 +32,26 @@ package com.docker.api.protos.context.v1; option go_package = "github.com/docker/api/protos/context/v1;v1"; service Contexts { + // Sets the current request for all calls + rpc SetCurrent(SetCurrentRequest) returns (SetCurrentResponse); // Returns the list of existing contexts rpc List(ListRequest) returns (ListResponse); } message Context { string name = 1; - string contextType = 2; + string contextType = 2; + bool current = 3; +} + +message SetCurrentRequest { + string name = 1; +} + +message SetCurrentResponse { } message ListRequest { - } message ListResponse { diff --git a/server/contexts.go b/server/contexts.go deleted file mode 100644 index 2c6e88d86..000000000 --- a/server/contexts.go +++ /dev/null @@ -1,35 +0,0 @@ -package server - -import ( - "context" - - "github.com/docker/api/context/store" - contextsv1 "github.com/docker/api/protos/contexts/v1" -) - -type cliServer struct { -} - -// NewContexts returns a contexts server -func NewContexts() contextsv1.ContextsServer { - return &cliServer{} -} - -func (cs *cliServer) List(ctx context.Context, request *contextsv1.ListRequest) (*contextsv1.ListResponse, error) { - s := store.ContextStore(ctx) - contexts, err := s.List() - if err != nil { - return &contextsv1.ListResponse{}, err - } - - result := &contextsv1.ListResponse{} - - for _, c := range contexts { - result.Contexts = append(result.Contexts, &contextsv1.Context{ - Name: c.Name, - ContextType: c.Type, - }) - } - - return result, nil -} diff --git a/server/proxy/contexts.go b/server/proxy/contexts.go new file mode 100644 index 000000000..b6c2e3ed8 --- /dev/null +++ b/server/proxy/contexts.go @@ -0,0 +1,39 @@ +package proxy + +import ( + "context" + + "github.com/docker/api/config" + "github.com/docker/api/context/store" + contextsv1 "github.com/docker/api/protos/contexts/v1" +) + +type contextsProxy struct { +} + +func (cp *contextsProxy) SetCurrent(ctx context.Context, request *contextsv1.SetCurrentRequest) (*contextsv1.SetCurrentResponse, error) { + if err := config.WriteCurrentContext(config.Dir(ctx), request.GetName()); err != nil { + return &contextsv1.SetCurrentResponse{}, err + } + + return &contextsv1.SetCurrentResponse{}, nil +} + +func (cp *contextsProxy) List(ctx context.Context, request *contextsv1.ListRequest) (*contextsv1.ListResponse, error) { + s := store.ContextStore(ctx) + contexts, err := s.List() + if err != nil { + return &contextsv1.ListResponse{}, err + } + + result := &contextsv1.ListResponse{} + + for _, c := range contexts { + result.Contexts = append(result.Contexts, &contextsv1.Context{ + Name: c.Name, + ContextType: c.Type, + }) + } + + return result, nil +} diff --git a/server/proxy/proxy.go b/server/proxy/proxy.go index 809a36a32..ef3f62c27 100644 --- a/server/proxy/proxy.go +++ b/server/proxy/proxy.go @@ -6,6 +6,7 @@ import ( "github.com/docker/api/client" containersv1 "github.com/docker/api/protos/containers/v1" + contextsv1 "github.com/docker/api/protos/contexts/v1" streamsv1 "github.com/docker/api/protos/streams/v1" ) @@ -27,16 +28,25 @@ func Client(ctx context.Context) *client.Client { type Proxy interface { containersv1.ContainersServer streamsv1.StreamingServer + ContextsProxy() contextsv1.ContextsServer } type proxy struct { - mu sync.Mutex - streams map[string]*Stream + currentContext string + mu sync.Mutex + streams map[string]*Stream + contextsProxy *contextsProxy } // New creates a new proxy server -func New() Proxy { +func New(currentContext string) Proxy { return &proxy{ - streams: map[string]*Stream{}, + currentContext: currentContext, + streams: map[string]*Stream{}, + contextsProxy: &contextsProxy{}, } } + +func (p *proxy) ContextsProxy() contextsv1.ContextsServer { + return p.contextsProxy +} diff --git a/server/server.go b/server/server.go index 8a1287b7a..533810fc6 100644 --- a/server/server.go +++ b/server/server.go @@ -40,7 +40,6 @@ import ( "github.com/docker/api/client" apicontext "github.com/docker/api/context" - "github.com/docker/api/context/store" "github.com/docker/api/server/proxy" ) @@ -127,8 +126,8 @@ func getContext(ctx context.Context) string { // configureContext populates the request context with objects the client // needs: the context store and the api client func configureContext(ctx context.Context, currentContext string) (context.Context, error) { - s := store.ContextStore(ctx) - ctx = store.WithContextStore(ctx, s) + // s := store.ContextStore(ctx) + // ctx = store.WithContextStore(ctx, s) if currentContext != "" { ctx = apicontext.WithCurrentContext(ctx, currentContext) } From c8079d61eeec1cc659b81921880a2a36be23da49 Mon Sep 17 00:00:00 2001 From: Djordje Lukic Date: Sat, 6 Jun 2020 22:46:35 +0200 Subject: [PATCH 3/3] Move streams into own package --- server/proxy/containers.go | 10 ++- server/proxy/logstream.go | 25 ------ server/proxy/proxy.go | 5 +- server/proxy/streams.go | 76 +------------------ server/proxy/streams/io.go | 45 +++++++++++ server/proxy/streams/logs.go | 26 +++++++ .../logs_test.go} | 2 +- server/proxy/streams/stream.go | 31 ++++++++ .../stream_test.go} | 14 ++-- server/server.go | 2 - 10 files changed, 126 insertions(+), 110 deletions(-) delete mode 100644 server/proxy/logstream.go create mode 100644 server/proxy/streams/io.go create mode 100644 server/proxy/streams/logs.go rename server/proxy/{logstream_test.go => streams/logs_test.go} (98%) create mode 100644 server/proxy/streams/stream.go rename server/proxy/{streams_test.go => streams/stream_test.go} (92%) diff --git a/server/proxy/containers.go b/server/proxy/containers.go index 9509e5043..e401e02a6 100644 --- a/server/proxy/containers.go +++ b/server/proxy/containers.go @@ -6,6 +6,7 @@ import ( "github.com/docker/api/containers" containersv1 "github.com/docker/api/protos/containers/v1" + "github.com/docker/api/server/proxy/streams" ) func portsToGrpc(ports []containers.Port) []*containersv1.Port { @@ -97,7 +98,10 @@ func (p *proxy) Exec(ctx context.Context, request *containersv1.ExecRequest) (*c return &containersv1.ExecResponse{}, errors.New("unknown stream id") } - err := Client(ctx).ContainerService().Exec(ctx, request.GetId(), request.GetCommand(), &reader{stream}, &writer{stream}) + io := &streams.IO{ + Stream: stream, + } + err := Client(ctx).ContainerService().Exec(ctx, request.GetId(), request.GetCommand(), io, io) return &containersv1.ExecResponse{}, err } @@ -108,6 +112,8 @@ func (p *proxy) Logs(request *containersv1.LogsRequest, stream containersv1.Cont return c.ContainerService().Logs(ctx, request.GetContainerId(), containers.LogsRequest{ Follow: request.Follow, - Writer: &logStream{stream}, + Writer: &streams.Log{ + Stream: stream, + }, }) } diff --git a/server/proxy/logstream.go b/server/proxy/logstream.go deleted file mode 100644 index 95e63f352..000000000 --- a/server/proxy/logstream.go +++ /dev/null @@ -1,25 +0,0 @@ -package proxy - -import ( - "io" - - "google.golang.org/grpc" - - containersv1 "github.com/docker/api/protos/containers/v1" -) - -type logStream struct { - stream grpc.ServerStream -} - -func newStreamWriter(stream grpc.ServerStream) io.Writer { - return &logStream{ - stream: stream, - } -} - -func (w *logStream) Write(p []byte) (n int, err error) { - return len(p), w.stream.SendMsg(&containersv1.LogsResponse{ - Value: p, - }) -} diff --git a/server/proxy/proxy.go b/server/proxy/proxy.go index ef3f62c27..1756ef61e 100644 --- a/server/proxy/proxy.go +++ b/server/proxy/proxy.go @@ -8,6 +8,7 @@ import ( containersv1 "github.com/docker/api/protos/containers/v1" contextsv1 "github.com/docker/api/protos/contexts/v1" streamsv1 "github.com/docker/api/protos/streams/v1" + "github.com/docker/api/server/proxy/streams" ) type clientKey struct{} @@ -34,7 +35,7 @@ type Proxy interface { type proxy struct { currentContext string mu sync.Mutex - streams map[string]*Stream + streams map[string]*streams.Stream contextsProxy *contextsProxy } @@ -42,7 +43,7 @@ type proxy struct { func New(currentContext string) Proxy { return &proxy{ currentContext: currentContext, - streams: map[string]*Stream{}, + streams: map[string]*streams.Stream{}, contextsProxy: &contextsProxy{}, } } diff --git a/server/proxy/streams.go b/server/proxy/streams.go index 60acb9c6e..3efa1c056 100644 --- a/server/proxy/streams.go +++ b/server/proxy/streams.go @@ -1,41 +1,14 @@ package proxy import ( - "sync" - "github.com/containerd/containerd/log" - "github.com/golang/protobuf/ptypes" "github.com/google/uuid" - "google.golang.org/grpc" "google.golang.org/grpc/metadata" streamsv1 "github.com/docker/api/protos/streams/v1" + "github.com/docker/api/server/proxy/streams" ) -// Stream is a bidirectional stream for container IO -type Stream struct { - streamsv1.Streaming_NewStreamServer - - errm sync.Mutex - errChan chan<- error -} - -// CloseWithError sends the result of an action to the errChan or nil -// if no erros -func (s *Stream) CloseWithError(err error) error { - s.errm.Lock() - defer s.errm.Unlock() - - if s.errChan != nil { - if err != nil { - s.errChan <- err - } - close(s.errChan) - s.errChan = nil - } - return nil -} - func (p *proxy) NewStream(stream streamsv1.Streaming_NewStreamServer) error { var ( ctx = stream.Context() @@ -53,9 +26,9 @@ func (p *proxy) NewStream(stream streamsv1.Streaming_NewStreamServer) error { errc := make(chan error) p.mu.Lock() - p.streams[id] = &Stream{ + p.streams[id] = &streams.Stream{ Streaming_NewStreamServer: stream, - errChan: errc, + ErrChan: errc, } p.mu.Unlock() @@ -73,46 +46,3 @@ func (p *proxy) NewStream(stream streamsv1.Streaming_NewStreamServer) error { return ctx.Err() } } - -// io.Reader that forwards everything to the stream -type reader struct { - stream *Stream -} - -func (r reader) Read(p []byte) (int, error) { - a, err := r.stream.Recv() - if err != nil { - return 0, err - } - - var m streamsv1.BytesMessage - err = ptypes.UnmarshalAny(a, &m) - if err != nil { - return 0, err - } - - return copy(p, m.Value), nil -} - -// io.Writer that writes -type writer struct { - stream grpc.ServerStream -} - -func (w *writer) Write(p []byte) (n int, err error) { - if len(p) == 0 { - return 0, nil - } - - message := streamsv1.BytesMessage{ - Type: streamsv1.IOStream_STDOUT, - Value: p, - } - - m, err := ptypes.MarshalAny(&message) - if err != nil { - return 0, err - } - - return len(message.Value), w.stream.SendMsg(m) -} diff --git a/server/proxy/streams/io.go b/server/proxy/streams/io.go new file mode 100644 index 000000000..a957d611a --- /dev/null +++ b/server/proxy/streams/io.go @@ -0,0 +1,45 @@ +package streams + +import ( + "github.com/golang/protobuf/ptypes" + + streamsv1 "github.com/docker/api/protos/streams/v1" +) + +// IO implements an io.ReadWriter that forwards everything to the stream +type IO struct { + Stream *Stream +} + +func (io *IO) Read(p []byte) (int, error) { + a, err := io.Stream.Recv() + if err != nil { + return 0, err + } + + var m streamsv1.BytesMessage + err = ptypes.UnmarshalAny(a, &m) + if err != nil { + return 0, err + } + + return copy(p, m.Value), nil +} + +func (io *IO) Write(p []byte) (n int, err error) { + if len(p) == 0 { + return 0, nil + } + + message := streamsv1.BytesMessage{ + Type: streamsv1.IOStream_STDOUT, + Value: p, + } + + m, err := ptypes.MarshalAny(&message) + if err != nil { + return 0, err + } + + return len(message.Value), io.Stream.SendMsg(m) +} diff --git a/server/proxy/streams/logs.go b/server/proxy/streams/logs.go new file mode 100644 index 000000000..15f24f5f1 --- /dev/null +++ b/server/proxy/streams/logs.go @@ -0,0 +1,26 @@ +package streams + +import ( + "io" + + "google.golang.org/grpc" + + containersv1 "github.com/docker/api/protos/containers/v1" +) + +// Log implements an io.Writer that proxies logs over a gRPC stream +type Log struct { + Stream grpc.ServerStream +} + +func newStreamWriter(stream grpc.ServerStream) io.Writer { + return &Log{ + Stream: stream, + } +} + +func (w *Log) Write(p []byte) (n int, err error) { + return len(p), w.Stream.SendMsg(&containersv1.LogsResponse{ + Value: p, + }) +} diff --git a/server/proxy/logstream_test.go b/server/proxy/streams/logs_test.go similarity index 98% rename from server/proxy/logstream_test.go rename to server/proxy/streams/logs_test.go index fa045a009..fbf1b8df0 100644 --- a/server/proxy/logstream_test.go +++ b/server/proxy/streams/logs_test.go @@ -1,4 +1,4 @@ -package proxy +package streams import ( "context" diff --git a/server/proxy/streams/stream.go b/server/proxy/streams/stream.go new file mode 100644 index 000000000..218eb5c1a --- /dev/null +++ b/server/proxy/streams/stream.go @@ -0,0 +1,31 @@ +package streams + +import ( + "sync" + + streamsv1 "github.com/docker/api/protos/streams/v1" +) + +// Stream is a bidirectional stream for container IO +type Stream struct { + streamsv1.Streaming_NewStreamServer + + errm sync.Mutex + ErrChan chan<- error +} + +// CloseWithError sends the result of an action to the errChan or nil +// if no erros +func (s *Stream) CloseWithError(err error) error { + s.errm.Lock() + defer s.errm.Unlock() + + if s.ErrChan != nil { + if err != nil { + s.ErrChan <- err + } + close(s.ErrChan) + s.ErrChan = nil + } + return nil +} diff --git a/server/proxy/streams_test.go b/server/proxy/streams/stream_test.go similarity index 92% rename from server/proxy/streams_test.go rename to server/proxy/streams/stream_test.go index 90c6ae5db..ecbb5f111 100644 --- a/server/proxy/streams_test.go +++ b/server/proxy/streams/stream_test.go @@ -1,4 +1,4 @@ -package proxy +package streams import ( "context" @@ -54,7 +54,7 @@ func (bs *byteStream) RecvMsg(m interface{}) error { return nil } -func getReader(t *testing.T, in []byte, errResult error) reader { +func getReader(t *testing.T, in []byte, errResult error) IO { message := streamsv1.BytesMessage{ Type: streamsv1.IOStream_STDOUT, Value: in, @@ -62,8 +62,8 @@ func getReader(t *testing.T, in []byte, errResult error) reader { m, err := ptypes.MarshalAny(&message) require.Nil(t, err) - return reader{ - stream: &Stream{ + return IO{ + Stream: &Stream{ Streaming_NewStreamServer: &byteStream{ recvResult: m, recvErr: errResult, @@ -109,7 +109,11 @@ func TestStreamWriter(t *testing.T) { expected := getAny(t, in) bs := byteStream{} - w := writer{stream: &bs} + w := IO{ + Stream: &Stream{ + Streaming_NewStreamServer: &bs, + }, + } n, err := w.Write(in) assert.Nil(t, err) diff --git a/server/server.go b/server/server.go index 533810fc6..159362488 100644 --- a/server/server.go +++ b/server/server.go @@ -126,8 +126,6 @@ func getContext(ctx context.Context) string { // configureContext populates the request context with objects the client // needs: the context store and the api client func configureContext(ctx context.Context, currentContext string) (context.Context, error) { - // s := store.ContextStore(ctx) - // ctx = store.WithContextStore(ctx, s) if currentContext != "" { ctx = apicontext.WithCurrentContext(ctx, currentContext) }