From 5abc68ebddd71d2041c125d31dd42e159ce49c12 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Mon, 16 Nov 2020 12:11:52 +0100 Subject: [PATCH 1/6] Add compose service, run `compose up` through API Signed-off-by: Guillaume Tardif --- cli/cmd/serve.go | 2 ++ server/proxy/compose.go | 62 +++++++++++++++++++++++++++++++++++++++++ server/proxy/proxy.go | 2 ++ 3 files changed, 66 insertions(+) create mode 100644 server/proxy/compose.go diff --git a/cli/cmd/serve.go b/cli/cmd/serve.go index 84667ba87..d11e47a0e 100644 --- a/cli/cmd/serve.go +++ b/cli/cmd/serve.go @@ -23,6 +23,7 @@ import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" + composev1 "github.com/docker/compose-cli/protos/compose/v1" containersv1 "github.com/docker/compose-cli/protos/containers/v1" contextsv1 "github.com/docker/compose-cli/protos/contexts/v1" streamsv1 "github.com/docker/compose-cli/protos/streams/v1" @@ -64,6 +65,7 @@ func runServe(ctx context.Context, opts serveOpts) error { p := proxy.New(ctx) + composev1.RegisterComposeServer(s, p) containersv1.RegisterContainersServer(s, p) contextsv1.RegisterContextsServer(s, p.ContextsProxy()) streamsv1.RegisterStreamingServer(s, p) diff --git a/server/proxy/compose.go b/server/proxy/compose.go new file mode 100644 index 000000000..be250213e --- /dev/null +++ b/server/proxy/compose.go @@ -0,0 +1,62 @@ +/* + Copyright 2020 Docker Compose CLI authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package proxy + +import ( + "context" + + "github.com/compose-spec/compose-go/cli" + "github.com/docker/compose-cli/api/containers" + composev1 "github.com/docker/compose-cli/protos/compose/v1" + containersv1 "github.com/docker/compose-cli/protos/containers/v1" + "github.com/docker/compose-cli/server/proxy/streams" +) + +func (p *proxy) Up(ctx context.Context, request *composev1.ComposeUpRequest) (*composev1.ComposeUpResponse, error) { + options, err := cli.NewProjectOptions(request.Files, + cli.WithOsEnv, + cli.WithWorkingDirectory(request.WorkDir), + cli.WithName(request.ProjectName)) + if err != nil { + return nil, err + } + + project, err := cli.ProjectFromOptions(options) + if err != nil { + return nil, err + } + + return &composev1.ComposeUpResponse{}, Client(ctx).ComposeService().Up(ctx, project, true) +} + +func (p *proxy) Down(ctx context.Context, request *composev1.ComposeDownRequest) (*composev1.ComposeDownResponse, error) { + err := Client(ctx).ComposeService().Down(ctx, "TODO") + if err != nil { + return nil, err + } + response := &composev1.ComposeDownResponse{} + return response, err +} + +func (p *proxy) ComposeLogs(request *containersv1.LogsRequest, stream containersv1.Containers_LogsServer) error { + return Client(stream.Context()).ContainerService().Logs(stream.Context(), request.GetContainerId(), containers.LogsRequest{ + Follow: request.Follow, + Writer: &streams.Log{ + Stream: stream, + }, + }) +} diff --git a/server/proxy/proxy.go b/server/proxy/proxy.go index 468b5b9a7..89f46b6ad 100644 --- a/server/proxy/proxy.go +++ b/server/proxy/proxy.go @@ -22,6 +22,7 @@ import ( "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/config" + composev1 "github.com/docker/compose-cli/protos/compose/v1" containersv1 "github.com/docker/compose-cli/protos/containers/v1" contextsv1 "github.com/docker/compose-cli/protos/contexts/v1" streamsv1 "github.com/docker/compose-cli/protos/streams/v1" @@ -45,6 +46,7 @@ func Client(ctx context.Context) *client.Client { // Proxy implements the gRPC server and forwards the actions // to the right backend type Proxy interface { + composev1.ComposeServer containersv1.ContainersServer streamsv1.StreamingServer volumesv1.VolumesServer From 5906677a2c8edba96fef7029119dae6f76379ab8 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Mon, 16 Nov 2020 12:19:59 +0100 Subject: [PATCH 2/6] Add gRPC proxy for `compose down` Signed-off-by: Guillaume Tardif --- protos/compose/v1/compose.pb.go | 74 +++++++++++++++++++++++---------- protos/compose/v1/compose.proto | 3 ++ server/proxy/compose.go | 14 ++++++- 3 files changed, 68 insertions(+), 23 deletions(-) diff --git a/protos/compose/v1/compose.pb.go b/protos/compose/v1/compose.pb.go index 595d0fd9a..ae7f5ee88 100644 --- a/protos/compose/v1/compose.pb.go +++ b/protos/compose/v1/compose.pb.go @@ -149,6 +149,10 @@ type ComposeDownRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + ProjectName string `protobuf:"bytes,1,opt,name=projectName,proto3" json:"projectName,omitempty"` + WorkDir string `protobuf:"bytes,2,opt,name=workDir,proto3" json:"workDir,omitempty"` + Files []string `protobuf:"bytes,3,rep,name=files,proto3" json:"files,omitempty"` } func (x *ComposeDownRequest) Reset() { @@ -183,6 +187,27 @@ func (*ComposeDownRequest) Descriptor() ([]byte, []int) { return file_protos_compose_v1_compose_proto_rawDescGZIP(), []int{2} } +func (x *ComposeDownRequest) GetProjectName() string { + if x != nil { + return x.ProjectName + } + return "" +} + +func (x *ComposeDownRequest) GetWorkDir() string { + if x != nil { + return x.WorkDir + } + return "" +} + +func (x *ComposeDownRequest) GetFiles() []string { + if x != nil { + return x.Files + } + return nil +} + type ComposeDownResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -235,29 +260,34 @@ var file_protos_compose_v1_compose_proto_rawDesc = []byte{ 0x6b, 0x44, 0x69, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x77, 0x6f, 0x72, 0x6b, 0x44, 0x69, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x13, 0x0a, 0x11, 0x43, 0x6f, 0x6d, - 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, + 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x66, 0x0a, 0x12, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x22, 0x15, 0x0a, 0x13, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, - 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xed, 0x01, 0x0a, 0x07, - 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x12, 0x6d, 0x0a, 0x02, 0x55, 0x70, 0x12, 0x32, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, - 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 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, 0x6d, 0x70, 0x6f, 0x73, - 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, 0x04, 0x44, 0x6f, 0x77, 0x6e, 0x12, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, - 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 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, 0x6d, - 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, - 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, - 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, - 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, + 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x77, 0x6f, 0x72, 0x6b, 0x44, 0x69, + 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x77, 0x6f, 0x72, 0x6b, 0x44, 0x69, 0x72, + 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x15, 0x0a, 0x13, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, + 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xed, 0x01, + 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x12, 0x6d, 0x0a, 0x02, 0x55, 0x70, 0x12, + 0x32, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 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, 0x6d, 0x70, + 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, 0x04, 0x44, 0x6f, 0x77, 0x6e, + 0x12, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, + 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, + 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x6f, 0x63, 0x6b, + 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2f, 0x76, 0x31, + 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/protos/compose/v1/compose.proto b/protos/compose/v1/compose.proto index fbe9a31b4..a0adfedb6 100644 --- a/protos/compose/v1/compose.proto +++ b/protos/compose/v1/compose.proto @@ -34,6 +34,9 @@ message ComposeUpResponse { } message ComposeDownRequest { + string projectName = 1; + string workDir = 2; + repeated string files = 3; } message ComposeDownResponse { diff --git a/server/proxy/compose.go b/server/proxy/compose.go index be250213e..786daa914 100644 --- a/server/proxy/compose.go +++ b/server/proxy/compose.go @@ -44,7 +44,19 @@ func (p *proxy) Up(ctx context.Context, request *composev1.ComposeUpRequest) (*c } func (p *proxy) Down(ctx context.Context, request *composev1.ComposeDownRequest) (*composev1.ComposeDownResponse, error) { - err := Client(ctx).ComposeService().Down(ctx, "TODO") + options, err := cli.NewProjectOptions(request.Files, + cli.WithOsEnv, + cli.WithWorkingDirectory(request.WorkDir), + cli.WithName(request.ProjectName)) + if err != nil { + return nil, err + } + + project, err := cli.ProjectFromOptions(options) + if err != nil { + return nil, err + } + err = Client(ctx).ComposeService().Down(ctx, project.Name) if err != nil { return nil, err } From b4e8c28ecfdd1d4bb35f66e1b8266f2de0ba013e Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Mon, 16 Nov 2020 12:47:43 +0100 Subject: [PATCH 3/6] Add compose project name in gRPC response for up and down Signed-off-by: Guillaume Tardif --- protos/compose/v1/compose.pb.go | 76 +++++++++++++++++++++------------ protos/compose/v1/compose.proto | 2 + server/proxy/compose.go | 55 +++++++++--------------- 3 files changed, 70 insertions(+), 63 deletions(-) diff --git a/protos/compose/v1/compose.pb.go b/protos/compose/v1/compose.pb.go index ae7f5ee88..d80ffe9b2 100644 --- a/protos/compose/v1/compose.pb.go +++ b/protos/compose/v1/compose.pb.go @@ -111,6 +111,8 @@ type ComposeUpResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + ProjectName string `protobuf:"bytes,1,opt,name=projectName,proto3" json:"projectName,omitempty"` } func (x *ComposeUpResponse) Reset() { @@ -145,6 +147,13 @@ func (*ComposeUpResponse) Descriptor() ([]byte, []int) { return file_protos_compose_v1_compose_proto_rawDescGZIP(), []int{1} } +func (x *ComposeUpResponse) GetProjectName() string { + if x != nil { + return x.ProjectName + } + return "" +} + type ComposeDownRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -212,6 +221,8 @@ type ComposeDownResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + ProjectName string `protobuf:"bytes,1,opt,name=projectName,proto3" json:"projectName,omitempty"` } func (x *ComposeDownResponse) Reset() { @@ -246,6 +257,13 @@ func (*ComposeDownResponse) Descriptor() ([]byte, []int) { return file_protos_compose_v1_compose_proto_rawDescGZIP(), []int{3} } +func (x *ComposeDownResponse) GetProjectName() string { + if x != nil { + return x.ProjectName + } + return "" +} + var File_protos_compose_v1_compose_proto protoreflect.FileDescriptor var file_protos_compose_v1_compose_proto_rawDesc = []byte{ @@ -259,35 +277,39 @@ var file_protos_compose_v1_compose_proto_rawDesc = []byte{ 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x77, 0x6f, 0x72, 0x6b, 0x44, 0x69, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x77, 0x6f, 0x72, 0x6b, 0x44, 0x69, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x13, 0x0a, 0x11, 0x43, 0x6f, 0x6d, - 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x66, - 0x0a, 0x12, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, - 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x77, 0x6f, 0x72, 0x6b, 0x44, 0x69, - 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x77, 0x6f, 0x72, 0x6b, 0x44, 0x69, 0x72, - 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x15, 0x0a, 0x13, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, - 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xed, 0x01, - 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x12, 0x6d, 0x0a, 0x02, 0x55, 0x70, 0x12, - 0x32, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, - 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, + 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x35, 0x0a, 0x11, 0x43, 0x6f, 0x6d, + 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, + 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, + 0x22, 0x66, 0x0a, 0x12, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, + 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x77, 0x6f, 0x72, 0x6b, + 0x44, 0x69, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x77, 0x6f, 0x72, 0x6b, 0x44, + 0x69, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x37, 0x0a, 0x13, 0x43, 0x6f, 0x6d, 0x70, + 0x6f, 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, + 0x65, 0x32, 0xed, 0x01, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x12, 0x6d, 0x0a, + 0x02, 0x55, 0x70, 0x12, 0x32, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, 0x04, 0x44, 0x6f, 0x77, 0x6e, - 0x12, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, - 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, - 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x6f, 0x63, 0x6b, - 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2f, 0x76, 0x31, - 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, + 0x73, 0x65, 0x55, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, 0x04, + 0x44, 0x6f, 0x77, 0x6e, 0x12, 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, 0x6d, + 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, + 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, + 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2d, 0x63, + 0x6c, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, + 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/protos/compose/v1/compose.proto b/protos/compose/v1/compose.proto index a0adfedb6..fb6f28c92 100644 --- a/protos/compose/v1/compose.proto +++ b/protos/compose/v1/compose.proto @@ -31,6 +31,7 @@ message ComposeUpRequest { } message ComposeUpResponse { + string projectName = 1; } message ComposeDownRequest { @@ -40,4 +41,5 @@ message ComposeDownRequest { } message ComposeDownResponse { + string projectName = 1; } diff --git a/server/proxy/compose.go b/server/proxy/compose.go index 786daa914..6da865e16 100644 --- a/server/proxy/compose.go +++ b/server/proxy/compose.go @@ -20,55 +20,38 @@ import ( "context" "github.com/compose-spec/compose-go/cli" - "github.com/docker/compose-cli/api/containers" + "github.com/compose-spec/compose-go/types" composev1 "github.com/docker/compose-cli/protos/compose/v1" - containersv1 "github.com/docker/compose-cli/protos/containers/v1" - "github.com/docker/compose-cli/server/proxy/streams" ) func (p *proxy) Up(ctx context.Context, request *composev1.ComposeUpRequest) (*composev1.ComposeUpResponse, error) { - options, err := cli.NewProjectOptions(request.Files, - cli.WithOsEnv, - cli.WithWorkingDirectory(request.WorkDir), - cli.WithName(request.ProjectName)) + project, err := getComposeProject(request.Files, request.WorkDir, request.ProjectName) if err != nil { return nil, err } - - project, err := cli.ProjectFromOptions(options) - if err != nil { - return nil, err - } - - return &composev1.ComposeUpResponse{}, Client(ctx).ComposeService().Up(ctx, project, true) + return &composev1.ComposeUpResponse{ProjectName: project.Name}, Client(ctx).ComposeService().Up(ctx, project, true) } func (p *proxy) Down(ctx context.Context, request *composev1.ComposeDownRequest) (*composev1.ComposeDownResponse, error) { - options, err := cli.NewProjectOptions(request.Files, - cli.WithOsEnv, - cli.WithWorkingDirectory(request.WorkDir), - cli.WithName(request.ProjectName)) + project, err := getComposeProject(request.Files, request.WorkDir, request.ProjectName) if err != nil { return nil, err } - - project, err := cli.ProjectFromOptions(options) - if err != nil { - return nil, err - } - err = Client(ctx).ComposeService().Down(ctx, project.Name) - if err != nil { - return nil, err - } - response := &composev1.ComposeDownResponse{} - return response, err + return &composev1.ComposeDownResponse{ProjectName: project.Name}, Client(ctx).ComposeService().Down(ctx, project.Name) } -func (p *proxy) ComposeLogs(request *containersv1.LogsRequest, stream containersv1.Containers_LogsServer) error { - return Client(stream.Context()).ContainerService().Logs(stream.Context(), request.GetContainerId(), containers.LogsRequest{ - Follow: request.Follow, - Writer: &streams.Log{ - Stream: stream, - }, - }) +func (p *proxy) ListStacks(ctx context.Context, request *composev1.ComposeDownRequest) (*composev1.ComposeDownResponse, error) { + project, err := getComposeProject(request.Files, request.WorkDir, request.ProjectName) + if err != nil { + return nil, err + } + return &composev1.ComposeDownResponse{ProjectName: project.Name}, Client(ctx).ComposeService().Down(ctx, project.Name) +} + +func getComposeProject(files []string, workingDir string, projectName string) (*types.Project, error) { + options, err := cli.NewProjectOptions(files, cli.WithWorkingDirectory(workingDir), cli.WithName(projectName)) + if err != nil { + return nil, err + } + return cli.ProjectFromOptions(options) } From 631c75051ddf699653340ec9807acdf784d534dc Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Mon, 16 Nov 2020 14:58:28 +0100 Subject: [PATCH 4/6] Adding compose ls API Signed-off-by: Guillaume Tardif --- protos/compose/v1/compose.pb.go | 341 +++++++++++++++++++++++++++++--- protos/compose/v1/compose.proto | 18 ++ server/proxy/compose.go | 15 +- 3 files changed, 343 insertions(+), 31 deletions(-) diff --git a/protos/compose/v1/compose.pb.go b/protos/compose/v1/compose.pb.go index d80ffe9b2..764852bf2 100644 --- a/protos/compose/v1/compose.pb.go +++ b/protos/compose/v1/compose.pb.go @@ -264,6 +264,187 @@ func (x *ComposeDownResponse) GetProjectName() string { return "" } +type ComposeListRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProjectName string `protobuf:"bytes,1,opt,name=projectName,proto3" json:"projectName,omitempty"` + WorkDir string `protobuf:"bytes,2,opt,name=workDir,proto3" json:"workDir,omitempty"` + Files []string `protobuf:"bytes,3,rep,name=files,proto3" json:"files,omitempty"` +} + +func (x *ComposeListRequest) Reset() { + *x = ComposeListRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_protos_compose_v1_compose_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ComposeListRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ComposeListRequest) ProtoMessage() {} + +func (x *ComposeListRequest) ProtoReflect() protoreflect.Message { + mi := &file_protos_compose_v1_compose_proto_msgTypes[4] + 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 ComposeListRequest.ProtoReflect.Descriptor instead. +func (*ComposeListRequest) Descriptor() ([]byte, []int) { + return file_protos_compose_v1_compose_proto_rawDescGZIP(), []int{4} +} + +func (x *ComposeListRequest) GetProjectName() string { + if x != nil { + return x.ProjectName + } + return "" +} + +func (x *ComposeListRequest) GetWorkDir() string { + if x != nil { + return x.WorkDir + } + return "" +} + +func (x *ComposeListRequest) GetFiles() []string { + if x != nil { + return x.Files + } + return nil +} + +type ComposeListResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Stacks []*Stack `protobuf:"bytes,1,rep,name=stacks,proto3" json:"stacks,omitempty"` +} + +func (x *ComposeListResponse) Reset() { + *x = ComposeListResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_protos_compose_v1_compose_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ComposeListResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ComposeListResponse) ProtoMessage() {} + +func (x *ComposeListResponse) ProtoReflect() protoreflect.Message { + mi := &file_protos_compose_v1_compose_proto_msgTypes[5] + 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 ComposeListResponse.ProtoReflect.Descriptor instead. +func (*ComposeListResponse) Descriptor() ([]byte, []int) { + return file_protos_compose_v1_compose_proto_rawDescGZIP(), []int{5} +} + +func (x *ComposeListResponse) GetStacks() []*Stack { + if x != nil { + return x.Stacks + } + return nil +} + +type Stack struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Status string `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"` + Reason string `protobuf:"bytes,4,opt,name=reason,proto3" json:"reason,omitempty"` +} + +func (x *Stack) Reset() { + *x = Stack{} + if protoimpl.UnsafeEnabled { + mi := &file_protos_compose_v1_compose_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Stack) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Stack) ProtoMessage() {} + +func (x *Stack) ProtoReflect() protoreflect.Message { + mi := &file_protos_compose_v1_compose_proto_msgTypes[6] + 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 Stack.ProtoReflect.Descriptor instead. +func (*Stack) Descriptor() ([]byte, []int) { + return file_protos_compose_v1_compose_proto_rawDescGZIP(), []int{6} +} + +func (x *Stack) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Stack) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Stack) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +func (x *Stack) GetReason() string { + if x != nil { + return x.Reason + } + return "" +} + var File_protos_compose_v1_compose_proto protoreflect.FileDescriptor var file_protos_compose_v1_compose_proto_rawDesc = []byte{ @@ -291,25 +472,51 @@ var file_protos_compose_v1_compose_proto_rawDesc = []byte{ 0x6f, 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, - 0x65, 0x32, 0xed, 0x01, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x12, 0x6d, 0x0a, - 0x02, 0x55, 0x70, 0x12, 0x32, 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, 0x6d, 0x70, - 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x6f, + 0x65, 0x22, 0x66, 0x0a, 0x12, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x4c, 0x69, 0x73, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, + 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x77, 0x6f, 0x72, + 0x6b, 0x44, 0x69, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x77, 0x6f, 0x72, 0x6b, + 0x44, 0x69, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x56, 0x0a, 0x13, 0x43, 0x6f, 0x6d, + 0x70, 0x6f, 0x73, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x3f, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x27, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x52, 0x06, 0x73, 0x74, 0x61, 0x63, 0x6b, + 0x73, 0x22, 0x5b, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x32, 0xe8, + 0x02, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x12, 0x6d, 0x0a, 0x02, 0x55, 0x70, + 0x12, 0x32, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 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, 0x6d, + 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x55, + 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, 0x04, 0x44, 0x6f, 0x77, + 0x6e, 0x12, 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, 0x6d, 0x70, 0x6f, 0x73, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, - 0x73, 0x65, 0x55, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, 0x04, - 0x44, 0x6f, 0x77, 0x6e, 0x12, 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, 0x6d, - 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, - 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, - 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2d, 0x63, - 0x6c, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, - 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x79, + 0x0a, 0x0a, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x73, 0x12, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x35, 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, 0x6d, 0x70, 0x6f, + 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2f, 0x63, + 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -324,23 +531,29 @@ func file_protos_compose_v1_compose_proto_rawDescGZIP() []byte { return file_protos_compose_v1_compose_proto_rawDescData } -var file_protos_compose_v1_compose_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_protos_compose_v1_compose_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_protos_compose_v1_compose_proto_goTypes = []interface{}{ (*ComposeUpRequest)(nil), // 0: com.docker.api.protos.compose.v1.ComposeUpRequest (*ComposeUpResponse)(nil), // 1: com.docker.api.protos.compose.v1.ComposeUpResponse (*ComposeDownRequest)(nil), // 2: com.docker.api.protos.compose.v1.ComposeDownRequest (*ComposeDownResponse)(nil), // 3: com.docker.api.protos.compose.v1.ComposeDownResponse + (*ComposeListRequest)(nil), // 4: com.docker.api.protos.compose.v1.ComposeListRequest + (*ComposeListResponse)(nil), // 5: com.docker.api.protos.compose.v1.ComposeListResponse + (*Stack)(nil), // 6: com.docker.api.protos.compose.v1.Stack } var file_protos_compose_v1_compose_proto_depIdxs = []int32{ - 0, // 0: com.docker.api.protos.compose.v1.Compose.Up:input_type -> com.docker.api.protos.compose.v1.ComposeUpRequest - 2, // 1: com.docker.api.protos.compose.v1.Compose.Down:input_type -> com.docker.api.protos.compose.v1.ComposeDownRequest - 1, // 2: com.docker.api.protos.compose.v1.Compose.Up:output_type -> com.docker.api.protos.compose.v1.ComposeUpResponse - 3, // 3: com.docker.api.protos.compose.v1.Compose.Down:output_type -> com.docker.api.protos.compose.v1.ComposeDownResponse - 2, // [2:4] is the sub-list for method output_type - 0, // [0:2] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 6, // 0: com.docker.api.protos.compose.v1.ComposeListResponse.stacks:type_name -> com.docker.api.protos.compose.v1.Stack + 0, // 1: com.docker.api.protos.compose.v1.Compose.Up:input_type -> com.docker.api.protos.compose.v1.ComposeUpRequest + 2, // 2: com.docker.api.protos.compose.v1.Compose.Down:input_type -> com.docker.api.protos.compose.v1.ComposeDownRequest + 4, // 3: com.docker.api.protos.compose.v1.Compose.ListStacks:input_type -> com.docker.api.protos.compose.v1.ComposeListRequest + 1, // 4: com.docker.api.protos.compose.v1.Compose.Up:output_type -> com.docker.api.protos.compose.v1.ComposeUpResponse + 3, // 5: com.docker.api.protos.compose.v1.Compose.Down:output_type -> com.docker.api.protos.compose.v1.ComposeDownResponse + 5, // 6: com.docker.api.protos.compose.v1.Compose.ListStacks:output_type -> com.docker.api.protos.compose.v1.ComposeListResponse + 4, // [4:7] is the sub-list for method output_type + 1, // [1:4] 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 } func init() { file_protos_compose_v1_compose_proto_init() } @@ -397,6 +610,42 @@ func file_protos_compose_v1_compose_proto_init() { return nil } } + file_protos_compose_v1_compose_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ComposeListRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_protos_compose_v1_compose_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ComposeListResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_protos_compose_v1_compose_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Stack); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -404,7 +653,7 @@ func file_protos_compose_v1_compose_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_protos_compose_v1_compose_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, @@ -432,6 +681,7 @@ const _ = grpc.SupportPackageIsVersion6 type ComposeClient interface { Up(ctx context.Context, in *ComposeUpRequest, opts ...grpc.CallOption) (*ComposeUpResponse, error) Down(ctx context.Context, in *ComposeDownRequest, opts ...grpc.CallOption) (*ComposeDownResponse, error) + ListStacks(ctx context.Context, in *ComposeListRequest, opts ...grpc.CallOption) (*ComposeListResponse, error) } type composeClient struct { @@ -460,10 +710,20 @@ func (c *composeClient) Down(ctx context.Context, in *ComposeDownRequest, opts . return out, nil } +func (c *composeClient) ListStacks(ctx context.Context, in *ComposeListRequest, opts ...grpc.CallOption) (*ComposeListResponse, error) { + out := new(ComposeListResponse) + err := c.cc.Invoke(ctx, "/com.docker.api.protos.compose.v1.Compose/ListStacks", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ComposeServer is the server API for Compose service. type ComposeServer interface { Up(context.Context, *ComposeUpRequest) (*ComposeUpResponse, error) Down(context.Context, *ComposeDownRequest) (*ComposeDownResponse, error) + ListStacks(context.Context, *ComposeListRequest) (*ComposeListResponse, error) } // UnimplementedComposeServer can be embedded to have forward compatible implementations. @@ -476,6 +736,9 @@ func (*UnimplementedComposeServer) Up(context.Context, *ComposeUpRequest) (*Comp func (*UnimplementedComposeServer) Down(context.Context, *ComposeDownRequest) (*ComposeDownResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Down not implemented") } +func (*UnimplementedComposeServer) ListStacks(context.Context, *ComposeListRequest) (*ComposeListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListStacks not implemented") +} func RegisterComposeServer(s *grpc.Server, srv ComposeServer) { s.RegisterService(&_Compose_serviceDesc, srv) @@ -517,6 +780,24 @@ func _Compose_Down_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Compose_ListStacks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ComposeListRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ComposeServer).ListStacks(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.docker.api.protos.compose.v1.Compose/ListStacks", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ComposeServer).ListStacks(ctx, req.(*ComposeListRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Compose_serviceDesc = grpc.ServiceDesc{ ServiceName: "com.docker.api.protos.compose.v1.Compose", HandlerType: (*ComposeServer)(nil), @@ -529,6 +810,10 @@ var _Compose_serviceDesc = grpc.ServiceDesc{ MethodName: "Down", Handler: _Compose_Down_Handler, }, + { + MethodName: "ListStacks", + Handler: _Compose_ListStacks_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "protos/compose/v1/compose.proto", diff --git a/protos/compose/v1/compose.proto b/protos/compose/v1/compose.proto index fb6f28c92..a1b861057 100644 --- a/protos/compose/v1/compose.proto +++ b/protos/compose/v1/compose.proto @@ -22,6 +22,7 @@ option go_package = "github.com/docker/compose-cli/protos/compose/v1;v1"; service Compose { rpc Up(ComposeUpRequest) returns (ComposeUpResponse); rpc Down(ComposeDownRequest) returns (ComposeDownResponse); + rpc ListStacks(ComposeListRequest)returns (ComposeListResponse); } message ComposeUpRequest { @@ -43,3 +44,20 @@ message ComposeDownRequest { message ComposeDownResponse { string projectName = 1; } + +message ComposeListRequest { + string projectName = 1; + string workDir = 2; + repeated string files = 3; +} + +message ComposeListResponse { + repeated Stack stacks = 1; +} + +message Stack { + string id = 1; + string name = 2; + string status = 3; + string reason = 4; +} diff --git a/server/proxy/compose.go b/server/proxy/compose.go index 6da865e16..608bc0a9f 100644 --- a/server/proxy/compose.go +++ b/server/proxy/compose.go @@ -40,12 +40,21 @@ func (p *proxy) Down(ctx context.Context, request *composev1.ComposeDownRequest) return &composev1.ComposeDownResponse{ProjectName: project.Name}, Client(ctx).ComposeService().Down(ctx, project.Name) } -func (p *proxy) ListStacks(ctx context.Context, request *composev1.ComposeDownRequest) (*composev1.ComposeDownResponse, error) { - project, err := getComposeProject(request.Files, request.WorkDir, request.ProjectName) +func (p *proxy) ListStacks(ctx context.Context, request *composev1.ComposeListRequest) (*composev1.ComposeListResponse, error) { + stacks, err := Client(ctx).ComposeService().List(ctx, request.ProjectName) if err != nil { return nil, err } - return &composev1.ComposeDownResponse{ProjectName: project.Name}, Client(ctx).ComposeService().Down(ctx, project.Name) + response := []*composev1.Stack{} + for _, stack := range stacks { + response = append(response, &composev1.Stack{ + Id: stack.ID, + Name: stack.Name, + Status: stack.Status, + Reason: stack.Reason, + }) + } + return &composev1.ComposeListResponse{Stacks: response}, nil } func getComposeProject(files []string, workingDir string, projectName string) (*types.Project, error) { From 4a975a5b0bcf42380ad7273d959356a9f2eba04e Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Mon, 16 Nov 2020 16:38:39 +0100 Subject: [PATCH 5/6] Adding compose ps API Signed-off-by: Guillaume Tardif --- protos/compose/v1/compose.pb.go | 395 +++++++++++++++++++++++++++----- protos/compose/v1/compose.proto | 21 +- server/proxy/compose.go | 34 ++- 3 files changed, 386 insertions(+), 64 deletions(-) diff --git a/protos/compose/v1/compose.pb.go b/protos/compose/v1/compose.pb.go index 764852bf2..9c7acb0ec 100644 --- a/protos/compose/v1/compose.pb.go +++ b/protos/compose/v1/compose.pb.go @@ -269,9 +269,7 @@ type ComposeListRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ProjectName string `protobuf:"bytes,1,opt,name=projectName,proto3" json:"projectName,omitempty"` - WorkDir string `protobuf:"bytes,2,opt,name=workDir,proto3" json:"workDir,omitempty"` - Files []string `protobuf:"bytes,3,rep,name=files,proto3" json:"files,omitempty"` + ProjectName string `protobuf:"bytes,1,opt,name=projectName,proto3" json:"projectName,omitempty"` } func (x *ComposeListRequest) Reset() { @@ -313,20 +311,6 @@ func (x *ComposeListRequest) GetProjectName() string { return "" } -func (x *ComposeListRequest) GetWorkDir() string { - if x != nil { - return x.WorkDir - } - return "" -} - -func (x *ComposeListRequest) GetFiles() []string { - if x != nil { - return x.Files - } - return nil -} - type ComposeListResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -445,6 +429,195 @@ func (x *Stack) GetReason() string { return "" } +type ComposePsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProjectName string `protobuf:"bytes,1,opt,name=projectName,proto3" json:"projectName,omitempty"` + WorkDir string `protobuf:"bytes,2,opt,name=workDir,proto3" json:"workDir,omitempty"` + Files []string `protobuf:"bytes,3,rep,name=files,proto3" json:"files,omitempty"` +} + +func (x *ComposePsRequest) Reset() { + *x = ComposePsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_protos_compose_v1_compose_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ComposePsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ComposePsRequest) ProtoMessage() {} + +func (x *ComposePsRequest) ProtoReflect() protoreflect.Message { + mi := &file_protos_compose_v1_compose_proto_msgTypes[7] + 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 ComposePsRequest.ProtoReflect.Descriptor instead. +func (*ComposePsRequest) Descriptor() ([]byte, []int) { + return file_protos_compose_v1_compose_proto_rawDescGZIP(), []int{7} +} + +func (x *ComposePsRequest) GetProjectName() string { + if x != nil { + return x.ProjectName + } + return "" +} + +func (x *ComposePsRequest) GetWorkDir() string { + if x != nil { + return x.WorkDir + } + return "" +} + +func (x *ComposePsRequest) GetFiles() []string { + if x != nil { + return x.Files + } + return nil +} + +type ComposePsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Services []*Service `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"` +} + +func (x *ComposePsResponse) Reset() { + *x = ComposePsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_protos_compose_v1_compose_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ComposePsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ComposePsResponse) ProtoMessage() {} + +func (x *ComposePsResponse) ProtoReflect() protoreflect.Message { + mi := &file_protos_compose_v1_compose_proto_msgTypes[8] + 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 ComposePsResponse.ProtoReflect.Descriptor instead. +func (*ComposePsResponse) Descriptor() ([]byte, []int) { + return file_protos_compose_v1_compose_proto_rawDescGZIP(), []int{8} +} + +func (x *ComposePsResponse) GetServices() []*Service { + if x != nil { + return x.Services + } + return nil +} + +type Service struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Replicas uint32 `protobuf:"varint,3,opt,name=replicas,proto3" json:"replicas,omitempty"` + Desired uint32 `protobuf:"varint,4,opt,name=desired,proto3" json:"desired,omitempty"` + Ports []string `protobuf:"bytes,5,rep,name=Ports,proto3" json:"Ports,omitempty"` +} + +func (x *Service) Reset() { + *x = Service{} + if protoimpl.UnsafeEnabled { + mi := &file_protos_compose_v1_compose_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Service) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Service) ProtoMessage() {} + +func (x *Service) ProtoReflect() protoreflect.Message { + mi := &file_protos_compose_v1_compose_proto_msgTypes[9] + 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 Service.ProtoReflect.Descriptor instead. +func (*Service) Descriptor() ([]byte, []int) { + return file_protos_compose_v1_compose_proto_rawDescGZIP(), []int{9} +} + +func (x *Service) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Service) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Service) GetReplicas() uint32 { + if x != nil { + return x.Replicas + } + return 0 +} + +func (x *Service) GetDesired() uint32 { + if x != nil { + return x.Desired + } + return 0 +} + +func (x *Service) GetPorts() []string { + if x != nil { + return x.Ports + } + return nil +} + var File_protos_compose_v1_compose_proto protoreflect.FileDescriptor var file_protos_compose_v1_compose_proto_rawDesc = []byte{ @@ -472,13 +645,10 @@ var file_protos_compose_v1_compose_proto_rawDesc = []byte{ 0x6f, 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, - 0x65, 0x22, 0x66, 0x0a, 0x12, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x4c, 0x69, 0x73, 0x74, + 0x65, 0x22, 0x36, 0x0a, 0x12, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, - 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x77, 0x6f, 0x72, - 0x6b, 0x44, 0x69, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x77, 0x6f, 0x72, 0x6b, - 0x44, 0x69, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x56, 0x0a, 0x13, 0x43, 0x6f, 0x6d, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x56, 0x0a, 0x13, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2e, 0x61, 0x70, @@ -489,34 +659,61 @@ var file_protos_compose_v1_compose_proto_rawDesc = []byte{ 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x32, 0xe8, - 0x02, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x12, 0x6d, 0x0a, 0x02, 0x55, 0x70, - 0x12, 0x32, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 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, 0x6d, - 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x55, - 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, 0x04, 0x44, 0x6f, 0x77, - 0x6e, 0x12, 0x34, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2e, 0x61, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x22, 0x64, + 0x0a, 0x10, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x50, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x77, 0x6f, 0x72, 0x6b, 0x44, 0x69, 0x72, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x77, 0x6f, 0x72, 0x6b, 0x44, 0x69, 0x72, 0x12, 0x14, + 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x66, + 0x69, 0x6c, 0x65, 0x73, 0x22, 0x5a, 0x0a, 0x11, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x50, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x08, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, + 0x22, 0x79, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x08, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x64, + 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x64, 0x65, + 0x73, 0x69, 0x72, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x50, 0x6f, 0x72, 0x74, 0x73, 0x18, 0x05, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x50, 0x6f, 0x72, 0x74, 0x73, 0x32, 0xd7, 0x03, 0x0a, 0x07, + 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x12, 0x6d, 0x0a, 0x02, 0x55, 0x70, 0x12, 0x32, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 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, 0x6d, 0x70, 0x6f, 0x73, - 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, - 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x79, - 0x0a, 0x0a, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x73, 0x12, 0x34, 0x2e, 0x63, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x55, 0x70, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, 0x04, 0x44, 0x6f, 0x77, 0x6e, 0x12, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 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, 0x6d, + 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, + 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x79, 0x0a, 0x0a, 0x4c, + 0x69, 0x73, 0x74, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x73, 0x12, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, + 0x70, 0x6f, 0x73, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x35, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6d, 0x0a, 0x02, 0x50, 0x73, 0x12, 0x32, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x35, 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, 0x6d, 0x70, 0x6f, - 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x4c, 0x69, 0x73, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2f, 0x63, - 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x50, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x50, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, + 0x73, 0x65, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x63, 0x6f, + 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -531,7 +728,7 @@ func file_protos_compose_v1_compose_proto_rawDescGZIP() []byte { return file_protos_compose_v1_compose_proto_rawDescData } -var file_protos_compose_v1_compose_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_protos_compose_v1_compose_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_protos_compose_v1_compose_proto_goTypes = []interface{}{ (*ComposeUpRequest)(nil), // 0: com.docker.api.protos.compose.v1.ComposeUpRequest (*ComposeUpResponse)(nil), // 1: com.docker.api.protos.compose.v1.ComposeUpResponse @@ -540,20 +737,26 @@ var file_protos_compose_v1_compose_proto_goTypes = []interface{}{ (*ComposeListRequest)(nil), // 4: com.docker.api.protos.compose.v1.ComposeListRequest (*ComposeListResponse)(nil), // 5: com.docker.api.protos.compose.v1.ComposeListResponse (*Stack)(nil), // 6: com.docker.api.protos.compose.v1.Stack + (*ComposePsRequest)(nil), // 7: com.docker.api.protos.compose.v1.ComposePsRequest + (*ComposePsResponse)(nil), // 8: com.docker.api.protos.compose.v1.ComposePsResponse + (*Service)(nil), // 9: com.docker.api.protos.compose.v1.Service } var file_protos_compose_v1_compose_proto_depIdxs = []int32{ 6, // 0: com.docker.api.protos.compose.v1.ComposeListResponse.stacks:type_name -> com.docker.api.protos.compose.v1.Stack - 0, // 1: com.docker.api.protos.compose.v1.Compose.Up:input_type -> com.docker.api.protos.compose.v1.ComposeUpRequest - 2, // 2: com.docker.api.protos.compose.v1.Compose.Down:input_type -> com.docker.api.protos.compose.v1.ComposeDownRequest - 4, // 3: com.docker.api.protos.compose.v1.Compose.ListStacks:input_type -> com.docker.api.protos.compose.v1.ComposeListRequest - 1, // 4: com.docker.api.protos.compose.v1.Compose.Up:output_type -> com.docker.api.protos.compose.v1.ComposeUpResponse - 3, // 5: com.docker.api.protos.compose.v1.Compose.Down:output_type -> com.docker.api.protos.compose.v1.ComposeDownResponse - 5, // 6: com.docker.api.protos.compose.v1.Compose.ListStacks:output_type -> com.docker.api.protos.compose.v1.ComposeListResponse - 4, // [4:7] is the sub-list for method output_type - 1, // [1:4] 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 + 9, // 1: com.docker.api.protos.compose.v1.ComposePsResponse.services:type_name -> com.docker.api.protos.compose.v1.Service + 0, // 2: com.docker.api.protos.compose.v1.Compose.Up:input_type -> com.docker.api.protos.compose.v1.ComposeUpRequest + 2, // 3: com.docker.api.protos.compose.v1.Compose.Down:input_type -> com.docker.api.protos.compose.v1.ComposeDownRequest + 4, // 4: com.docker.api.protos.compose.v1.Compose.ListStacks:input_type -> com.docker.api.protos.compose.v1.ComposeListRequest + 7, // 5: com.docker.api.protos.compose.v1.Compose.Ps:input_type -> com.docker.api.protos.compose.v1.ComposePsRequest + 1, // 6: com.docker.api.protos.compose.v1.Compose.Up:output_type -> com.docker.api.protos.compose.v1.ComposeUpResponse + 3, // 7: com.docker.api.protos.compose.v1.Compose.Down:output_type -> com.docker.api.protos.compose.v1.ComposeDownResponse + 5, // 8: com.docker.api.protos.compose.v1.Compose.ListStacks:output_type -> com.docker.api.protos.compose.v1.ComposeListResponse + 8, // 9: com.docker.api.protos.compose.v1.Compose.Ps:output_type -> com.docker.api.protos.compose.v1.ComposePsResponse + 6, // [6:10] is the sub-list for method output_type + 2, // [2:6] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_protos_compose_v1_compose_proto_init() } @@ -646,6 +849,42 @@ func file_protos_compose_v1_compose_proto_init() { return nil } } + file_protos_compose_v1_compose_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ComposePsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_protos_compose_v1_compose_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ComposePsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_protos_compose_v1_compose_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Service); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -653,7 +892,7 @@ func file_protos_compose_v1_compose_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_protos_compose_v1_compose_proto_rawDesc, NumEnums: 0, - NumMessages: 7, + NumMessages: 10, NumExtensions: 0, NumServices: 1, }, @@ -682,6 +921,7 @@ type ComposeClient interface { Up(ctx context.Context, in *ComposeUpRequest, opts ...grpc.CallOption) (*ComposeUpResponse, error) Down(ctx context.Context, in *ComposeDownRequest, opts ...grpc.CallOption) (*ComposeDownResponse, error) ListStacks(ctx context.Context, in *ComposeListRequest, opts ...grpc.CallOption) (*ComposeListResponse, error) + Ps(ctx context.Context, in *ComposePsRequest, opts ...grpc.CallOption) (*ComposePsResponse, error) } type composeClient struct { @@ -719,11 +959,21 @@ func (c *composeClient) ListStacks(ctx context.Context, in *ComposeListRequest, return out, nil } +func (c *composeClient) Ps(ctx context.Context, in *ComposePsRequest, opts ...grpc.CallOption) (*ComposePsResponse, error) { + out := new(ComposePsResponse) + err := c.cc.Invoke(ctx, "/com.docker.api.protos.compose.v1.Compose/Ps", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ComposeServer is the server API for Compose service. type ComposeServer interface { Up(context.Context, *ComposeUpRequest) (*ComposeUpResponse, error) Down(context.Context, *ComposeDownRequest) (*ComposeDownResponse, error) ListStacks(context.Context, *ComposeListRequest) (*ComposeListResponse, error) + Ps(context.Context, *ComposePsRequest) (*ComposePsResponse, error) } // UnimplementedComposeServer can be embedded to have forward compatible implementations. @@ -739,6 +989,9 @@ func (*UnimplementedComposeServer) Down(context.Context, *ComposeDownRequest) (* func (*UnimplementedComposeServer) ListStacks(context.Context, *ComposeListRequest) (*ComposeListResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListStacks not implemented") } +func (*UnimplementedComposeServer) Ps(context.Context, *ComposePsRequest) (*ComposePsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Ps not implemented") +} func RegisterComposeServer(s *grpc.Server, srv ComposeServer) { s.RegisterService(&_Compose_serviceDesc, srv) @@ -798,6 +1051,24 @@ func _Compose_ListStacks_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } +func _Compose_Ps_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ComposePsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ComposeServer).Ps(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/com.docker.api.protos.compose.v1.Compose/Ps", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ComposeServer).Ps(ctx, req.(*ComposePsRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Compose_serviceDesc = grpc.ServiceDesc{ ServiceName: "com.docker.api.protos.compose.v1.Compose", HandlerType: (*ComposeServer)(nil), @@ -814,6 +1085,10 @@ var _Compose_serviceDesc = grpc.ServiceDesc{ MethodName: "ListStacks", Handler: _Compose_ListStacks_Handler, }, + { + MethodName: "Ps", + Handler: _Compose_Ps_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "protos/compose/v1/compose.proto", diff --git a/protos/compose/v1/compose.proto b/protos/compose/v1/compose.proto index a1b861057..c62b63d8f 100644 --- a/protos/compose/v1/compose.proto +++ b/protos/compose/v1/compose.proto @@ -23,6 +23,7 @@ service Compose { rpc Up(ComposeUpRequest) returns (ComposeUpResponse); rpc Down(ComposeDownRequest) returns (ComposeDownResponse); rpc ListStacks(ComposeListRequest)returns (ComposeListResponse); + rpc Ps(ComposePsRequest)returns (ComposePsResponse); } message ComposeUpRequest { @@ -47,8 +48,6 @@ message ComposeDownResponse { message ComposeListRequest { string projectName = 1; - string workDir = 2; - repeated string files = 3; } message ComposeListResponse { @@ -61,3 +60,21 @@ message Stack { string status = 3; string reason = 4; } + +message ComposePsRequest { + string projectName = 1; + string workDir = 2; + repeated string files = 3; +} + +message ComposePsResponse { + repeated Service services = 1; +} + +message Service { + string id = 1; + string name = 2; + uint32 replicas = 3; + uint32 desired = 4; + repeated string Ports = 5; +} diff --git a/server/proxy/compose.go b/server/proxy/compose.go index 608bc0a9f..12c62fa99 100644 --- a/server/proxy/compose.go +++ b/server/proxy/compose.go @@ -33,11 +33,41 @@ func (p *proxy) Up(ctx context.Context, request *composev1.ComposeUpRequest) (*c } func (p *proxy) Down(ctx context.Context, request *composev1.ComposeDownRequest) (*composev1.ComposeDownResponse, error) { - project, err := getComposeProject(request.Files, request.WorkDir, request.ProjectName) + projectName := request.GetProjectName() + if projectName == "" { + project, err := getComposeProject(request.Files, request.WorkDir, request.ProjectName) + if err != nil { + return nil, err + } + projectName = project.Name + } + return &composev1.ComposeDownResponse{ProjectName: projectName}, Client(ctx).ComposeService().Down(ctx, projectName) +} + +func (p *proxy) Ps(ctx context.Context, request *composev1.ComposePsRequest) (*composev1.ComposePsResponse, error) { + projectName := request.GetProjectName() + if projectName == "" { + project, err := getComposeProject(request.Files, request.WorkDir, request.ProjectName) + if err != nil { + return nil, err + } + projectName = project.Name + } + services, err := Client(ctx).ComposeService().Ps(ctx, projectName) if err != nil { return nil, err } - return &composev1.ComposeDownResponse{ProjectName: project.Name}, Client(ctx).ComposeService().Down(ctx, project.Name) + response := []*composev1.Service{} + for _, service := range services { + response = append(response, &composev1.Service{ + Id: service.ID, + Name: service.Name, + Replicas: uint32(service.Replicas), + Desired: uint32(service.Desired), + Ports: service.Ports, + }) + } + return &composev1.ComposePsResponse{Services: response}, nil } func (p *proxy) ListStacks(ctx context.Context, request *composev1.ComposeListRequest) (*composev1.ComposeListResponse, error) { From 08cf86bbfff3dae4004fbeea6eb8690b72e088b2 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Mon, 16 Nov 2020 16:49:50 +0100 Subject: [PATCH 6/6] Rename compose List() => Stacks to avoid name collision, and remove confusion with compose ps, also renamed Services() Signed-off-by: Guillaume Tardif --- protos/compose/v1/compose.pb.go | 98 ++++++++++++++++----------------- protos/compose/v1/compose.proto | 4 +- server/metrics.go | 4 ++ server/metrics_test.go | 2 + server/proxy/compose.go | 5 +- 5 files changed, 60 insertions(+), 53 deletions(-) diff --git a/protos/compose/v1/compose.pb.go b/protos/compose/v1/compose.pb.go index 9c7acb0ec..9a16f4dd0 100644 --- a/protos/compose/v1/compose.pb.go +++ b/protos/compose/v1/compose.pb.go @@ -679,7 +679,7 @@ var file_protos_compose_v1_compose_proto_rawDesc = []byte{ 0x0d, 0x52, 0x08, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x50, 0x6f, 0x72, 0x74, 0x73, 0x18, 0x05, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x50, 0x6f, 0x72, 0x74, 0x73, 0x32, 0xd7, 0x03, 0x0a, 0x07, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x50, 0x6f, 0x72, 0x74, 0x73, 0x32, 0xd9, 0x03, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x12, 0x6d, 0x0a, 0x02, 0x55, 0x70, 0x12, 0x32, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, @@ -694,26 +694,26 @@ var file_protos_compose_v1_compose_proto_rawDesc = []byte{ 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x44, - 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x79, 0x0a, 0x0a, 0x4c, - 0x69, 0x73, 0x74, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x73, 0x12, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, - 0x70, 0x6f, 0x73, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x35, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, - 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6d, 0x0a, 0x02, 0x50, 0x73, 0x12, 0x32, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x50, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x50, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, - 0x73, 0x65, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x63, 0x6f, - 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x75, 0x0a, 0x06, 0x53, + 0x74, 0x61, 0x63, 0x6b, 0x73, 0x12, 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, + 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, + 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, + 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x73, 0x0a, 0x08, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x32, + 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, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x50, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 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, 0x6d, 0x70, 0x6f, + 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x50, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d, + 0x70, 0x6f, 0x73, 0x65, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, + 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -746,12 +746,12 @@ var file_protos_compose_v1_compose_proto_depIdxs = []int32{ 9, // 1: com.docker.api.protos.compose.v1.ComposePsResponse.services:type_name -> com.docker.api.protos.compose.v1.Service 0, // 2: com.docker.api.protos.compose.v1.Compose.Up:input_type -> com.docker.api.protos.compose.v1.ComposeUpRequest 2, // 3: com.docker.api.protos.compose.v1.Compose.Down:input_type -> com.docker.api.protos.compose.v1.ComposeDownRequest - 4, // 4: com.docker.api.protos.compose.v1.Compose.ListStacks:input_type -> com.docker.api.protos.compose.v1.ComposeListRequest - 7, // 5: com.docker.api.protos.compose.v1.Compose.Ps:input_type -> com.docker.api.protos.compose.v1.ComposePsRequest + 4, // 4: com.docker.api.protos.compose.v1.Compose.Stacks:input_type -> com.docker.api.protos.compose.v1.ComposeListRequest + 7, // 5: com.docker.api.protos.compose.v1.Compose.Services:input_type -> com.docker.api.protos.compose.v1.ComposePsRequest 1, // 6: com.docker.api.protos.compose.v1.Compose.Up:output_type -> com.docker.api.protos.compose.v1.ComposeUpResponse 3, // 7: com.docker.api.protos.compose.v1.Compose.Down:output_type -> com.docker.api.protos.compose.v1.ComposeDownResponse - 5, // 8: com.docker.api.protos.compose.v1.Compose.ListStacks:output_type -> com.docker.api.protos.compose.v1.ComposeListResponse - 8, // 9: com.docker.api.protos.compose.v1.Compose.Ps:output_type -> com.docker.api.protos.compose.v1.ComposePsResponse + 5, // 8: com.docker.api.protos.compose.v1.Compose.Stacks:output_type -> com.docker.api.protos.compose.v1.ComposeListResponse + 8, // 9: com.docker.api.protos.compose.v1.Compose.Services:output_type -> com.docker.api.protos.compose.v1.ComposePsResponse 6, // [6:10] is the sub-list for method output_type 2, // [2:6] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name @@ -920,8 +920,8 @@ const _ = grpc.SupportPackageIsVersion6 type ComposeClient interface { Up(ctx context.Context, in *ComposeUpRequest, opts ...grpc.CallOption) (*ComposeUpResponse, error) Down(ctx context.Context, in *ComposeDownRequest, opts ...grpc.CallOption) (*ComposeDownResponse, error) - ListStacks(ctx context.Context, in *ComposeListRequest, opts ...grpc.CallOption) (*ComposeListResponse, error) - Ps(ctx context.Context, in *ComposePsRequest, opts ...grpc.CallOption) (*ComposePsResponse, error) + Stacks(ctx context.Context, in *ComposeListRequest, opts ...grpc.CallOption) (*ComposeListResponse, error) + Services(ctx context.Context, in *ComposePsRequest, opts ...grpc.CallOption) (*ComposePsResponse, error) } type composeClient struct { @@ -950,18 +950,18 @@ func (c *composeClient) Down(ctx context.Context, in *ComposeDownRequest, opts . return out, nil } -func (c *composeClient) ListStacks(ctx context.Context, in *ComposeListRequest, opts ...grpc.CallOption) (*ComposeListResponse, error) { +func (c *composeClient) Stacks(ctx context.Context, in *ComposeListRequest, opts ...grpc.CallOption) (*ComposeListResponse, error) { out := new(ComposeListResponse) - err := c.cc.Invoke(ctx, "/com.docker.api.protos.compose.v1.Compose/ListStacks", in, out, opts...) + err := c.cc.Invoke(ctx, "/com.docker.api.protos.compose.v1.Compose/Stacks", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *composeClient) Ps(ctx context.Context, in *ComposePsRequest, opts ...grpc.CallOption) (*ComposePsResponse, error) { +func (c *composeClient) Services(ctx context.Context, in *ComposePsRequest, opts ...grpc.CallOption) (*ComposePsResponse, error) { out := new(ComposePsResponse) - err := c.cc.Invoke(ctx, "/com.docker.api.protos.compose.v1.Compose/Ps", in, out, opts...) + err := c.cc.Invoke(ctx, "/com.docker.api.protos.compose.v1.Compose/Services", in, out, opts...) if err != nil { return nil, err } @@ -972,8 +972,8 @@ func (c *composeClient) Ps(ctx context.Context, in *ComposePsRequest, opts ...gr type ComposeServer interface { Up(context.Context, *ComposeUpRequest) (*ComposeUpResponse, error) Down(context.Context, *ComposeDownRequest) (*ComposeDownResponse, error) - ListStacks(context.Context, *ComposeListRequest) (*ComposeListResponse, error) - Ps(context.Context, *ComposePsRequest) (*ComposePsResponse, error) + Stacks(context.Context, *ComposeListRequest) (*ComposeListResponse, error) + Services(context.Context, *ComposePsRequest) (*ComposePsResponse, error) } // UnimplementedComposeServer can be embedded to have forward compatible implementations. @@ -986,11 +986,11 @@ func (*UnimplementedComposeServer) Up(context.Context, *ComposeUpRequest) (*Comp func (*UnimplementedComposeServer) Down(context.Context, *ComposeDownRequest) (*ComposeDownResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Down not implemented") } -func (*UnimplementedComposeServer) ListStacks(context.Context, *ComposeListRequest) (*ComposeListResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListStacks not implemented") +func (*UnimplementedComposeServer) Stacks(context.Context, *ComposeListRequest) (*ComposeListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Stacks not implemented") } -func (*UnimplementedComposeServer) Ps(context.Context, *ComposePsRequest) (*ComposePsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Ps not implemented") +func (*UnimplementedComposeServer) Services(context.Context, *ComposePsRequest) (*ComposePsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Services not implemented") } func RegisterComposeServer(s *grpc.Server, srv ComposeServer) { @@ -1033,38 +1033,38 @@ func _Compose_Down_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } -func _Compose_ListStacks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Compose_Stacks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ComposeListRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ComposeServer).ListStacks(ctx, in) + return srv.(ComposeServer).Stacks(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/com.docker.api.protos.compose.v1.Compose/ListStacks", + FullMethod: "/com.docker.api.protos.compose.v1.Compose/Stacks", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ComposeServer).ListStacks(ctx, req.(*ComposeListRequest)) + return srv.(ComposeServer).Stacks(ctx, req.(*ComposeListRequest)) } return interceptor(ctx, in, info, handler) } -func _Compose_Ps_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Compose_Services_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ComposePsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ComposeServer).Ps(ctx, in) + return srv.(ComposeServer).Services(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/com.docker.api.protos.compose.v1.Compose/Ps", + FullMethod: "/com.docker.api.protos.compose.v1.Compose/Services", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ComposeServer).Ps(ctx, req.(*ComposePsRequest)) + return srv.(ComposeServer).Services(ctx, req.(*ComposePsRequest)) } return interceptor(ctx, in, info, handler) } @@ -1082,12 +1082,12 @@ var _Compose_serviceDesc = grpc.ServiceDesc{ Handler: _Compose_Down_Handler, }, { - MethodName: "ListStacks", - Handler: _Compose_ListStacks_Handler, + MethodName: "Stacks", + Handler: _Compose_Stacks_Handler, }, { - MethodName: "Ps", - Handler: _Compose_Ps_Handler, + MethodName: "Services", + Handler: _Compose_Services_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/protos/compose/v1/compose.proto b/protos/compose/v1/compose.proto index c62b63d8f..5feadc381 100644 --- a/protos/compose/v1/compose.proto +++ b/protos/compose/v1/compose.proto @@ -22,8 +22,8 @@ option go_package = "github.com/docker/compose-cli/protos/compose/v1;v1"; service Compose { rpc Up(ComposeUpRequest) returns (ComposeUpResponse); rpc Down(ComposeDownRequest) returns (ComposeDownResponse); - rpc ListStacks(ComposeListRequest)returns (ComposeListResponse); - rpc Ps(ComposePsRequest)returns (ComposePsResponse); + rpc Stacks(ComposeListRequest)returns (ComposeListResponse); + rpc Services(ComposePsRequest)returns (ComposePsResponse); } message ComposeUpRequest { diff --git a/server/metrics.go b/server/metrics.go index b465981f1..bbd1131ec 100644 --- a/server/metrics.go +++ b/server/metrics.go @@ -43,6 +43,10 @@ var ( "/com.docker.api.protos.volumes.v1.Volumes/VolumesDelete": "volume rm", "/com.docker.api.protos.volumes.v1.Volumes/VolumesCreate": "volume create", "/com.docker.api.protos.volumes.v1.Volumes/VolumesInspect": "volume inspect", + "/com.docker.api.protos.compose.v1.Compose/Up": "compose up", + "/com.docker.api.protos.compose.v1.Compose/Down": "compose down", + "/com.docker.api.protos.compose.v1.Compose/Stacks": "compose ls", + "/com.docker.api.protos.compose.v1.Compose/Services": "compose ps", } ) diff --git a/server/metrics_test.go b/server/metrics_test.go index 9c2752308..3b47c7efe 100644 --- a/server/metrics_test.go +++ b/server/metrics_test.go @@ -35,6 +35,7 @@ import ( "github.com/docker/compose-cli/api/volumes" "github.com/docker/compose-cli/errdefs" "github.com/docker/compose-cli/metrics" + composev1 "github.com/docker/compose-cli/protos/compose/v1" containersv1 "github.com/docker/compose-cli/protos/containers/v1" contextsv1 "github.com/docker/compose-cli/protos/contexts/v1" streamsv1 "github.com/docker/compose-cli/protos/streams/v1" @@ -105,6 +106,7 @@ func setupServer() *grpc.Server { ctx := context.TODO() s := New(ctx) p := proxy.New(ctx) + composev1.RegisterComposeServer(s, p) containersv1.RegisterContainersServer(s, p) streamsv1.RegisterStreamingServer(s, p) volumesv1.RegisterVolumesServer(s, p) diff --git a/server/proxy/compose.go b/server/proxy/compose.go index 12c62fa99..a903c05c3 100644 --- a/server/proxy/compose.go +++ b/server/proxy/compose.go @@ -21,6 +21,7 @@ import ( "github.com/compose-spec/compose-go/cli" "github.com/compose-spec/compose-go/types" + composev1 "github.com/docker/compose-cli/protos/compose/v1" ) @@ -44,7 +45,7 @@ func (p *proxy) Down(ctx context.Context, request *composev1.ComposeDownRequest) return &composev1.ComposeDownResponse{ProjectName: projectName}, Client(ctx).ComposeService().Down(ctx, projectName) } -func (p *proxy) Ps(ctx context.Context, request *composev1.ComposePsRequest) (*composev1.ComposePsResponse, error) { +func (p *proxy) Services(ctx context.Context, request *composev1.ComposePsRequest) (*composev1.ComposePsResponse, error) { projectName := request.GetProjectName() if projectName == "" { project, err := getComposeProject(request.Files, request.WorkDir, request.ProjectName) @@ -70,7 +71,7 @@ func (p *proxy) Ps(ctx context.Context, request *composev1.ComposePsRequest) (*c return &composev1.ComposePsResponse{Services: response}, nil } -func (p *proxy) ListStacks(ctx context.Context, request *composev1.ComposeListRequest) (*composev1.ComposeListResponse, error) { +func (p *proxy) Stacks(ctx context.Context, request *composev1.ComposeListRequest) (*composev1.ComposeListResponse, error) { stacks, err := Client(ctx).ComposeService().List(ctx, request.ProjectName) if err != nil { return nil, err