diff --git a/cli/cmd/compose/compose.go b/cli/cmd/compose/compose.go index 90a185560..83c89cde2 100644 --- a/cli/cmd/compose/compose.go +++ b/cli/cmd/compose/compose.go @@ -23,7 +23,7 @@ import ( "github.com/spf13/cobra" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/errdefs" ) diff --git a/cli/cmd/compose/convert.go b/cli/cmd/compose/convert.go index 10e577f4b..7a0360c60 100644 --- a/cli/cmd/compose/convert.go +++ b/cli/cmd/compose/convert.go @@ -23,7 +23,7 @@ import ( "github.com/compose-spec/compose-go/cli" "github.com/spf13/cobra" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" ) func convertCommand() *cobra.Command { diff --git a/cli/cmd/compose/down.go b/cli/cmd/compose/down.go index a49d003d8..44281fa30 100644 --- a/cli/cmd/compose/down.go +++ b/cli/cmd/compose/down.go @@ -21,7 +21,7 @@ import ( "github.com/spf13/cobra" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/progress" ) diff --git a/cli/cmd/compose/list.go b/cli/cmd/compose/list.go index ba71db247..03346f59f 100644 --- a/cli/cmd/compose/list.go +++ b/cli/cmd/compose/list.go @@ -24,7 +24,7 @@ import ( "github.com/spf13/cobra" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" ) func listCommand() *cobra.Command { diff --git a/cli/cmd/compose/logs.go b/cli/cmd/compose/logs.go index de86e223f..e8e83ceef 100644 --- a/cli/cmd/compose/logs.go +++ b/cli/cmd/compose/logs.go @@ -22,7 +22,7 @@ import ( "github.com/spf13/cobra" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" ) func logsCommand() *cobra.Command { diff --git a/cli/cmd/compose/ps.go b/cli/cmd/compose/ps.go index e52f80499..038f03123 100644 --- a/cli/cmd/compose/ps.go +++ b/cli/cmd/compose/ps.go @@ -26,7 +26,7 @@ import ( "github.com/spf13/cobra" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" ) func psCommand() *cobra.Command { diff --git a/cli/cmd/compose/up.go b/cli/cmd/compose/up.go index f4f70da23..b1914128f 100644 --- a/cli/cmd/compose/up.go +++ b/cli/cmd/compose/up.go @@ -23,7 +23,7 @@ import ( "github.com/spf13/cobra" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/progress" ) diff --git a/cli/cmd/context/create_aci.go b/cli/cmd/context/create_aci.go index 32ebb3e9c..ac07f8e4c 100644 --- a/cli/cmd/context/create_aci.go +++ b/cli/cmd/context/create_aci.go @@ -23,7 +23,7 @@ import ( "github.com/spf13/cobra" "github.com/docker/compose-cli/aci" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/context/store" "github.com/docker/compose-cli/errdefs" ) diff --git a/cli/cmd/context/create_ecs.go b/cli/cmd/context/create_ecs.go index 979b881c0..78fb62663 100644 --- a/cli/cmd/context/create_ecs.go +++ b/cli/cmd/context/create_ecs.go @@ -22,7 +22,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/context/store" "github.com/docker/compose-cli/ecs" "github.com/docker/compose-cli/errdefs" diff --git a/cli/cmd/exec.go b/cli/cmd/exec.go index 736c2552c..7d09f2dd7 100644 --- a/cli/cmd/exec.go +++ b/cli/cmd/exec.go @@ -26,8 +26,8 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/client" ) type execOpts struct { diff --git a/cli/cmd/inspect.go b/cli/cmd/inspect.go index 6eac9fb3b..7ffe50da6 100644 --- a/cli/cmd/inspect.go +++ b/cli/cmd/inspect.go @@ -23,7 +23,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/formatter" ) diff --git a/cli/cmd/kill.go b/cli/cmd/kill.go index 08c2c4f17..1eff1aabb 100644 --- a/cli/cmd/kill.go +++ b/cli/cmd/kill.go @@ -25,7 +25,7 @@ import ( "github.com/hashicorp/go-multierror" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/errdefs" ) diff --git a/cli/cmd/login/login.go b/cli/cmd/login/login.go index 90413ba70..11ca6eeb2 100644 --- a/cli/cmd/login/login.go +++ b/cli/cmd/login/login.go @@ -26,8 +26,8 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/cli/mobycli" - "github.com/docker/compose-cli/client" "github.com/docker/compose-cli/errdefs" ) diff --git a/cli/cmd/logout/azure.go b/cli/cmd/logout/azure.go index 6f7ee0b96..44d305c94 100644 --- a/cli/cmd/logout/azure.go +++ b/cli/cmd/logout/azure.go @@ -23,7 +23,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/errdefs" ) diff --git a/cli/cmd/logs.go b/cli/cmd/logs.go index 4c152f496..dc478f4ee 100644 --- a/cli/cmd/logs.go +++ b/cli/cmd/logs.go @@ -25,8 +25,8 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/client" ) type logsOpts struct { diff --git a/cli/cmd/ps.go b/cli/cmd/ps.go index 400fd1358..b918b6cd2 100644 --- a/cli/cmd/ps.go +++ b/cli/cmd/ps.go @@ -28,7 +28,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" formatter2 "github.com/docker/compose-cli/formatter" ) diff --git a/cli/cmd/rm.go b/cli/cmd/rm.go index 8f2cc00b0..f61f86dda 100644 --- a/cli/cmd/rm.go +++ b/cli/cmd/rm.go @@ -25,8 +25,8 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/client" "github.com/docker/compose-cli/errdefs" ) diff --git a/cli/cmd/run/run.go b/cli/cmd/run/run.go index 1e2ee1642..a4283eba9 100644 --- a/cli/cmd/run/run.go +++ b/cli/cmd/run/run.go @@ -27,8 +27,8 @@ import ( "github.com/docker/compose-cli/api/containers" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/cli/options/run" - "github.com/docker/compose-cli/client" "github.com/docker/compose-cli/progress" ) diff --git a/cli/cmd/secrets.go b/cli/cmd/secrets.go index 9c569907f..539fef93e 100644 --- a/cli/cmd/secrets.go +++ b/cli/cmd/secrets.go @@ -25,8 +25,8 @@ import ( "github.com/spf13/cobra" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/secrets" - "github.com/docker/compose-cli/client" ) type createSecretOptions struct { diff --git a/cli/cmd/start.go b/cli/cmd/start.go index cb27abf5f..f65dd1d54 100644 --- a/cli/cmd/start.go +++ b/cli/cmd/start.go @@ -27,7 +27,7 @@ import ( "github.com/hashicorp/go-multierror" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" ) // StartCommand starts containers diff --git a/cli/cmd/stop.go b/cli/cmd/stop.go index e0003fd90..cbfeb3856 100644 --- a/cli/cmd/stop.go +++ b/cli/cmd/stop.go @@ -27,7 +27,7 @@ import ( "github.com/hashicorp/go-multierror" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" ) type stopOpts struct { diff --git a/client/client.go b/client/client.go deleted file mode 100644 index a6e19bf22..000000000 --- a/client/client.go +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright 2020 Docker, Inc. - - 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 client - -import ( - "context" - - "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/api/secrets" - "github.com/docker/compose-cli/backend" - apicontext "github.com/docker/compose-cli/context" - "github.com/docker/compose-cli/context/cloud" - "github.com/docker/compose-cli/context/store" -) - -// New returns a backend client associated with current context -func New(ctx context.Context) (*Client, error) { - currentContext := apicontext.CurrentContext(ctx) - s := store.ContextStore(ctx) - - cc, err := s.Get(currentContext) - if err != nil { - return nil, err - } - - service, err := backend.Get(ctx, cc.Type()) - if err != nil { - return nil, err - } - - return &Client{ - backendType: cc.Type(), - bs: service, - }, nil -} - -// GetCloudService returns a backend CloudService (typically login, create context) -func GetCloudService(ctx context.Context, backendType string) (cloud.Service, error) { - return backend.GetCloudService(ctx, backendType) -} - -// Client is a multi-backend client -type Client struct { - backendType string - bs backend.Service -} - -// ContainerService returns the backend service for the current context -func (c *Client) ContainerService() containers.Service { - if cs := c.bs.ContainerService(); cs != nil { - return cs - } - - return &containerService{} -} - -// ComposeService returns the backend service for the current context -func (c *Client) ComposeService() compose.Service { - if cs := c.bs.ComposeService(); cs != nil { - return cs - } - - return &composeService{} -} - -// SecretsService returns the backend service for the current context -func (c *Client) SecretsService() secrets.Service { - if ss := c.bs.SecretsService(); ss != nil { - return ss - } - - return &secretsService{} -} diff --git a/client/compose.go b/client/compose.go deleted file mode 100644 index 91387f24a..000000000 --- a/client/compose.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright 2020 Docker, Inc. - - 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 client - -import ( - "context" - "io" - - "github.com/compose-spec/compose-go/types" - - "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/errdefs" -) - -type composeService struct { -} - -// Up executes the equivalent to a `compose up` -func (c *composeService) Up(context.Context, *types.Project) error { - return errdefs.ErrNotImplemented -} - -// Down executes the equivalent to a `compose down` -func (c *composeService) Down(context.Context, string) error { - return errdefs.ErrNotImplemented -} - -// Logs executes the equivalent to a `compose logs` -func (c *composeService) Logs(context.Context, string, io.Writer) error { - return errdefs.ErrNotImplemented -} - -// Ps executes the equivalent to a `compose ps` -func (c *composeService) Ps(context.Context, string) ([]compose.ServiceStatus, error) { - return nil, errdefs.ErrNotImplemented -} - -// List executes the equivalent to a `docker stack ls` -func (c *composeService) List(context.Context, string) ([]compose.Stack, error) { - return nil, errdefs.ErrNotImplemented -} - -// Convert translate compose model into backend's native format -func (c *composeService) Convert(context.Context, *types.Project) ([]byte, error) { - return nil, errdefs.ErrNotImplemented -} diff --git a/client/containers.go b/client/containers.go deleted file mode 100644 index 41639f382..000000000 --- a/client/containers.go +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright 2020 Docker, Inc. - - 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 client - -import ( - "context" - - "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/errdefs" -) - -type containerService struct { -} - -// List returns all the containers -func (c *containerService) List(context.Context, bool) ([]containers.Container, error) { - return nil, errdefs.ErrNotImplemented -} - -// Start starts a stopped container -func (c *containerService) Start(context.Context, string) error { - return errdefs.ErrNotImplemented -} - -// Stop stops the running container -func (c *containerService) Stop(context.Context, string, *uint32) error { - return errdefs.ErrNotImplemented -} - -func (c *containerService) Kill(ctx context.Context, containerID string, signal string) error { - return errdefs.ErrNotImplemented -} - -// Run creates and starts a container -func (c *containerService) Run(context.Context, containers.ContainerConfig) error { - return errdefs.ErrNotImplemented -} - -// Exec executes a command inside a running container -func (c *containerService) Exec(context.Context, string, containers.ExecRequest) error { - return errdefs.ErrNotImplemented -} - -// Logs returns all the logs of a container -func (c *containerService) Logs(context.Context, string, containers.LogsRequest) error { - return errdefs.ErrNotImplemented -} - -// Delete removes containers -func (c *containerService) Delete(context.Context, string, containers.DeleteRequest) error { - return errdefs.ErrNotImplemented -} - -// Inspect get a specific container -func (c *containerService) Inspect(context.Context, string) (containers.Container, error) { - return containers.Container{}, errdefs.ErrNotImplemented -} diff --git a/client/secrets.go b/client/secrets.go deleted file mode 100644 index 24a754b11..000000000 --- a/client/secrets.go +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright 2020 Docker, Inc. - - 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 client - -import ( - "context" - - "github.com/docker/compose-cli/api/secrets" - "github.com/docker/compose-cli/errdefs" -) - -type secretsService struct { -} - -func (s *secretsService) CreateSecret(context.Context, secrets.Secret) (string, error) { - return "", errdefs.ErrNotImplemented -} - -func (s *secretsService) InspectSecret(context.Context, string) (secrets.Secret, error) { - return secrets.Secret{}, errdefs.ErrNotImplemented -} - -func (s *secretsService) ListSecrets(context.Context) ([]secrets.Secret, error) { - return nil, errdefs.ErrNotImplemented -} - -func (s *secretsService) DeleteSecret(context.Context, string, bool) error { - return errdefs.ErrNotImplemented -} diff --git a/server/interceptor.go b/server/interceptor.go index ea3f3f8d1..aa6a8043d 100644 --- a/server/interceptor.go +++ b/server/interceptor.go @@ -24,7 +24,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/metadata" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/config" apicontext "github.com/docker/compose-cli/context" "github.com/docker/compose-cli/context/store" diff --git a/server/proxy/proxy.go b/server/proxy/proxy.go index cac286739..4029f37c1 100644 --- a/server/proxy/proxy.go +++ b/server/proxy/proxy.go @@ -20,7 +20,7 @@ import ( "context" "sync" - "github.com/docker/compose-cli/client" + "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/config" containersv1 "github.com/docker/compose-cli/protos/containers/v1" contextsv1 "github.com/docker/compose-cli/protos/contexts/v1"