mirror of https://github.com/docker/compose.git
Adjust commands to latest compose-go
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
6e6a11aa73
commit
cfbd963c3d
|
@ -19,7 +19,6 @@ package aci
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/docker/api/secrets"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
@ -42,6 +41,7 @@ import (
|
|||
"github.com/docker/api/context/cloud"
|
||||
"github.com/docker/api/context/store"
|
||||
"github.com/docker/api/errdefs"
|
||||
"github.com/docker/api/secrets"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -18,6 +18,7 @@ package compose
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/compose-spec/compose-go/cli"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -28,6 +29,21 @@ import (
|
|||
"github.com/docker/api/errdefs"
|
||||
)
|
||||
|
||||
type composeOptions struct {
|
||||
Name string
|
||||
WorkingDir string
|
||||
ConfigPaths []string
|
||||
Environment []string
|
||||
}
|
||||
|
||||
func (o *composeOptions) toProjectOptions() (*cli.ProjectOptions, error) {
|
||||
return cli.NewProjectOptions(o.ConfigPaths,
|
||||
cli.WithOsEnv,
|
||||
cli.WithEnv(o.Environment),
|
||||
cli.WithWorkingDirectory(o.WorkingDir),
|
||||
cli.WithName(o.Name))
|
||||
}
|
||||
|
||||
// Command returns the compose command with its child commands
|
||||
func Command() *cobra.Command {
|
||||
command := &cobra.Command{
|
||||
|
|
|
@ -20,18 +20,17 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/compose-spec/compose-go/cli"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/api/client"
|
||||
)
|
||||
|
||||
func downCommand() *cobra.Command {
|
||||
opts := cli.ProjectOptions{}
|
||||
opts := composeOptions{}
|
||||
downCmd := &cobra.Command{
|
||||
Use: "down",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runDown(cmd.Context(), &opts)
|
||||
return runDown(cmd.Context(), opts)
|
||||
},
|
||||
}
|
||||
downCmd.Flags().StringVarP(&opts.Name, "project-name", "p", "", "Project name")
|
||||
|
@ -41,7 +40,7 @@ func downCommand() *cobra.Command {
|
|||
return downCmd
|
||||
}
|
||||
|
||||
func runDown(ctx context.Context, opts *cli.ProjectOptions) error {
|
||||
func runDown(ctx context.Context, opts composeOptions) error {
|
||||
c, err := client.New(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -52,5 +51,9 @@ func runDown(ctx context.Context, opts *cli.ProjectOptions) error {
|
|||
return errors.New("compose not implemented in current context")
|
||||
}
|
||||
|
||||
return composeService.Down(ctx, opts)
|
||||
options, err := opts.toProjectOptions()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return composeService.Down(ctx, options)
|
||||
}
|
||||
|
|
|
@ -21,18 +21,17 @@ import (
|
|||
"errors"
|
||||
"os"
|
||||
|
||||
"github.com/compose-spec/compose-go/cli"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/api/client"
|
||||
)
|
||||
|
||||
func logsCommand() *cobra.Command {
|
||||
opts := cli.ProjectOptions{}
|
||||
opts := composeOptions{}
|
||||
logsCmd := &cobra.Command{
|
||||
Use: "logs",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runLogs(cmd.Context(), &opts)
|
||||
return runLogs(cmd.Context(), opts)
|
||||
},
|
||||
}
|
||||
logsCmd.Flags().StringVarP(&opts.Name, "project-name", "p", "", "Project name")
|
||||
|
@ -42,7 +41,7 @@ func logsCommand() *cobra.Command {
|
|||
return logsCmd
|
||||
}
|
||||
|
||||
func runLogs(ctx context.Context, opts *cli.ProjectOptions) error {
|
||||
func runLogs(ctx context.Context, opts composeOptions) error {
|
||||
c, err := client.New(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -53,5 +52,9 @@ func runLogs(ctx context.Context, opts *cli.ProjectOptions) error {
|
|||
return errors.New("compose not implemented in current context")
|
||||
}
|
||||
|
||||
return composeService.Logs(ctx, opts, os.Stdout)
|
||||
options, err := opts.toProjectOptions()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return composeService.Logs(ctx, options, os.Stdout)
|
||||
}
|
||||
|
|
|
@ -25,18 +25,17 @@ import (
|
|||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/compose-spec/compose-go/cli"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/api/client"
|
||||
)
|
||||
|
||||
func psCommand() *cobra.Command {
|
||||
opts := cli.ProjectOptions{}
|
||||
opts := composeOptions{}
|
||||
psCmd := &cobra.Command{
|
||||
Use: "ps",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runPs(cmd.Context(), &opts)
|
||||
return runPs(cmd.Context(), opts)
|
||||
},
|
||||
}
|
||||
psCmd.Flags().StringVarP(&opts.Name, "project-name", "p", "", "Project name")
|
||||
|
@ -46,7 +45,7 @@ func psCommand() *cobra.Command {
|
|||
return psCmd
|
||||
}
|
||||
|
||||
func runPs(ctx context.Context, opts *cli.ProjectOptions) error {
|
||||
func runPs(ctx context.Context, opts composeOptions) error {
|
||||
c, err := client.New(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -57,7 +56,11 @@ func runPs(ctx context.Context, opts *cli.ProjectOptions) error {
|
|||
return errors.New("compose not implemented in current context")
|
||||
}
|
||||
|
||||
serviceList, err := composeService.Ps(ctx, opts)
|
||||
options, err := opts.toProjectOptions()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
serviceList, err := composeService.Ps(ctx, options)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/compose-spec/compose-go/cli"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/api/client"
|
||||
|
@ -28,11 +27,11 @@ import (
|
|||
)
|
||||
|
||||
func upCommand() *cobra.Command {
|
||||
opts := cli.ProjectOptions{}
|
||||
opts := composeOptions{}
|
||||
upCmd := &cobra.Command{
|
||||
Use: "up",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runUp(cmd.Context(), &opts)
|
||||
return runUp(cmd.Context(), opts)
|
||||
},
|
||||
}
|
||||
upCmd.Flags().StringVarP(&opts.Name, "project-name", "p", "", "Project name")
|
||||
|
@ -44,7 +43,7 @@ func upCommand() *cobra.Command {
|
|||
return upCmd
|
||||
}
|
||||
|
||||
func runUp(ctx context.Context, opts *cli.ProjectOptions) error {
|
||||
func runUp(ctx context.Context, opts composeOptions) error {
|
||||
c, err := client.New(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -56,6 +55,10 @@ func runUp(ctx context.Context, opts *cli.ProjectOptions) error {
|
|||
}
|
||||
|
||||
return progress.Run(ctx, func(ctx context.Context) error {
|
||||
return composeService.Up(ctx, opts)
|
||||
options, err := opts.toProjectOptions()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return composeService.Up(ctx, options)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -69,16 +69,16 @@ func getEcsAPIService(ecsCtx store.EcsContext) (*ecsAPIService, error) {
|
|||
}
|
||||
|
||||
return &ecsAPIService{
|
||||
ctx: ecsCtx,
|
||||
ctx: ecsCtx,
|
||||
Region: ecsCtx.Region,
|
||||
SDK: NewSDK(sess),
|
||||
SDK: NewSDK(sess),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type ecsAPIService struct {
|
||||
ctx store.EcsContext
|
||||
ctx store.EcsContext
|
||||
Region string
|
||||
SDK sdk
|
||||
SDK sdk
|
||||
}
|
||||
|
||||
func (a *ecsAPIService) ContainerService() containers.Service {
|
||||
|
|
|
@ -31,6 +31,7 @@ import (
|
|||
"github.com/docker/api/containers"
|
||||
"github.com/docker/api/context/cloud"
|
||||
"github.com/docker/api/errdefs"
|
||||
"github.com/docker/api/secrets"
|
||||
)
|
||||
|
||||
type apiService struct {
|
||||
|
|
Loading…
Reference in New Issue