Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 49e7f2d

Browse files
committed
Move compose v2 implementation under pkg/compose with dependencies
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent e2ea24c commit 49e7f2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+260
-330
lines changed

aci/aci.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ import (
3939
"github.com/docker/compose-cli/api/client"
4040
"github.com/docker/compose-cli/api/containers"
4141
"github.com/docker/compose-cli/api/context/store"
42-
"github.com/docker/compose-cli/api/progress"
4342
"github.com/docker/compose-cli/pkg/api"
43+
"github.com/docker/compose-cli/pkg/progress"
4444
)
4545

4646
func createACIContainers(ctx context.Context, aciContext store.AciContext, groupDefinition containerinstance.ContainerGroup) error {

aci/compose.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import (
2828
"github.com/docker/compose-cli/aci/convert"
2929
"github.com/docker/compose-cli/aci/login"
3030
"github.com/docker/compose-cli/api/context/store"
31-
"github.com/docker/compose-cli/api/progress"
3231
"github.com/docker/compose-cli/pkg/api"
32+
"github.com/docker/compose-cli/pkg/progress"
3333
"github.com/docker/compose-cli/utils/formatter"
3434
)
3535

aci/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
"github.com/docker/compose-cli/api/context/store"
3131
"github.com/docker/compose-cli/pkg/api"
32-
"github.com/docker/compose-cli/utils/prompt"
32+
"github.com/docker/compose-cli/pkg/prompt"
3333
)
3434

3535
// ContextParams options for creating ACI context

aci/volumes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ import (
3030

3131
"github.com/docker/compose-cli/aci/login"
3232
"github.com/docker/compose-cli/api/context/store"
33-
"github.com/docker/compose-cli/api/progress"
3433
"github.com/docker/compose-cli/api/volumes"
3534
"github.com/docker/compose-cli/pkg/api"
35+
"github.com/docker/compose-cli/pkg/progress"
3636
)
3737

