compose up and other compose commands running on “Moby” context type.

Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
Guillaume Tardif 2020-12-04 18:09:12 +01:00
parent 3190456101
commit ec5afcfd4d
12 changed files with 30 additions and 36 deletions

View file

@ -45,7 +45,7 @@ func buildCommand() *cobra.Command {
}
func runBuild(ctx context.Context, opts buildOptions, services []string) error {
c, err := client.New(ctx)
c, err := client.NewWithDefaultLocalBackend(ctx)
if err != nil {
return err
}

View file

@ -17,16 +17,12 @@
package compose
import (
"context"
"github.com/compose-spec/compose-go/cli"
"github.com/compose-spec/compose-go/types"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/docker/compose-cli/api/client"
"github.com/docker/compose-cli/context/store"
"github.com/docker/compose-cli/errdefs"
)
type composeOptions struct {
@ -76,9 +72,6 @@ func Command(contextType string) *cobra.Command {
command := &cobra.Command{
Short: "Docker Compose",
Use: "compose",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return checkComposeSupport(cmd.Context())
},
}
command.AddCommand(
@ -90,7 +83,7 @@ func Command(contextType string) *cobra.Command {
convertCommand(),
)
if contextType == store.LocalContextType {
if contextType == store.LocalContextType || contextType == store.DefaultContextType {
command.AddCommand(
buildCommand(),
pushCommand(),
@ -101,15 +94,6 @@ func Command(contextType string) *cobra.Command {
return command
}
func checkComposeSupport(ctx context.Context) error {
_, err := client.New(ctx)
if errdefs.IsNotFoundError(err) {
return errdefs.ErrNotImplemented
}
return err
}
//
func filter(project *types.Project, services []string) error {
if len(services) == 0 {

View file

@ -46,7 +46,7 @@ func convertCommand() *cobra.Command {
func runConvert(ctx context.Context, opts composeOptions) error {
var json []byte
c, err := client.New(ctx)
c, err := client.NewWithDefaultLocalBackend(ctx)
if err != nil {
return err
}

View file

@ -41,7 +41,7 @@ func downCommand() *cobra.Command {
}
func runDown(ctx context.Context, opts composeOptions) error {
c, err := client.New(ctx)
c, err := client.NewWithDefaultLocalBackend(ctx)
if err != nil {
return err
}

View file

@ -43,7 +43,7 @@ func listCommand() *cobra.Command {
}
func runList(ctx context.Context, opts composeOptions) error {
c, err := client.New(ctx)
c, err := client.NewWithDefaultLocalBackend(ctx)
if err != nil {
return err
}

View file

@ -41,7 +41,7 @@ func logsCommand() *cobra.Command {
}
func runLogs(ctx context.Context, opts composeOptions) error {
c, err := client.New(ctx)
c, err := client.NewWithDefaultLocalBackend(ctx)
if err != nil {
return err
}

View file

@ -45,7 +45,7 @@ func psCommand() *cobra.Command {
}
func runPs(ctx context.Context, opts composeOptions) error {
c, err := client.New(ctx)
c, err := client.NewWithDefaultLocalBackend(ctx)
if err != nil {
return err
}

View file

@ -46,7 +46,7 @@ func pullCommand() *cobra.Command {
}
func runPull(ctx context.Context, opts pullOptions, services []string) error {
c, err := client.New(ctx)
c, err := client.NewWithDefaultLocalBackend(ctx)
if err != nil {
return err
}

View file

@ -46,7 +46,7 @@ func pushCommand() *cobra.Command {
}
func runPush(ctx context.Context, opts pushOptions, services []string) error {
c, err := client.New(ctx)
c, err := client.NewWithDefaultLocalBackend(ctx)
if err != nil {
return err
}

View file

@ -38,7 +38,7 @@ func upCommand(contextType string) *cobra.Command {
Use: "up [SERVICE...]",
RunE: func(cmd *cobra.Command, args []string) error {
switch contextType {
case store.LocalContextType:
case store.LocalContextType, store.DefaultContextType:
return runCreateStart(cmd.Context(), opts, args)
default:
return runUp(cmd.Context(), opts, args)
@ -100,7 +100,7 @@ func runCreateStart(ctx context.Context, opts composeOptions, services []string)
}
func setup(ctx context.Context, opts composeOptions, services []string) (*client.Client, *types.Project, error) {
c, err := client.New(ctx)
c, err := client.NewWithDefaultLocalBackend(ctx)
if err != nil {
return nil, nil, err
}