mirror of https://github.com/docker/compose.git
Merge pull request #1729 from ndeloof/drop_compose_grpc
remove obsolete compose grpc service
This commit is contained in:
commit
f34f49a16b
|
@ -24,7 +24,6 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/docker/compose-cli/cli/server"
|
"github.com/docker/compose-cli/cli/server"
|
||||||
composev1 "github.com/docker/compose-cli/cli/server/protos/compose/v1"
|
|
||||||
containersv1 "github.com/docker/compose-cli/cli/server/protos/containers/v1"
|
containersv1 "github.com/docker/compose-cli/cli/server/protos/containers/v1"
|
||||||
contextsv1 "github.com/docker/compose-cli/cli/server/protos/contexts/v1"
|
contextsv1 "github.com/docker/compose-cli/cli/server/protos/contexts/v1"
|
||||||
streamsv1 "github.com/docker/compose-cli/cli/server/protos/streams/v1"
|
streamsv1 "github.com/docker/compose-cli/cli/server/protos/streams/v1"
|
||||||
|
@ -65,7 +64,6 @@ func runServe(ctx context.Context, opts serveOpts) error {
|
||||||
|
|
||||||
p := proxy.New(ctx)
|
p := proxy.New(ctx)
|
||||||
|
|
||||||
composev1.RegisterComposeServer(s, p)
|
|
||||||
containersv1.RegisterContainersServer(s, p)
|
containersv1.RegisterContainersServer(s, p)
|
||||||
contextsv1.RegisterContextsServer(s, p.ContextsProxy())
|
contextsv1.RegisterContextsServer(s, p.ContextsProxy())
|
||||||
streamsv1.RegisterStreamingServer(s, p)
|
streamsv1.RegisterStreamingServer(s, p)
|
||||||
|
|
|
@ -35,7 +35,6 @@ import (
|
||||||
"github.com/docker/compose-cli/api/secrets"
|
"github.com/docker/compose-cli/api/secrets"
|
||||||
"github.com/docker/compose-cli/api/volumes"
|
"github.com/docker/compose-cli/api/volumes"
|
||||||
"github.com/docker/compose-cli/cli/metrics"
|
"github.com/docker/compose-cli/cli/metrics"
|
||||||
composev1 "github.com/docker/compose-cli/cli/server/protos/compose/v1"
|
|
||||||
containersv1 "github.com/docker/compose-cli/cli/server/protos/containers/v1"
|
containersv1 "github.com/docker/compose-cli/cli/server/protos/containers/v1"
|
||||||
contextsv1 "github.com/docker/compose-cli/cli/server/protos/contexts/v1"
|
contextsv1 "github.com/docker/compose-cli/cli/server/protos/contexts/v1"
|
||||||
streamsv1 "github.com/docker/compose-cli/cli/server/protos/streams/v1"
|
streamsv1 "github.com/docker/compose-cli/cli/server/protos/streams/v1"
|
||||||
|
@ -106,7 +105,6 @@ func setupServer() *grpc.Server {
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
s := New(ctx)
|
s := New(ctx)
|
||||||
p := proxy.New(ctx)
|
p := proxy.New(ctx)
|
||||||
composev1.RegisterComposeServer(s, p)
|
|
||||||
containersv1.RegisterContainersServer(s, p)
|
containersv1.RegisterContainersServer(s, p)
|
||||||
streamsv1.RegisterStreamingServer(s, p)
|
streamsv1.RegisterStreamingServer(s, p)
|
||||||
volumesv1.RegisterVolumesServer(s, p)
|
volumesv1.RegisterVolumesServer(s, p)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,81 +0,0 @@
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
syntax = "proto3";
|
|
||||||
|
|
||||||
package com.docker.api.protos.compose.v1;
|
|
||||||
|
|
||||||
option go_package = "github.com/docker/compose-cli/cli/server/protos/compose/v1;v1";
|
|
||||||
|
|
||||||
service Compose {
|
|
||||||
rpc Up(ComposeUpRequest) returns (ComposeUpResponse);
|
|
||||||
rpc Down(ComposeDownRequest) returns (ComposeDownResponse);
|
|
||||||
rpc Stacks(ComposeStacksRequest)returns (ComposeStacksResponse);
|
|
||||||
rpc Services(ComposeServicesRequest)returns (ComposeServicesResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
message ComposeUpRequest {
|
|
||||||
string projectName = 1;
|
|
||||||
string workDir = 2;
|
|
||||||
repeated string files = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ComposeUpResponse {
|
|
||||||
string projectName = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ComposeDownRequest {
|
|
||||||
string projectName = 1;
|
|
||||||
string workDir = 2;
|
|
||||||
repeated string files = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ComposeDownResponse {
|
|
||||||
string projectName = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ComposeStacksRequest {
|
|
||||||
string projectName = 1;
|
|
||||||
bool all = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ComposeStacksResponse {
|
|
||||||
repeated Stack stacks = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message Stack {
|
|
||||||
string id = 1;
|
|
||||||
string name = 2;
|
|
||||||
string status = 3;
|
|
||||||
string reason = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ComposeServicesRequest {
|
|
||||||
string projectName = 1;
|
|
||||||
string workDir = 2;
|
|
||||||
repeated string files = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ComposeServicesResponse {
|
|
||||||
repeated Service services = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message Service {
|
|
||||||
string id = 1;
|
|
||||||
string name = 2;
|
|
||||||
uint32 replicas = 3;
|
|
||||||
uint32 desired = 4;
|
|
||||||
repeated string Ports = 5;
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
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 v1
|
|
|
@ -1,102 +0,0 @@
|
||||||
/*
|
|
||||||
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/docker/compose-cli/api/compose"
|
|
||||||
|
|
||||||
"github.com/compose-spec/compose-go/cli"
|
|
||||||
"github.com/compose-spec/compose-go/types"
|
|
||||||
|
|
||||||
composev1 "github.com/docker/compose-cli/cli/server/protos/compose/v1"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (p *proxy) Up(ctx context.Context, request *composev1.ComposeUpRequest) (*composev1.ComposeUpResponse, error) {
|
|
||||||
project, err := getComposeProject(request.Files, request.WorkDir, request.ProjectName)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
err = Client(ctx).ComposeService().Up(ctx, project, compose.UpOptions{Detach: true})
|
|
||||||
return &composev1.ComposeUpResponse{ProjectName: project.Name}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *proxy) Down(ctx context.Context, request *composev1.ComposeDownRequest) (*composev1.ComposeDownResponse, error) {
|
|
||||||
projectName := request.GetProjectName()
|
|
||||||
if projectName == "" {
|
|
||||||
project, err := getComposeProject(request.Files, request.WorkDir, request.ProjectName)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
projectName = project.Name
|
|
||||||
}
|
|
||||||
err := Client(ctx).ComposeService().Down(ctx, projectName, compose.DownOptions{})
|
|
||||||
return &composev1.ComposeDownResponse{ProjectName: projectName}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *proxy) Services(ctx context.Context, request *composev1.ComposeServicesRequest) (*composev1.ComposeServicesResponse, error) {
|
|
||||||
projectName := request.GetProjectName()
|
|
||||||
if projectName == "" {
|
|
||||||
project, err := getComposeProject(request.Files, request.WorkDir, request.ProjectName)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
projectName = project.Name
|
|
||||||
}
|
|
||||||
response := []*composev1.Service{}
|
|
||||||
_, err := Client(ctx).ComposeService().Ps(ctx, projectName, compose.PsOptions{})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
/* FIXME need to create `docker service ls` command to re-introduce this feature
|
|
||||||
for _, service := range services {
|
|
||||||
response = append(response, &composev1.Service{
|
|
||||||
Id: service.ID,
|
|
||||||
ProjectName: service.ProjectName,
|
|
||||||
Replicas: uint32(service.Replicas),
|
|
||||||
Desired: uint32(service.Desired),
|
|
||||||
Ports: service.Ports,
|
|
||||||
})
|
|
||||||
}*/
|
|
||||||
return &composev1.ComposeServicesResponse{Services: response}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *proxy) Stacks(ctx context.Context, request *composev1.ComposeStacksRequest) (*composev1.ComposeStacksResponse, error) {
|
|
||||||
stacks, err := Client(ctx).ComposeService().List(ctx, compose.ListOptions{All: request.All})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
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.ComposeStacksResponse{Stacks: response}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
|
@ -22,7 +22,6 @@ import (
|
||||||
|
|
||||||
"github.com/docker/compose-cli/api/client"
|
"github.com/docker/compose-cli/api/client"
|
||||||
"github.com/docker/compose-cli/api/config"
|
"github.com/docker/compose-cli/api/config"
|
||||||
composev1 "github.com/docker/compose-cli/cli/server/protos/compose/v1"
|
|
||||||
containersv1 "github.com/docker/compose-cli/cli/server/protos/containers/v1"
|
containersv1 "github.com/docker/compose-cli/cli/server/protos/containers/v1"
|
||||||
contextsv1 "github.com/docker/compose-cli/cli/server/protos/contexts/v1"
|
contextsv1 "github.com/docker/compose-cli/cli/server/protos/contexts/v1"
|
||||||
streamsv1 "github.com/docker/compose-cli/cli/server/protos/streams/v1"
|
streamsv1 "github.com/docker/compose-cli/cli/server/protos/streams/v1"
|
||||||
|
@ -46,7 +45,6 @@ func Client(ctx context.Context) *client.Client {
|
||||||
// Proxy implements the gRPC server and forwards the actions
|
// Proxy implements the gRPC server and forwards the actions
|
||||||
// to the right backend
|
// to the right backend
|
||||||
type Proxy interface {
|
type Proxy interface {
|
||||||
composev1.ComposeServer
|
|
||||||
containersv1.ContainersServer
|
containersv1.ContainersServer
|
||||||
streamsv1.StreamingServer
|
streamsv1.StreamingServer
|
||||||
volumesv1.VolumesServer
|
volumesv1.VolumesServer
|
||||||
|
|
Loading…
Reference in New Issue