Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion aci/login/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ import (
"github.com/docker/compose-cli/pkg/api"
)

// UserAgentName is the default user agent used by the cli
const UserAgentName = "docker-cli"

// NewContainerGroupsClient get client toi manipulate containerGrouos
func NewContainerGroupsClient(subscriptionID string) (containerinstance.ContainerGroupsClient, error) {
authorizer, mgmtURL, err := getClientSetupData()
Expand All @@ -52,7 +55,7 @@ func NewContainerGroupsClient(subscriptionID string) (containerinstance.Containe
}

func setupClient(aciClient *autorest.Client, auth autorest.Authorizer) {
aciClient.UserAgent = internal.UserAgentName + "/" + internal.Version
aciClient.UserAgent = UserAgentName + "/" + internal.Version
aciClient.Authorizer = auth
}

Expand Down
15 changes: 8 additions & 7 deletions cli/cmd/context/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import (
"sort"
"strings"

formatter2 "github.com/docker/compose-cli/cmd/formatter"

"github.com/pkg/errors"
"github.com/spf13/cobra"

apicontext "github.com/docker/compose-cli/api/context"
"github.com/docker/compose-cli/api/context/store"
"github.com/docker/compose-cli/cli/formatter"
"github.com/docker/compose-cli/cli/mobycli"
)

Expand Down Expand Up @@ -68,7 +69,7 @@ func runList(cmd *cobra.Command, opts lsOpts) error {
return err
}
format := strings.ToLower(strings.ReplaceAll(opts.format, " ", ""))
if format != "" && format != formatter.JSON && format != formatter.PRETTY && format != formatter.TemplateLegacyJSON {
if format != "" && format != formatter2.JSON && format != formatter2.PRETTY && format != formatter2.TemplateLegacyJSON {
mobycli.Exec(cmd.Root())
return nil
}
Expand All @@ -91,15 +92,15 @@ func runList(cmd *cobra.Command, opts lsOpts) error {
return nil
}

if opts.json || format == formatter.JSON {
opts.format = formatter.JSON
if opts.json || format == formatter2.JSON {
opts.format = formatter2.JSON
}
if format == formatter.TemplateLegacyJSON {
opts.format = formatter.TemplateLegacyJSON
if format == formatter2.TemplateLegacyJSON {
opts.format = formatter2.TemplateLegacyJSON
}

view := viewFromContextList(contexts, currentContext)
return formatter.Print(view, opts.format, os.Stdout,
return formatter2.Print(view, opts.format, os.Stdout,
func(w io.Writer) {
for _, c := range view {
contextName := c.Name
Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/context/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import (
"errors"
"fmt"

"github.com/docker/compose-cli/cmd/formatter"

"github.com/hashicorp/go-multierror"
"github.com/spf13/cobra"

apicontext "github.com/docker/compose-cli/api/context"
"github.com/docker/compose-cli/api/context/store"
"github.com/docker/compose-cli/cli/formatter"
)

type removeOpts struct {
Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import (
"context"
"fmt"

"github.com/docker/compose-cli/cmd/formatter"

"github.com/Azure/go-autorest/autorest/to"
"github.com/compose-spec/compose-go/types"
"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/cli/formatter"
)

// InspectCommand inspects into containers
Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import (
"context"
"fmt"

"github.com/docker/compose-cli/cmd/formatter"

"github.com/hashicorp/go-multierror"
"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/docker/compose-cli/api/client"
"github.com/docker/compose-cli/cli/formatter"
"github.com/docker/compose-cli/pkg/api"
)

Expand Down
7 changes: 4 additions & 3 deletions cli/cmd/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import (
"os"
"strings"

formatter3 "github.com/docker/compose-cli/cmd/formatter"

"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/docker/compose-cli/api/client"
"github.com/docker/compose-cli/api/containers"
formatter2 "github.com/docker/compose-cli/cli/formatter"
"github.com/docker/compose-cli/utils/formatter"
)

Expand Down Expand Up @@ -89,11 +90,11 @@ func runPs(ctx context.Context, opts psOpts) error {
}

if opts.json {
opts.format = formatter2.JSON
opts.format = formatter3.JSON
}

view := viewFromContainerList(containerList)
return formatter2.Print(view, opts.format, os.Stdout, func(w io.Writer) {
return formatter3.Print(view, opts.format, os.Stdout, func(w io.Writer) {
for _, c := range view {
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", c.ID, c.Image, c.Command, c.Status,
strings.Join(c.Ports, ", "))
Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ import (
"context"
"fmt"

"github.com/docker/compose-cli/cmd/formatter"

"github.com/hashicorp/go-multierror"
"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/cli/formatter"
"github.com/docker/compose-cli/pkg/api"
)

Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ import (
"io/ioutil"
"os"

"github.com/docker/compose-cli/cmd/formatter"

"github.com/spf13/cobra"

"github.com/docker/compose-cli/api/client"
"github.com/docker/compose-cli/api/secrets"
"github.com/docker/compose-cli/cli/formatter"
)

// SecretCommand manage secrets
Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import (
"context"
"fmt"

"github.com/docker/compose-cli/cmd/formatter"

"github.com/hashicorp/go-multierror"
"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/docker/compose-cli/api/client"
"github.com/docker/compose-cli/cli/formatter"
"github.com/docker/compose-cli/pkg/api"
)

Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import (
"context"
"fmt"

"github.com/docker/compose-cli/cmd/formatter"

"github.com/hashicorp/go-multierror"
"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/docker/compose-cli/api/client"
"github.com/docker/compose-cli/cli/formatter"
"github.com/docker/compose-cli/pkg/api"
)

Expand Down
4 changes: 3 additions & 1 deletion cli/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ import (
"os"
"strings"

"github.com/docker/compose-cli/cmd/formatter"

"github.com/spf13/cobra"

"github.com/docker/cli/cli"
"github.com/docker/compose-cli/cli/formatter"

"github.com/docker/compose-cli/cli/mobycli"
"github.com/docker/compose-cli/internal"
)
Expand Down
6 changes: 3 additions & 3 deletions cli/cmd/volume/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (
"context"
"fmt"

format "github.com/docker/compose-cli/cmd/formatter"

"github.com/docker/compose-cli/aci"
"github.com/docker/compose-cli/api/client"
"github.com/docker/compose-cli/api/context/store"
"github.com/docker/compose-cli/cli/formatter"
format "github.com/docker/compose-cli/cli/formatter"
"github.com/docker/compose-cli/ecs"
"github.com/docker/compose-cli/pkg/progress"

Expand Down Expand Up @@ -125,7 +125,7 @@ func rmVolume() *cobra.Command {
}
fmt.Println(id)
}
formatter.SetMultiErrorFormat(errs)
format.SetMultiErrorFormat(errs)
return errs.ErrorOrNil()
},
}
Expand Down
7 changes: 4 additions & 3 deletions cli/cmd/volume/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import (
"io"
"os"

formatter2 "github.com/docker/compose-cli/cmd/formatter"

"github.com/spf13/cobra"

"github.com/docker/compose-cli/api/client"
"github.com/docker/compose-cli/api/volumes"
"github.com/docker/compose-cli/cli/formatter"
)

type listVolumeOpts struct {
Expand Down Expand Up @@ -55,14 +56,14 @@ func listVolume() *cobra.Command {
return nil
}
view := viewFromVolumeList(vols)
return formatter.Print(view, opts.format, os.Stdout, func(w io.Writer) {
return formatter2.Print(view, opts.format, os.Stdout, func(w io.Writer) {
for _, vol := range view {
_, _ = fmt.Fprintf(w, "%s\t%s\n", vol.ID, vol.Description)
}
}, "ID", "DESCRIPTION")
},
}
cmd.Flags().StringVar(&opts.format, "format", formatter.PRETTY, "Format the output. Values: [pretty | json]. (Default: pretty)")
cmd.Flags().StringVar(&opts.format, "format", formatter2.PRETTY, "Format the output. Values: [pretty | json]. (Default: pretty)")
cmd.Flags().BoolVarP(&opts.quiet, "quiet", "q", false, "Only display IDs")
return cmd
}
Expand Down
2 changes: 1 addition & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func main() {

// On default context, "compose" is implemented by CLI Plugin
proxy := api.NewServiceProxy().WithService(service.ComposeService())
command := compose2.RootCommand(ctype, proxy)
command := compose2.RootCommand(proxy)

if ctype == store.AciContextType {
customizeCliForACI(command, proxy)
Expand Down
29 changes: 10 additions & 19 deletions cmd/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"strings"
"syscall"

"github.com/docker/compose-cli/cmd/formatter"

"github.com/sirupsen/logrus"

"github.com/compose-spec/compose-go/cli"
Expand All @@ -35,8 +37,6 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/docker/compose-cli/api/context/store"
"github.com/docker/compose-cli/cli/formatter"
"github.com/docker/compose-cli/pkg/api"
"github.com/docker/compose-cli/pkg/compose"
)
Expand Down Expand Up @@ -198,7 +198,7 @@ func (o *projectOptions) toProjectOptions(po ...cli.ProjectOptionsFn) (*cli.Proj
}

// RootCommand returns the compose command with its child commands
func RootCommand(contextType string, backend api.Service) *cobra.Command {
func RootCommand(backend api.Service) *cobra.Command {
opts := projectOptions{}
var (
ansi string
Expand Down Expand Up @@ -247,10 +247,6 @@ func RootCommand(contextType string, backend api.Service) *cobra.Command {
opts.ProjectDir = opts.WorkDir
fmt.Fprint(os.Stderr, aec.Apply("option '--workdir' is DEPRECATED at root level! Please use '--project-directory' instead.\n", aec.RedF))
}
if contextType == store.DefaultContextType || contextType == store.LocalContextType {
Warning = "The new 'docker compose' command is currently experimental. " +
"To provide feedback or request new features please open issues at https://github.com/docker/compose-cli"
}
return nil
},
}
Expand All @@ -262,8 +258,8 @@ func RootCommand(contextType string, backend api.Service) *cobra.Command {
restartCommand(&opts, backend),
stopCommand(&opts, backend),
psCommand(&opts, backend),
listCommand(contextType, backend),
logsCommand(&opts, contextType, backend),
listCommand(backend),
logsCommand(&opts, backend),
convertCommand(&opts, backend),
killCommand(&opts, backend),
runCommand(&opts, backend),
Expand All @@ -276,17 +272,12 @@ func RootCommand(contextType string, backend api.Service) *cobra.Command {
portCommand(&opts, backend),
imagesCommand(&opts, backend),
versionCommand(),
buildCommand(&opts, backend),
pushCommand(&opts, backend),
pullCommand(&opts, backend),
createCommand(&opts, backend),
copyCommand(&opts, backend),
)

if contextType == store.LocalContextType || contextType == store.DefaultContextType {
command.AddCommand(
buildCommand(&opts, backend),
pushCommand(&opts, backend),
pullCommand(&opts, backend),
createCommand(&opts, backend),
copyCommand(&opts, backend),
)
}
command.Flags().SetInterspersed(false)
opts.addProjectFlags(command.Flags())
command.Flags().StringVar(&ansi, "ansi", "auto", `Control when to print ANSI control characters ("never"|"always"|"auto")`)
Expand Down
5 changes: 3 additions & 2 deletions cmd/compose/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import (
"sort"
"strings"

formatter2 "github.com/docker/compose-cli/cmd/formatter"

"github.com/docker/docker/pkg/stringid"
"github.com/docker/go-units"
"github.com/spf13/cobra"

"github.com/docker/compose-cli/cli/formatter"
"github.com/docker/compose-cli/pkg/api"
"github.com/docker/compose-cli/pkg/utils"
)
Expand Down Expand Up @@ -88,7 +89,7 @@ func runImages(ctx context.Context, backend api.Service, opts imageOptions, serv
return images[i].ContainerName < images[j].ContainerName
})

return formatter.Print(images, formatter.PRETTY, os.Stdout,
return formatter2.Print(images, formatter2.PRETTY, os.Stdout,
func(w io.Writer) {
for _, img := range images {
id := stringid.TruncateID(img.ID)
Expand Down
Loading