3838
type aciVolumeService struct {

cli/cmd/run/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import (
2929
"github.com/docker/compose-cli/api/client"
3030
"github.com/docker/compose-cli/api/containers"
3131
"github.com/docker/compose-cli/api/context/store"
32-
"github.com/docker/compose-cli/api/progress"
3332
"github.com/docker/compose-cli/cli/options/run"
33+
"github.com/docker/compose-cli/pkg/progress"
3434
)
3535

3636
// Command runs a container

cli/cmd/volume/command.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import (
2323
"github.com/docker/compose-cli/aci"
2424
"github.com/docker/compose-cli/api/client"
2525
"github.com/docker/compose-cli/api/context/store"
26-
"github.com/docker/compose-cli/api/progress"
2726
"github.com/docker/compose-cli/cli/formatter"
28-
formatter2 "github.com/docker/compose-cli/cli/formatter"
27+
format "github.com/docker/compose-cli/cli/formatter"
2928
"github.com/docker/compose-cli/ecs"
29+
"github.com/docker/compose-cli/pkg/progress"
3030

3131
"github.com/hashicorp/go-multierror"
3232
"github.com/spf13/cobra"
@@ -146,7 +146,7 @@ func inspectVolume() *cobra.Command {
146146
if err != nil {
147147
return err
148148
}
149-
outJSON, err := formatter2.ToStandardJSON(v)
149+
outJSON, err := format.ToStandardJSON(v)
150150
if err != nil {
151151
return err
152152
}

cli/main.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import (
5151
compose2 "github.com/docker/compose-cli/cmd/compose"
5252
"github.com/docker/compose-cli/local"
5353
"github.com/docker/compose-cli/pkg/api"
54+
"github.com/docker/compose-cli/pkg/compose"
5455

5556
// Backend registrations
5657
_ "github.com/docker/compose-cli/aci"
@@ -237,7 +238,7 @@ func main() {
237238
if err = root.ExecuteContext(ctx); err != nil {
238239
handleError(ctx, err, ctype, currentContext, cc, root)
239240
}
240-
metrics.Track(ctype, os.Args[1:], metrics.SuccessStatus)
241+
metrics.Track(ctype, os.Args[1:], compose.SuccessStatus)
241242
}
242243

243244
func customizeCliForACI(command *cobra.Command, proxy *api.ServiceProxy) {
@@ -271,7 +272,7 @@ func getBackend(ctype string, configDir string, opts cliopts.GlobalOpts) (backen
271272
func handleError(ctx context.Context, err error, ctype string, currentContext string, cc *store.DockerContext, root *cobra.Command) {
272273
// if user canceled request, simply exit without any error message
273274
if api.IsErrCanceled(err) || errors.Is(ctx.Err(), context.Canceled) {
274-
metrics.Track(ctype, os.Args[1:], metrics.CanceledStatus)
275+
metrics.Track(ctype, os.Args[1:], compose.CanceledStatus)
275276
os.Exit(130)
276277
}
277278
if ctype == store.AwsContextType {
@@ -293,20 +294,20 @@ $ docker context create %s <name>`, cc.Type(), store.EcsContextType), ctype)
293294

294295
func exit(ctx string, err error, ctype string) {
295296
if exit, ok := err.(cli.StatusError); ok {
296-
metrics.Track(ctype, os.Args[1:], metrics.SuccessStatus)
297+
metrics.Track(ctype, os.Args[1:], compose.SuccessStatus)
297298
os.Exit(exit.StatusCode)
298299
}
299300

300-
var composeErr metrics.ComposeError
301-
metricsStatus := metrics.FailureStatus
301+
var composeErr compose.Error
302+
metricsStatus := compose.FailureStatus
302303
exitCode := 1
303304
if errors.As(err, &composeErr) {
304305
metricsStatus = composeErr.GetMetricsFailureCategory().MetricsStatus
305306
exitCode = composeErr.GetMetricsFailureCategory().ExitCode
306307
}
307308
if strings.HasPrefix(err.Error(), "unknown shorthand flag:") || strings.HasPrefix(err.Error(), "unknown flag:") || strings.HasPrefix(err.Error(), "unknown docker command:") {
308-
metricsStatus = metrics.CommandSyntaxFailure.MetricsStatus
309-
exitCode = metrics.CommandSyntaxFailure.ExitCode
309+
metricsStatus = compose.CommandSyntaxFailure.MetricsStatus
310+
exitCode = compose.CommandSyntaxFailure.ExitCode
310311
}
311312
metrics.Track(ctype, os.Args[1:], metricsStatus)
312313

@@ -343,7 +344,7 @@ func checkIfUnknownCommandExistInDefaultContext(err error, currentContext string
343344

344345
if mobycli.IsDefaultContextCommand(dockerCommand) {
345346
fmt.Fprintf(os.Stderr, "Command %q not available in current context (%s), you can use the \"default\" context to run this command\n", dockerCommand, currentContext)
346-
metrics.Track(contextType, os.Args[1:], metrics.FailureStatus)
347+
metrics.Track(contextType, os.Args[1:], compose.FailureStatus)
347348
os.Exit(1)
348349
}
349350
}

cli/metrics/generatecommands/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"os/exec"
2222
"strings"
2323

24-
"github.com/docker/compose-cli/utils"
24+
"github.com/docker/compose-cli/pkg/utils"
2525
)
2626

2727
var managementCommands = []string{"ecs", "scan"}

cli/metrics/metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"os"
2121
"strings"
2222

23-
"github.com/docker/compose-cli/utils"
23+
"github.com/docker/compose-cli/pkg/utils"
2424
)
2525

2626
// Track sends the tracking analytics to Docker Desktop

cli/mobycli/exec.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ import (
2424
"os/signal"
2525
"regexp"
2626

27-
"github.com/spf13/cobra"
28-
2927
apicontext "github.com/docker/compose-cli/api/context"
3028
"github.com/docker/compose-cli/api/context/store"
3129
"github.com/docker/compose-cli/cli/metrics"
3230
"github.com/docker/compose-cli/cli/mobycli/resolvepath"
33-
"github.com/docker/compose-cli/utils"
31+
"github.com/spf13/cobra"
32+
33+
"github.com/docker/compose-cli/pkg/compose"
34+
"github.com/docker/compose-cli/pkg/utils"
3435
)
3536

3637
var delegatedContextTypes = []string{store.DefaultContextType}
@@ -68,18 +69,18 @@ func Exec(root *cobra.Command) {
6869
if err != nil {
6970
if exiterr, ok := err.(*exec.ExitError); ok {
7071
exitCode := exiterr.ExitCode()
71-
metrics.Track(store.DefaultContextType, os.Args[1:], metrics.ByExitCode(exitCode).MetricsStatus)
72+
metrics.Track(store.DefaultContextType, os.Args[1:], compose.ByExitCode(exitCode).MetricsStatus)
7273
os.Exit(exitCode)
7374
}
74-
metrics.Track(store.DefaultContextType, os.Args[1:], metrics.FailureStatus)
75+
metrics.Track(store.DefaultContextType, os.Args[1:], compose.FailureStatus)
7576
fmt.Fprintln(os.Stderr, err)
7677
os.Exit(1)
7778
}
7879
command := metrics.GetCommand(os.Args[1:])
7980
if command == "build" && !metrics.HasQuietFlag(os.Args[1:]) {
8081
utils.DisplayScanSuggestMsg()
8182
}
82-
metrics.Track(store.DefaultContextType, os.Args[1:], metrics.SuccessStatus)
83+
metrics.Track(store.DefaultContextType, os.Args[1:], compose.SuccessStatus)
8384

8485
os.Exit(0)
8586
}

0 commit comments

Comments
 (0)