diff --git a/aci/aci.go b/aci/aci.go index d576d224..7478b978 100644 --- a/aci/aci.go +++ b/aci/aci.go @@ -38,9 +38,9 @@ import ( "github.com/docker/compose-cli/aci/login" "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/errdefs" - "github.com/docker/compose-cli/progress" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/api/errdefs" + "github.com/docker/compose-cli/api/progress" ) func createACIContainers(ctx context.Context, aciContext store.AciContext, groupDefinition containerinstance.ContainerGroup) error { diff --git a/aci/backend.go b/aci/backend.go index b2886392..37332636 100644 --- a/aci/backend.go +++ b/aci/backend.go @@ -26,15 +26,16 @@ import ( "github.com/docker/compose-cli/aci/convert" "github.com/docker/compose-cli/aci/login" + "github.com/docker/compose-cli/api/backend" "github.com/docker/compose-cli/api/compose" "github.com/docker/compose-cli/api/containers" "github.com/docker/compose-cli/api/resources" "github.com/docker/compose-cli/api/secrets" "github.com/docker/compose-cli/api/volumes" - "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" + + "github.com/docker/compose-cli/api/cloud" + apicontext "github.com/docker/compose-cli/api/context" + "github.com/docker/compose-cli/api/context/store" ) const ( diff --git a/aci/compose.go b/aci/compose.go index 2820e192..60a42b17 100644 --- a/aci/compose.go +++ b/aci/compose.go @@ -27,8 +27,8 @@ import ( "github.com/docker/compose-cli/aci/convert" "github.com/docker/compose-cli/aci/login" "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/utils/formatter" ) diff --git a/aci/containers.go b/aci/containers.go index 1b8a926d..0425c583 100644 --- a/aci/containers.go +++ b/aci/containers.go @@ -32,8 +32,8 @@ import ( "github.com/docker/compose-cli/aci/convert" "github.com/docker/compose-cli/aci/login" "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/api/errdefs" ) type aciContainerService struct { diff --git a/aci/context.go b/aci/context.go index 7ef34a2a..7f9cdb4c 100644 --- a/aci/context.go +++ b/aci/context.go @@ -27,9 +27,9 @@ import ( "github.com/hashicorp/go-uuid" "github.com/pkg/errors" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/errdefs" - "github.com/docker/compose-cli/prompt" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/api/errdefs" + "github.com/docker/compose-cli/utils/prompt" ) // ContextParams options for creating ACI context diff --git a/aci/context_test.go b/aci/context_test.go index e834498a..88d72656 100644 --- a/aci/context_test.go +++ b/aci/context_test.go @@ -28,7 +28,7 @@ import ( "gotest.tools/v3/assert" "gotest.tools/v3/assert/cmp" - "github.com/docker/compose-cli/context/store" + "github.com/docker/compose-cli/api/context/store" ) type contextMocks struct { diff --git a/aci/convert/convert.go b/aci/convert/convert.go index 9dbcee3f..0032a4b9 100644 --- a/aci/convert/convert.go +++ b/aci/convert/convert.go @@ -33,7 +33,7 @@ import ( "github.com/docker/compose-cli/aci/login" "github.com/docker/compose-cli/api/compose" "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/context/store" + "github.com/docker/compose-cli/api/context/store" "github.com/docker/compose-cli/utils/formatter" ) diff --git a/aci/convert/convert_test.go b/aci/convert/convert_test.go index be7a72e5..ee3bcc2c 100644 --- a/aci/convert/convert_test.go +++ b/aci/convert/convert_test.go @@ -30,7 +30,7 @@ import ( "github.com/docker/compose-cli/api/compose" "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/context/store" + "github.com/docker/compose-cli/api/context/store" ) var ( diff --git a/aci/convert/volume.go b/aci/convert/volume.go index c64aa53b..3c3e0dd4 100644 --- a/aci/convert/volume.go +++ b/aci/convert/volume.go @@ -30,7 +30,7 @@ import ( "github.com/compose-spec/compose-go/types" "github.com/docker/compose-cli/aci/login" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/errdefs" ) const ( diff --git a/aci/login/client.go b/aci/login/client.go index 635288b3..55b2fb97 100644 --- a/aci/login/client.go +++ b/aci/login/client.go @@ -26,7 +26,7 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/pkg/errors" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/internal" ) diff --git a/aci/login/login.go b/aci/login/login.go index 9c99bcb8..21cb30fc 100644 --- a/aci/login/login.go +++ b/aci/login/login.go @@ -33,7 +33,7 @@ import ( "github.com/pkg/errors" "golang.org/x/oauth2" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/errdefs" ) //go login process, derived from code sample provided by MS at https://github.com/devigned/go-az-cli-stuff diff --git a/aci/login/storagelogin.go b/aci/login/storagelogin.go index 8ec65b06..fbaefb06 100644 --- a/aci/login/storagelogin.go +++ b/aci/login/storagelogin.go @@ -22,7 +22,7 @@ import ( "github.com/pkg/errors" - "github.com/docker/compose-cli/context/store" + "github.com/docker/compose-cli/api/context/store" ) // StorageLogin helper for Azure Storage Login diff --git a/aci/resources.go b/aci/resources.go index 8732dbc6..c483de1b 100644 --- a/aci/resources.go +++ b/aci/resources.go @@ -23,8 +23,8 @@ import ( "github.com/hashicorp/go-multierror" "github.com/docker/compose-cli/aci/convert" + "github.com/docker/compose-cli/api/context/store" "github.com/docker/compose-cli/api/resources" - "github.com/docker/compose-cli/context/store" ) type aciResourceService struct { diff --git a/aci/volumes.go b/aci/volumes.go index 2c012b53..caa2bc0f 100644 --- a/aci/volumes.go +++ b/aci/volumes.go @@ -29,10 +29,10 @@ import ( "github.com/Azure/go-autorest/autorest/to" "github.com/docker/compose-cli/aci/login" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/api/errdefs" + "github.com/docker/compose-cli/api/progress" "github.com/docker/compose-cli/api/volumes" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/errdefs" - "github.com/docker/compose-cli/progress" ) type aciVolumeService struct { diff --git a/backend/backend.go b/api/backend/backend.go similarity index 97% rename from backend/backend.go rename to api/backend/backend.go index 8852151b..b1aa3ead 100644 --- a/backend/backend.go +++ b/api/backend/backend.go @@ -23,13 +23,13 @@ import ( "github.com/sirupsen/logrus" + "github.com/docker/compose-cli/api/cloud" "github.com/docker/compose-cli/api/compose" "github.com/docker/compose-cli/api/containers" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/api/resources" "github.com/docker/compose-cli/api/secrets" "github.com/docker/compose-cli/api/volumes" - "github.com/docker/compose-cli/context/cloud" - "github.com/docker/compose-cli/errdefs" ) var ( diff --git a/api/client/client.go b/api/client/client.go index 10c0bbda..bbcd759a 100644 --- a/api/client/client.go +++ b/api/client/client.go @@ -19,15 +19,15 @@ package client import ( "context" + "github.com/docker/compose-cli/api/backend" + "github.com/docker/compose-cli/api/cloud" "github.com/docker/compose-cli/api/compose" "github.com/docker/compose-cli/api/containers" + apicontext "github.com/docker/compose-cli/api/context" + "github.com/docker/compose-cli/api/context/store" "github.com/docker/compose-cli/api/resources" "github.com/docker/compose-cli/api/secrets" "github.com/docker/compose-cli/api/volumes" - "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 diff --git a/api/client/compose.go b/api/client/compose.go index 0c621123..072b06b9 100644 --- a/api/client/compose.go +++ b/api/client/compose.go @@ -20,7 +20,7 @@ import ( "context" "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/errdefs" "github.com/compose-spec/compose-go/types" ) diff --git a/api/client/containers.go b/api/client/containers.go index efa39537..1b1e665b 100644 --- a/api/client/containers.go +++ b/api/client/containers.go @@ -20,7 +20,7 @@ import ( "context" "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/errdefs" ) type containerService struct { diff --git a/api/client/resources.go b/api/client/resources.go index cefb6c48..04b74219 100644 --- a/api/client/resources.go +++ b/api/client/resources.go @@ -19,8 +19,8 @@ package client import ( "context" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/api/resources" - "github.com/docker/compose-cli/errdefs" ) type resourceService struct { diff --git a/api/client/secrets.go b/api/client/secrets.go index 8c2debd2..a263e5fd 100644 --- a/api/client/secrets.go +++ b/api/client/secrets.go @@ -19,8 +19,8 @@ package client import ( "context" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/api/secrets" - "github.com/docker/compose-cli/errdefs" ) type secretsService struct { diff --git a/api/client/volume.go b/api/client/volume.go index 23d99c3d..aa359754 100644 --- a/api/client/volume.go +++ b/api/client/volume.go @@ -19,8 +19,8 @@ package client import ( "context" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/api/volumes" - "github.com/docker/compose-cli/errdefs" ) type volumeService struct { diff --git a/context/cloud/api.go b/api/cloud/api.go similarity index 97% rename from context/cloud/api.go rename to api/cloud/api.go index 475599d3..aa8b7773 100644 --- a/context/cloud/api.go +++ b/api/cloud/api.go @@ -19,7 +19,7 @@ package cloud import ( "context" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/errdefs" ) // Service cloud specific services diff --git a/config/config.go b/api/config/config.go similarity index 98% rename from config/config.go rename to api/config/config.go index 1ea0e43b..b771ded8 100644 --- a/config/config.go +++ b/api/config/config.go @@ -25,7 +25,7 @@ import ( "github.com/pkg/errors" - "github.com/docker/compose-cli/context/store" + "github.com/docker/compose-cli/api/context/store" ) type dirKey struct{} diff --git a/config/config_test.go b/api/config/config_test.go similarity index 100% rename from config/config_test.go rename to api/config/config_test.go diff --git a/config/keys.go b/api/config/keys.go similarity index 100% rename from config/keys.go rename to api/config/keys.go diff --git a/api/containers/api.go b/api/containers/api.go index f5f55d2c..02cab49d 100644 --- a/api/containers/api.go +++ b/api/containers/api.go @@ -23,7 +23,7 @@ import ( "github.com/compose-spec/compose-go/types" specs "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/docker/compose-cli/formatter" + "github.com/docker/compose-cli/utils" ) const ( @@ -102,7 +102,7 @@ type ContainerConfig struct { // Volumes to be mounted Volumes []string // Memlimit - MemLimit formatter.MemBytes + MemLimit utils.MemBytes // CPUlimit CPULimit float64 // Environment variables diff --git a/context/context.go b/api/context/context.go similarity index 100% rename from context/context.go rename to api/context/context.go diff --git a/context/flags.go b/api/context/flags.go similarity index 100% rename from context/flags.go rename to api/context/flags.go diff --git a/context/store/contextmetadata.go b/api/context/store/contextmetadata.go similarity index 100% rename from context/store/contextmetadata.go rename to api/context/store/contextmetadata.go diff --git a/context/store/contextmetadata_test.go b/api/context/store/contextmetadata_test.go similarity index 100% rename from context/store/contextmetadata_test.go rename to api/context/store/contextmetadata_test.go diff --git a/context/store/store.go b/api/context/store/store.go similarity index 99% rename from context/store/store.go rename to api/context/store/store.go index 917f282e..78b512ea 100644 --- a/context/store/store.go +++ b/api/context/store/store.go @@ -28,7 +28,7 @@ import ( "github.com/opencontainers/go-digest" "github.com/pkg/errors" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/errdefs" ) const ( diff --git a/context/store/store_test.go b/api/context/store/store_test.go similarity index 98% rename from context/store/store_test.go rename to api/context/store/store_test.go index 29b814f1..97e7613e 100644 --- a/context/store/store_test.go +++ b/api/context/store/store_test.go @@ -25,7 +25,7 @@ import ( "gotest.tools/v3/assert" "gotest.tools/v3/assert/cmp" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/errdefs" ) func testStore(t *testing.T) Store { diff --git a/context/store/storedefault.go b/api/context/store/storedefault.go similarity index 100% rename from context/store/storedefault.go rename to api/context/store/storedefault.go diff --git a/errdefs/errors.go b/api/errdefs/errors.go similarity index 100% rename from errdefs/errors.go rename to api/errdefs/errors.go diff --git a/errdefs/errors_test.go b/api/errdefs/errors_test.go similarity index 100% rename from errdefs/errors_test.go rename to api/errdefs/errors_test.go diff --git a/progress/event.go b/api/progress/event.go similarity index 100% rename from progress/event.go rename to api/progress/event.go diff --git a/progress/noop.go b/api/progress/noop.go similarity index 100% rename from progress/noop.go rename to api/progress/noop.go diff --git a/progress/plain.go b/api/progress/plain.go similarity index 100% rename from progress/plain.go rename to api/progress/plain.go diff --git a/progress/spinner.go b/api/progress/spinner.go similarity index 100% rename from progress/spinner.go rename to api/progress/spinner.go diff --git a/progress/tty.go b/api/progress/tty.go similarity index 100% rename from progress/tty.go rename to api/progress/tty.go diff --git a/progress/tty_test.go b/api/progress/tty_test.go similarity index 100% rename from progress/tty_test.go rename to api/progress/tty_test.go diff --git a/progress/writer.go b/api/progress/writer.go similarity index 100% rename from progress/writer.go rename to api/progress/writer.go diff --git a/progress/writer_test.go b/api/progress/writer_test.go similarity index 100% rename from progress/writer_test.go rename to api/progress/writer_test.go diff --git a/cli/cmd/compose/build.go b/cli/cmd/compose/build.go index 6caf7474..f2a82575 100644 --- a/cli/cmd/compose/build.go +++ b/cli/cmd/compose/build.go @@ -23,7 +23,7 @@ import ( "github.com/spf13/cobra" "github.com/docker/compose-cli/api/client" - "github.com/docker/compose-cli/progress" + "github.com/docker/compose-cli/api/progress" ) type buildOptions struct { diff --git a/cli/cmd/compose/compose.go b/cli/cmd/compose/compose.go index ddd04385..87f4ed0b 100644 --- a/cli/cmd/compose/compose.go +++ b/cli/cmd/compose/compose.go @@ -24,7 +24,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" - "github.com/docker/compose-cli/context/store" + "github.com/docker/compose-cli/api/context/store" ) type composeOptions struct { diff --git a/cli/cmd/compose/down.go b/cli/cmd/compose/down.go index ac1b9355..cfa3c43e 100644 --- a/cli/cmd/compose/down.go +++ b/cli/cmd/compose/down.go @@ -24,7 +24,7 @@ import ( "github.com/spf13/cobra" "github.com/docker/compose-cli/api/client" - "github.com/docker/compose-cli/progress" + "github.com/docker/compose-cli/api/progress" ) func downCommand() *cobra.Command { diff --git a/cli/cmd/compose/list.go b/cli/cmd/compose/list.go index 8b8d7c07..114cf2aa 100644 --- a/cli/cmd/compose/list.go +++ b/cli/cmd/compose/list.go @@ -27,7 +27,7 @@ import ( "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/formatter" + "github.com/docker/compose-cli/cli/formatter" ) func listCommand() *cobra.Command { diff --git a/cli/cmd/compose/logs.go b/cli/cmd/compose/logs.go index 6993943b..49758d45 100644 --- a/cli/cmd/compose/logs.go +++ b/cli/cmd/compose/logs.go @@ -24,7 +24,7 @@ import ( "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/formatter" + "github.com/docker/compose-cli/cli/formatter" ) func logsCommand() *cobra.Command { diff --git a/cli/cmd/compose/ps.go b/cli/cmd/compose/ps.go index 63d7b512..aa317aa9 100644 --- a/cli/cmd/compose/ps.go +++ b/cli/cmd/compose/ps.go @@ -27,7 +27,7 @@ import ( "github.com/spf13/cobra" "github.com/docker/compose-cli/api/client" - "github.com/docker/compose-cli/formatter" + "github.com/docker/compose-cli/cli/formatter" ) func psCommand() *cobra.Command { diff --git a/cli/cmd/compose/pull.go b/cli/cmd/compose/pull.go index 03ce586a..02243c34 100644 --- a/cli/cmd/compose/pull.go +++ b/cli/cmd/compose/pull.go @@ -23,7 +23,7 @@ import ( "github.com/spf13/cobra" "github.com/docker/compose-cli/api/client" - "github.com/docker/compose-cli/progress" + "github.com/docker/compose-cli/api/progress" ) type pullOptions struct { diff --git a/cli/cmd/compose/push.go b/cli/cmd/compose/push.go index 2c95ceea..86f92e8c 100644 --- a/cli/cmd/compose/push.go +++ b/cli/cmd/compose/push.go @@ -23,7 +23,7 @@ import ( "github.com/spf13/cobra" "github.com/docker/compose-cli/api/client" - "github.com/docker/compose-cli/progress" + "github.com/docker/compose-cli/api/progress" ) type pushOptions struct { diff --git a/cli/cmd/compose/run.go b/cli/cmd/compose/run.go index 3c019cb1..b97574d1 100644 --- a/cli/cmd/compose/run.go +++ b/cli/cmd/compose/run.go @@ -25,7 +25,7 @@ import ( "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/progress" + "github.com/docker/compose-cli/api/progress" ) type runOptions struct { diff --git a/cli/cmd/compose/up.go b/cli/cmd/compose/up.go index c84b9dd5..6fbfa019 100644 --- a/cli/cmd/compose/up.go +++ b/cli/cmd/compose/up.go @@ -24,9 +24,9 @@ import ( "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/formatter" - "github.com/docker/compose-cli/progress" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/api/progress" + "github.com/docker/compose-cli/cli/formatter" "github.com/compose-spec/compose-go/cli" "github.com/compose-spec/compose-go/types" diff --git a/cli/cmd/context/create.go b/cli/cmd/context/create.go index 941527f9..65354da8 100644 --- a/cli/cmd/context/create.go +++ b/cli/cmd/context/create.go @@ -23,8 +23,8 @@ import ( "github.com/spf13/cobra" + "github.com/docker/compose-cli/api/context/store" "github.com/docker/compose-cli/cli/mobycli" - "github.com/docker/compose-cli/context/store" ) type descriptionCreateOpts struct { diff --git a/cli/cmd/context/create_aci.go b/cli/cmd/context/create_aci.go index c66787df..0c6f7c41 100644 --- a/cli/cmd/context/create_aci.go +++ b/cli/cmd/context/create_aci.go @@ -24,8 +24,8 @@ import ( "github.com/docker/compose-cli/aci" "github.com/docker/compose-cli/api/client" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/api/errdefs" ) func init() { diff --git a/cli/cmd/context/create_ecs.go b/cli/cmd/context/create_ecs.go index 2d76bf0d..34ba11c4 100644 --- a/cli/cmd/context/create_ecs.go +++ b/cli/cmd/context/create_ecs.go @@ -23,12 +23,13 @@ import ( "os" "strings" - "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" "github.com/pkg/errors" "github.com/spf13/cobra" + + "github.com/docker/compose-cli/api/client" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/api/errdefs" + "github.com/docker/compose-cli/ecs" ) func init() { diff --git a/cli/cmd/context/ls.go b/cli/cmd/context/ls.go index b5119328..ffcd1b8e 100644 --- a/cli/cmd/context/ls.go +++ b/cli/cmd/context/ls.go @@ -26,10 +26,10 @@ import ( "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" - apicontext "github.com/docker/compose-cli/context" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/formatter" ) type lsOpts struct { diff --git a/cli/cmd/context/rm.go b/cli/cmd/context/rm.go index 5ad9f060..473b13e6 100644 --- a/cli/cmd/context/rm.go +++ b/cli/cmd/context/rm.go @@ -24,9 +24,9 @@ import ( "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" - apicontext "github.com/docker/compose-cli/context" - "github.com/docker/compose-cli/context/store" ) type removeOpts struct { diff --git a/cli/cmd/context/show.go b/cli/cmd/context/show.go index 5b6c2129..69dc91da 100644 --- a/cli/cmd/context/show.go +++ b/cli/cmd/context/show.go @@ -22,8 +22,8 @@ import ( "github.com/spf13/cobra" - apicontext "github.com/docker/compose-cli/context" - "github.com/docker/compose-cli/context/store" + apicontext "github.com/docker/compose-cli/api/context" + "github.com/docker/compose-cli/api/context/store" ) func showCommand() *cobra.Command { diff --git a/cli/cmd/context/update.go b/cli/cmd/context/update.go index dcc4a3b4..f21182b4 100644 --- a/cli/cmd/context/update.go +++ b/cli/cmd/context/update.go @@ -20,9 +20,9 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/cli/mobycli" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/errdefs" ) func updateCommand() *cobra.Command { diff --git a/cli/cmd/context/use.go b/cli/cmd/context/use.go index d58c2d99..8c4684c5 100644 --- a/cli/cmd/context/use.go +++ b/cli/cmd/context/use.go @@ -22,8 +22,8 @@ import ( "github.com/spf13/cobra" - "github.com/docker/compose-cli/config" - "github.com/docker/compose-cli/context/store" + "github.com/docker/compose-cli/api/config" + "github.com/docker/compose-cli/api/context/store" ) func useCommand() *cobra.Command { diff --git a/cli/cmd/inspect.go b/cli/cmd/inspect.go index 6ce9a0e2..e344794c 100644 --- a/cli/cmd/inspect.go +++ b/cli/cmd/inspect.go @@ -27,7 +27,7 @@ import ( "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/formatter" + "github.com/docker/compose-cli/cli/formatter" ) // InspectCommand inspects into containers diff --git a/cli/cmd/inspect_test.go b/cli/cmd/inspect_test.go deleted file mode 100644 index af75d4df..00000000 --- a/cli/cmd/inspect_test.go +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright 2020 Docker Compose CLI authors - - 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 cmd - -import ( - "testing" - - "gotest.tools/v3/assert" - "gotest.tools/v3/golden" - - _ "github.com/docker/compose-cli/example" - "github.com/docker/compose-cli/tests/framework" -) - -func TestInspectId(t *testing.T) { - c := framework.NewTestCLI(t) - err := runInspect(c.Context(), "id") - assert.NilError(t, err) - golden.Assert(t, c.GetStdOut(), "inspect-out-id.golden") -} diff --git a/cli/cmd/kill.go b/cli/cmd/kill.go index 9b14f7fe..0de597d7 100644 --- a/cli/cmd/kill.go +++ b/cli/cmd/kill.go @@ -25,8 +25,8 @@ import ( "github.com/spf13/cobra" "github.com/docker/compose-cli/api/client" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/cli/formatter" - "github.com/docker/compose-cli/errdefs" ) type killOpts struct { diff --git a/cli/cmd/login/login.go b/cli/cmd/login/login.go index 78cc0a99..7163dc96 100644 --- a/cli/cmd/login/login.go +++ b/cli/cmd/login/login.go @@ -24,9 +24,9 @@ import ( "github.com/spf13/cobra" "github.com/docker/compose-cli/api/client" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/cli/cmd/mobyflags" "github.com/docker/compose-cli/cli/mobycli" - "github.com/docker/compose-cli/errdefs" ) // Command returns the login command diff --git a/cli/cmd/logout/azure.go b/cli/cmd/logout/azure.go index 1f0ca039..2c209a49 100644 --- a/cli/cmd/logout/azure.go +++ b/cli/cmd/logout/azure.go @@ -24,7 +24,7 @@ import ( "github.com/spf13/cobra" "github.com/docker/compose-cli/api/client" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/errdefs" ) // AzureLogoutCommand returns the azure logout command diff --git a/cli/cmd/ps.go b/cli/cmd/ps.go index 56d6ab72..587999b1 100644 --- a/cli/cmd/ps.go +++ b/cli/cmd/ps.go @@ -28,7 +28,7 @@ import ( "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/containers" - formatter2 "github.com/docker/compose-cli/formatter" + formatter2 "github.com/docker/compose-cli/cli/formatter" "github.com/docker/compose-cli/utils/formatter" ) diff --git a/cli/cmd/ps_test.go b/cli/cmd/ps_test.go deleted file mode 100644 index 7dc72d57..00000000 --- a/cli/cmd/ps_test.go +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright 2020 Docker Compose CLI authors - - 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 cmd - -import ( - "testing" - - "gotest.tools/v3/assert" - "gotest.tools/v3/golden" - - _ "github.com/docker/compose-cli/example" - "github.com/docker/compose-cli/tests/framework" -) - -func TestPs(t *testing.T) { - c := framework.NewTestCLI(t) - opts := psOpts{ - quiet: false, - } - - err := runPs(c.Context(), opts) - assert.NilError(t, err) - - golden.Assert(t, c.GetStdOut(), "ps-out.golden") -} - -func TestPsQuiet(t *testing.T) { - c := framework.NewTestCLI(t) - opts := psOpts{ - quiet: true, - } - - err := runPs(c.Context(), opts) - assert.NilError(t, err) - - golden.Assert(t, c.GetStdOut(), "ps-out-quiet.golden") -} diff --git a/cli/cmd/rm.go b/cli/cmd/rm.go index 5a824513..0f38f8c7 100644 --- a/cli/cmd/rm.go +++ b/cli/cmd/rm.go @@ -26,8 +26,8 @@ import ( "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/containers" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/cli/formatter" - "github.com/docker/compose-cli/errdefs" ) type rmOpts struct { diff --git a/cli/cmd/run/run.go b/cli/cmd/run/run.go index c08008bc..62ea4be8 100644 --- a/cli/cmd/run/run.go +++ b/cli/cmd/run/run.go @@ -28,9 +28,9 @@ import ( "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/containers" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/api/progress" "github.com/docker/compose-cli/cli/options/run" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/progress" ) // Command runs a container diff --git a/cli/cmd/secrets.go b/cli/cmd/secrets.go index 0fc14c58..22a9e934 100644 --- a/cli/cmd/secrets.go +++ b/cli/cmd/secrets.go @@ -26,7 +26,7 @@ import ( "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/secrets" - "github.com/docker/compose-cli/formatter" + "github.com/docker/compose-cli/cli/formatter" ) // SecretCommand manage secrets diff --git a/cli/cmd/serve.go b/cli/cmd/serve.go index d11e47a0..dcdde89d 100644 --- a/cli/cmd/serve.go +++ b/cli/cmd/serve.go @@ -23,13 +23,13 @@ import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" - composev1 "github.com/docker/compose-cli/protos/compose/v1" - containersv1 "github.com/docker/compose-cli/protos/containers/v1" - contextsv1 "github.com/docker/compose-cli/protos/contexts/v1" - streamsv1 "github.com/docker/compose-cli/protos/streams/v1" - volumesv1 "github.com/docker/compose-cli/protos/volumes/v1" - "github.com/docker/compose-cli/server" - "github.com/docker/compose-cli/server/proxy" + "github.com/docker/compose-cli/cli/server" + composev1 "github.com/docker/compose-cli/cli/server/protos/compose/v1" + containersv1 "github.com/docker/compose-cli/cli/server/protos/containers/v1" + contextsv1 "github.com/docker/compose-cli/cli/server/protos/contexts/v1" + streamsv1 "github.com/docker/compose-cli/cli/server/protos/streams/v1" + volumesv1 "github.com/docker/compose-cli/cli/server/protos/volumes/v1" + "github.com/docker/compose-cli/cli/server/proxy" ) type serveOpts struct { diff --git a/cli/cmd/start.go b/cli/cmd/start.go index 14fb009d..32e23112 100644 --- a/cli/cmd/start.go +++ b/cli/cmd/start.go @@ -25,8 +25,8 @@ import ( "github.com/spf13/cobra" "github.com/docker/compose-cli/api/client" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/cli/formatter" - "github.com/docker/compose-cli/errdefs" ) // StartCommand starts containers diff --git a/cli/cmd/stop.go b/cli/cmd/stop.go index 219c8e72..460a301b 100644 --- a/cli/cmd/stop.go +++ b/cli/cmd/stop.go @@ -25,8 +25,8 @@ import ( "github.com/spf13/cobra" "github.com/docker/compose-cli/api/client" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/cli/formatter" - "github.com/docker/compose-cli/errdefs" ) type stopOpts struct { diff --git a/cli/cmd/testdata/inspect-out-id.golden b/cli/cmd/testdata/inspect-out-id.golden deleted file mode 100644 index 1200c98e..00000000 --- a/cli/cmd/testdata/inspect-out-id.golden +++ /dev/null @@ -1,14 +0,0 @@ -{ - "ID": "id", - "Status": "", - "Image": "nginx", - "HostConfig": { - "RestartPolicy": "none", - "CPUReservation": 0, - "CPULimit": 0, - "MemoryReservation": 0, - "MemoryLimit": 0, - "AutoRemove": false - }, - "Platform": "Linux" -} diff --git a/cli/cmd/testdata/ps-out-quiet.golden b/cli/cmd/testdata/ps-out-quiet.golden deleted file mode 100644 index ceeb39db..00000000 --- a/cli/cmd/testdata/ps-out-quiet.golden +++ /dev/null @@ -1,2 +0,0 @@ -id -1234 diff --git a/cli/cmd/testdata/ps-out.golden b/cli/cmd/testdata/ps-out.golden deleted file mode 100644 index ee7ef979..00000000 --- a/cli/cmd/testdata/ps-out.golden +++ /dev/null @@ -1,3 +0,0 @@ -CONTAINER ID IMAGE COMMAND STATUS PORTS -id nginx -1234 alpine diff --git a/cli/cmd/version.go b/cli/cmd/version.go index f1238ab9..83372aa3 100644 --- a/cli/cmd/version.go +++ b/cli/cmd/version.go @@ -24,8 +24,8 @@ import ( "github.com/spf13/cobra" "github.com/docker/compose-cli/cli/cmd/mobyflags" + "github.com/docker/compose-cli/cli/formatter" "github.com/docker/compose-cli/cli/mobycli" - "github.com/docker/compose-cli/formatter" "github.com/docker/compose-cli/internal" ) diff --git a/cli/cmd/volume/command.go b/cli/cmd/volume/command.go index 852a43d4..8188c320 100644 --- a/cli/cmd/volume/command.go +++ b/cli/cmd/volume/command.go @@ -22,11 +22,11 @@ import ( "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/api/progress" "github.com/docker/compose-cli/cli/formatter" - "github.com/docker/compose-cli/context/store" + formatter2 "github.com/docker/compose-cli/cli/formatter" "github.com/docker/compose-cli/ecs" - formatter2 "github.com/docker/compose-cli/formatter" - "github.com/docker/compose-cli/progress" "github.com/hashicorp/go-multierror" "github.com/spf13/cobra" diff --git a/cli/cmd/volume/list.go b/cli/cmd/volume/list.go index 062ef63c..8bbc2018 100644 --- a/cli/cmd/volume/list.go +++ b/cli/cmd/volume/list.go @@ -25,7 +25,7 @@ import ( "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/volumes" - "github.com/docker/compose-cli/formatter" + "github.com/docker/compose-cli/cli/formatter" ) type listVolumeOpts struct { diff --git a/cli/config/flags.go b/cli/config/flags.go index 2ba12e67..2a5265b2 100644 --- a/cli/config/flags.go +++ b/cli/config/flags.go @@ -22,7 +22,7 @@ import ( "github.com/spf13/pflag" - "github.com/docker/compose-cli/config" + "github.com/docker/compose-cli/api/config" ) // ConfigFlags are the global CLI flags diff --git a/formatter/colors.go b/cli/formatter/colors.go similarity index 100% rename from formatter/colors.go rename to cli/formatter/colors.go diff --git a/formatter/consts.go b/cli/formatter/consts.go similarity index 100% rename from formatter/consts.go rename to cli/formatter/consts.go diff --git a/formatter/formatter.go b/cli/formatter/formatter.go similarity index 97% rename from formatter/formatter.go rename to cli/formatter/formatter.go index 4f8df536..b1472024 100644 --- a/formatter/formatter.go +++ b/cli/formatter/formatter.go @@ -24,7 +24,7 @@ import ( "github.com/pkg/errors" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/errdefs" ) // Print prints formatted lists in different formats diff --git a/formatter/formatter_test.go b/cli/formatter/formatter_test.go similarity index 100% rename from formatter/formatter_test.go rename to cli/formatter/formatter_test.go diff --git a/formatter/json.go b/cli/formatter/json.go similarity index 100% rename from formatter/json.go rename to cli/formatter/json.go diff --git a/formatter/logs.go b/cli/formatter/logs.go similarity index 100% rename from formatter/logs.go rename to cli/formatter/logs.go diff --git a/formatter/pretty.go b/cli/formatter/pretty.go similarity index 100% rename from formatter/pretty.go rename to cli/formatter/pretty.go diff --git a/cli/main.go b/cli/main.go index 446d5046..5a772763 100644 --- a/cli/main.go +++ b/cli/main.go @@ -32,6 +32,10 @@ import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "github.com/docker/compose-cli/api/config" + apicontext "github.com/docker/compose-cli/api/context" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/cli/cmd" "github.com/docker/compose-cli/cli/cmd/compose" contextcmd "github.com/docker/compose-cli/cli/cmd/context" @@ -39,13 +43,9 @@ import ( "github.com/docker/compose-cli/cli/cmd/logout" "github.com/docker/compose-cli/cli/cmd/run" "github.com/docker/compose-cli/cli/cmd/volume" + "github.com/docker/compose-cli/cli/metrics" "github.com/docker/compose-cli/cli/mobycli" cliopts "github.com/docker/compose-cli/cli/options" - "github.com/docker/compose-cli/config" - apicontext "github.com/docker/compose-cli/context" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/errdefs" - "github.com/docker/compose-cli/metrics" // Backend registrations _ "github.com/docker/compose-cli/aci" diff --git a/cli/main_test.go b/cli/main_test.go index 20426de3..bb62ee04 100644 --- a/cli/main_test.go +++ b/cli/main_test.go @@ -24,11 +24,11 @@ import ( "gotest.tools/v3/assert" + "github.com/docker/compose-cli/api/config" "github.com/docker/compose-cli/cli/cmd" "github.com/docker/compose-cli/cli/cmd/context" "github.com/docker/compose-cli/cli/cmd/login" "github.com/docker/compose-cli/cli/cmd/run" - "github.com/docker/compose-cli/config" ) var contextSetConfig = []byte(`{ diff --git a/metrics/client.go b/cli/metrics/client.go similarity index 100% rename from metrics/client.go rename to cli/metrics/client.go diff --git a/metrics/commands.go b/cli/metrics/commands.go similarity index 100% rename from metrics/commands.go rename to cli/metrics/commands.go diff --git a/metrics/conn_e2e.go b/cli/metrics/conn_e2e.go similarity index 100% rename from metrics/conn_e2e.go rename to cli/metrics/conn_e2e.go diff --git a/metrics/conn_other.go b/cli/metrics/conn_other.go similarity index 100% rename from metrics/conn_other.go rename to cli/metrics/conn_other.go diff --git a/metrics/conn_windows.go b/cli/metrics/conn_windows.go similarity index 100% rename from metrics/conn_windows.go rename to cli/metrics/conn_windows.go diff --git a/metrics/generatecommands/main.go b/cli/metrics/generatecommands/main.go similarity index 100% rename from metrics/generatecommands/main.go rename to cli/metrics/generatecommands/main.go diff --git a/metrics/metrics.go b/cli/metrics/metrics.go similarity index 100% rename from metrics/metrics.go rename to cli/metrics/metrics.go diff --git a/metrics/metrics_test.go b/cli/metrics/metrics_test.go similarity index 100% rename from metrics/metrics_test.go rename to cli/metrics/metrics_test.go diff --git a/cli/mobycli/exec.go b/cli/mobycli/exec.go index c46637ed..e264e2cd 100644 --- a/cli/mobycli/exec.go +++ b/cli/mobycli/exec.go @@ -26,10 +26,10 @@ import ( "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/metrics" "github.com/docker/compose-cli/cli/mobycli/resolvepath" - apicontext "github.com/docker/compose-cli/context" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/metrics" ) var delegatedContextTypes = []string{store.DefaultContextType} diff --git a/cli/mobycli/exec_test.go b/cli/mobycli/exec_test.go index 20bd71fa..7138464f 100644 --- a/cli/mobycli/exec_test.go +++ b/cli/mobycli/exec_test.go @@ -21,7 +21,7 @@ import ( "gotest.tools/v3/assert" - "github.com/docker/compose-cli/context/store" + "github.com/docker/compose-cli/api/context/store" ) func TestDelegateContextTypeToMoby(t *testing.T) { diff --git a/cli/options/options.go b/cli/options/options.go index f7575438..0d4aac18 100644 --- a/cli/options/options.go +++ b/cli/options/options.go @@ -17,8 +17,8 @@ package options import ( + apicontext "github.com/docker/compose-cli/api/context" cliconfig "github.com/docker/compose-cli/cli/config" - apicontext "github.com/docker/compose-cli/context" ) // GlobalOpts contains the global CLI options diff --git a/cli/options/run/opts.go b/cli/options/run/opts.go index ea95be63..3388d673 100644 --- a/cli/options/run/opts.go +++ b/cli/options/run/opts.go @@ -22,6 +22,8 @@ import ( "strings" "time" + "github.com/docker/compose-cli/utils" + "github.com/compose-spec/compose-go/types" "github.com/containerd/containerd/platforms" "github.com/docker/cli/opts" @@ -30,7 +32,6 @@ import ( specs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/formatter" ) // Opts contain run command options @@ -41,7 +42,7 @@ type Opts struct { Labels []string Volumes []string Cpus float64 - Memory formatter.MemBytes + Memory utils.MemBytes Detach bool Environment []string EnvironmentFiles []string diff --git a/server/contextserverstream.go b/cli/server/contextserverstream.go similarity index 100% rename from server/contextserverstream.go rename to cli/server/contextserverstream.go diff --git a/server/interceptor.go b/cli/server/interceptor.go similarity index 94% rename from server/interceptor.go rename to cli/server/interceptor.go index 17165a10..7528a513 100644 --- a/server/interceptor.go +++ b/cli/server/interceptor.go @@ -25,10 +25,10 @@ import ( "google.golang.org/grpc/metadata" "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" - "github.com/docker/compose-cli/server/proxy" + "github.com/docker/compose-cli/api/config" + apicontext "github.com/docker/compose-cli/api/context" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/cli/server/proxy" ) // key is the key where the current docker context is stored in the metadata diff --git a/server/interceptor_test.go b/cli/server/interceptor_test.go similarity index 97% rename from server/interceptor_test.go rename to cli/server/interceptor_test.go index 88fa1ae2..66dbf4a7 100644 --- a/server/interceptor_test.go +++ b/cli/server/interceptor_test.go @@ -28,8 +28,8 @@ import ( "gotest.tools/v3/assert" "gotest.tools/v3/assert/cmp" - "github.com/docker/compose-cli/config" - apicontext "github.com/docker/compose-cli/context" + "github.com/docker/compose-cli/api/config" + apicontext "github.com/docker/compose-cli/api/context" ) func testContext(t *testing.T) context.Context { diff --git a/server/metrics.go b/cli/server/metrics.go similarity index 96% rename from server/metrics.go rename to cli/server/metrics.go index bbd1131e..8dd5065e 100644 --- a/server/metrics.go +++ b/cli/server/metrics.go @@ -21,8 +21,8 @@ import ( "google.golang.org/grpc" - "github.com/docker/compose-cli/metrics" - "github.com/docker/compose-cli/server/proxy" + "github.com/docker/compose-cli/cli/metrics" + "github.com/docker/compose-cli/cli/server/proxy" ) var ( diff --git a/server/metrics_test.go b/cli/server/metrics_test.go similarity index 88% rename from server/metrics_test.go rename to cli/server/metrics_test.go index 3b47c7ef..498ef5e3 100644 --- a/server/metrics_test.go +++ b/cli/server/metrics_test.go @@ -31,16 +31,16 @@ import ( "github.com/docker/compose-cli/api/client" "github.com/docker/compose-cli/api/compose" "github.com/docker/compose-cli/api/containers" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/api/secrets" "github.com/docker/compose-cli/api/volumes" - "github.com/docker/compose-cli/errdefs" - "github.com/docker/compose-cli/metrics" - composev1 "github.com/docker/compose-cli/protos/compose/v1" - containersv1 "github.com/docker/compose-cli/protos/containers/v1" - contextsv1 "github.com/docker/compose-cli/protos/contexts/v1" - streamsv1 "github.com/docker/compose-cli/protos/streams/v1" - volumesv1 "github.com/docker/compose-cli/protos/volumes/v1" - "github.com/docker/compose-cli/server/proxy" + "github.com/docker/compose-cli/cli/metrics" + composev1 "github.com/docker/compose-cli/cli/server/protos/compose/v1" + containersv1 "github.com/docker/compose-cli/cli/server/protos/containers/v1" + contextsv1 "github.com/docker/compose-cli/cli/server/protos/contexts/v1" + streamsv1 "github.com/docker/compose-cli/cli/server/protos/streams/v1" + volumesv1 "github.com/docker/compose-cli/cli/server/protos/volumes/v1" + "github.com/docker/compose-cli/cli/server/proxy" ) func TestAllMethodsHaveCorrespondingCliCommand(t *testing.T) { diff --git a/protos/compose/v1/compose.pb.go b/cli/server/protos/compose/v1/compose.pb.go similarity index 99% rename from protos/compose/v1/compose.pb.go rename to cli/server/protos/compose/v1/compose.pb.go index 712fa40f..820be0d3 100644 --- a/protos/compose/v1/compose.pb.go +++ b/cli/server/protos/compose/v1/compose.pb.go @@ -23,14 +23,15 @@ package v1 import ( context "context" + reflect "reflect" + sync "sync" + proto "github.com/golang/protobuf/proto" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" ) const ( diff --git a/protos/compose/v1/compose.proto b/cli/server/protos/compose/v1/compose.proto similarity index 95% rename from protos/compose/v1/compose.proto rename to cli/server/protos/compose/v1/compose.proto index 216a905e..2858af16 100644 --- a/protos/compose/v1/compose.proto +++ b/cli/server/protos/compose/v1/compose.proto @@ -17,7 +17,7 @@ syntax = "proto3"; package com.docker.api.protos.compose.v1; -option go_package = "github.com/docker/compose-cli/protos/compose/v1;v1"; +option go_package = "github.com/docker/compose-cli/cli/server/protos/compose/v1;v1"; service Compose { rpc Up(ComposeUpRequest) returns (ComposeUpResponse); diff --git a/protos/compose/v1/doc.go b/cli/server/protos/compose/v1/doc.go similarity index 100% rename from protos/compose/v1/doc.go rename to cli/server/protos/compose/v1/doc.go diff --git a/protos/containers/v1/containers.pb.go b/cli/server/protos/containers/v1/containers.pb.go similarity index 99% rename from protos/containers/v1/containers.pb.go rename to cli/server/protos/containers/v1/containers.pb.go index 2a34bde3..638a3780 100644 --- a/protos/containers/v1/containers.pb.go +++ b/cli/server/protos/containers/v1/containers.pb.go @@ -23,14 +23,15 @@ package v1 import ( context "context" + reflect "reflect" + sync "sync" + proto "github.com/golang/protobuf/proto" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" ) const ( diff --git a/protos/containers/v1/containers.proto b/cli/server/protos/containers/v1/containers.proto similarity index 97% rename from protos/containers/v1/containers.proto rename to cli/server/protos/containers/v1/containers.proto index 647b58b3..86ea30fb 100644 --- a/protos/containers/v1/containers.proto +++ b/cli/server/protos/containers/v1/containers.proto @@ -17,7 +17,7 @@ syntax = "proto3"; package com.docker.api.protos.containers.v1; -option go_package = "github.com/docker/compose-cli/protos/containers/v1;v1"; +option go_package = "github.com/docker/compose-cli/cli/server/protos/containers/v1;v1"; service Containers { rpc List(ListRequest) returns (ListResponse); diff --git a/protos/containers/v1/doc.go b/cli/server/protos/containers/v1/doc.go similarity index 100% rename from protos/containers/v1/doc.go rename to cli/server/protos/containers/v1/doc.go diff --git a/protos/contexts/v1/contexts.pb.go b/cli/server/protos/contexts/v1/contexts.pb.go similarity index 99% rename from protos/contexts/v1/contexts.pb.go rename to cli/server/protos/contexts/v1/contexts.pb.go index 761a9589..201becdc 100644 --- a/protos/contexts/v1/contexts.pb.go +++ b/cli/server/protos/contexts/v1/contexts.pb.go @@ -23,14 +23,15 @@ package v1 import ( context "context" + reflect "reflect" + sync "sync" + proto "github.com/golang/protobuf/proto" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" ) const ( diff --git a/protos/contexts/v1/contexts.proto b/cli/server/protos/contexts/v1/contexts.proto similarity index 94% rename from protos/contexts/v1/contexts.proto rename to cli/server/protos/contexts/v1/contexts.proto index 2c4755cd..a77239ca 100644 --- a/protos/contexts/v1/contexts.proto +++ b/cli/server/protos/contexts/v1/contexts.proto @@ -17,7 +17,7 @@ syntax = "proto3"; package com.docker.api.protos.context.v1; -option go_package = "github.com/docker/compose-cli/protos/context/v1;v1"; +option go_package = "github.com/docker/compose-cli/cli/server/protos/context/v1;v1"; service Contexts { // Sets the current request for all calls diff --git a/protos/contexts/v1/doc.go b/cli/server/protos/contexts/v1/doc.go similarity index 100% rename from protos/contexts/v1/doc.go rename to cli/server/protos/contexts/v1/doc.go diff --git a/protos/streams/v1/streams.pb.go b/cli/server/protos/streams/v1/streams.pb.go similarity index 99% rename from protos/streams/v1/streams.pb.go rename to cli/server/protos/streams/v1/streams.pb.go index f9c54bb1..12a3b5ce 100644 --- a/protos/streams/v1/streams.pb.go +++ b/cli/server/protos/streams/v1/streams.pb.go @@ -23,6 +23,9 @@ package v1 import ( context "context" + reflect "reflect" + sync "sync" + proto "github.com/golang/protobuf/proto" any "github.com/golang/protobuf/ptypes/any" grpc "google.golang.org/grpc" @@ -30,8 +33,6 @@ import ( status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" ) const ( diff --git a/protos/streams/v1/streams.proto b/cli/server/protos/streams/v1/streams.proto similarity index 92% rename from protos/streams/v1/streams.proto rename to cli/server/protos/streams/v1/streams.proto index 8d396118..cde5b3d3 100644 --- a/protos/streams/v1/streams.proto +++ b/cli/server/protos/streams/v1/streams.proto @@ -19,7 +19,7 @@ package com.docker.api.protos.streams.v1; import "google/protobuf/any.proto"; -option go_package = "github.com/docker/compose-cli/protos/streams/v1;v1"; +option go_package = "github.com/docker/compose-cli/cli/server/protos/streams/v1;v1"; service Streaming { rpc NewStream(stream google.protobuf.Any) returns (stream google.protobuf.Any); diff --git a/protos/volumes/v1/volumes.pb.go b/cli/server/protos/volumes/v1/volumes.pb.go similarity index 99% rename from protos/volumes/v1/volumes.pb.go rename to cli/server/protos/volumes/v1/volumes.pb.go index b6b2433c..6ee4208d 100644 --- a/protos/volumes/v1/volumes.pb.go +++ b/cli/server/protos/volumes/v1/volumes.pb.go @@ -23,6 +23,9 @@ package v1 import ( context "context" + reflect "reflect" + sync "sync" + proto "github.com/golang/protobuf/proto" _ "github.com/golang/protobuf/ptypes/any" grpc "google.golang.org/grpc" @@ -30,8 +33,6 @@ import ( status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" ) const ( diff --git a/protos/volumes/v1/volumes.proto b/cli/server/protos/volumes/v1/volumes.proto similarity index 94% rename from protos/volumes/v1/volumes.proto rename to cli/server/protos/volumes/v1/volumes.proto index 6ae22e29..4048621e 100644 --- a/protos/volumes/v1/volumes.proto +++ b/cli/server/protos/volumes/v1/volumes.proto @@ -19,7 +19,7 @@ package com.docker.api.protos.volumes.v1; import "google/protobuf/any.proto"; -option go_package = "github.com/docker/compose-cli/protos/volumes/v1;v1"; +option go_package = "github.com/docker/compose-cli/cli/server/protos/volumes/v1;v1"; service Volumes { rpc VolumesCreate(VolumesCreateRequest) returns (VolumesCreateResponse); diff --git a/server/proxy/compose.go b/cli/server/proxy/compose.go similarity index 97% rename from server/proxy/compose.go rename to cli/server/proxy/compose.go index 4fa76548..edb07bcf 100644 --- a/server/proxy/compose.go +++ b/cli/server/proxy/compose.go @@ -24,7 +24,7 @@ import ( "github.com/compose-spec/compose-go/cli" "github.com/compose-spec/compose-go/types" - composev1 "github.com/docker/compose-cli/protos/compose/v1" + composev1 "github.com/docker/compose-cli/cli/server/protos/compose/v1" ) func (p *proxy) Up(ctx context.Context, request *composev1.ComposeUpRequest) (*composev1.ComposeUpResponse, error) { diff --git a/server/proxy/containers.go b/cli/server/proxy/containers.go similarity index 96% rename from server/proxy/containers.go rename to cli/server/proxy/containers.go index 03ed1386..802a0930 100644 --- a/server/proxy/containers.go +++ b/cli/server/proxy/containers.go @@ -20,14 +20,15 @@ import ( "context" "errors" + "github.com/docker/compose-cli/utils" + "github.com/compose-spec/compose-go/types" "github.com/containerd/containerd/platforms" specs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/formatter" - containersv1 "github.com/docker/compose-cli/protos/containers/v1" - "github.com/docker/compose-cli/server/proxy/streams" + containersv1 "github.com/docker/compose-cli/cli/server/protos/containers/v1" + "github.com/docker/compose-cli/cli/server/proxy/streams" ) func portsToGrpc(ports []containers.Port) []*containersv1.Port { @@ -185,7 +186,7 @@ func grpcContainerToContainerConfig(request *containersv1.RunRequest) (container Ports: ports, Labels: request.GetLabels(), Volumes: request.GetVolumes(), - MemLimit: formatter.MemBytes(request.GetMemoryLimit()), + MemLimit: utils.MemBytes(request.GetMemoryLimit()), CPULimit: float64(request.GetCpuLimit()), RestartPolicyCondition: request.RestartPolicyCondition, Environment: request.Environment, diff --git a/server/proxy/containers_test.go b/cli/server/proxy/containers_test.go similarity index 91% rename from server/proxy/containers_test.go rename to cli/server/proxy/containers_test.go index 3389c32b..701175ac 100644 --- a/server/proxy/containers_test.go +++ b/cli/server/proxy/containers_test.go @@ -19,11 +19,12 @@ package proxy import ( "testing" + "github.com/docker/compose-cli/utils" + "gotest.tools/v3/assert" "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/formatter" - containersv1 "github.com/docker/compose-cli/protos/containers/v1" + containersv1 "github.com/docker/compose-cli/cli/server/protos/containers/v1" ) func TestGrpcContainerToContainerConfig(t *testing.T) { @@ -53,7 +54,7 @@ func TestGrpcContainerToContainerConfig(t *testing.T) { assert.NilError(t, err) assert.Equal(t, cc.ID, "myId") assert.Equal(t, cc.Image, "myImage") - assert.Equal(t, cc.MemLimit, formatter.MemBytes(41)) + assert.Equal(t, cc.MemLimit, utils.MemBytes(41)) assert.Equal(t, cc.CPULimit, float64(42)) assert.DeepEqual(t, cc.Volumes, []string{"myvolume"}) assert.DeepEqual(t, cc.Ports, []containers.Port{ diff --git a/server/proxy/contexts.go b/cli/server/proxy/contexts.go similarity index 94% rename from server/proxy/contexts.go rename to cli/server/proxy/contexts.go index 10f3b3aa..dead6921 100644 --- a/server/proxy/contexts.go +++ b/cli/server/proxy/contexts.go @@ -19,9 +19,9 @@ package proxy import ( "context" - "github.com/docker/compose-cli/config" - "github.com/docker/compose-cli/context/store" - contextsv1 "github.com/docker/compose-cli/protos/contexts/v1" + "github.com/docker/compose-cli/api/config" + "github.com/docker/compose-cli/api/context/store" + contextsv1 "github.com/docker/compose-cli/cli/server/protos/contexts/v1" ) type contextsProxy struct { diff --git a/server/proxy/contexts_test.go b/cli/server/proxy/contexts_test.go similarity index 95% rename from server/proxy/contexts_test.go rename to cli/server/proxy/contexts_test.go index 567d46a2..c0542293 100644 --- a/server/proxy/contexts_test.go +++ b/cli/server/proxy/contexts_test.go @@ -21,9 +21,10 @@ import ( "gotest.tools/v3/assert" - "github.com/docker/compose-cli/context/store" - contextsv1 "github.com/docker/compose-cli/protos/contexts/v1" "github.com/google/go-cmp/cmp/cmpopts" + + "github.com/docker/compose-cli/api/context/store" + contextsv1 "github.com/docker/compose-cli/cli/server/protos/contexts/v1" ) func TestConvertContext(t *testing.T) { diff --git a/server/proxy/proxy.go b/cli/server/proxy/proxy.go similarity index 79% rename from server/proxy/proxy.go rename to cli/server/proxy/proxy.go index 89f46b6a..621b14f4 100644 --- a/server/proxy/proxy.go +++ b/cli/server/proxy/proxy.go @@ -21,13 +21,13 @@ import ( "sync" "github.com/docker/compose-cli/api/client" - "github.com/docker/compose-cli/config" - composev1 "github.com/docker/compose-cli/protos/compose/v1" - containersv1 "github.com/docker/compose-cli/protos/containers/v1" - contextsv1 "github.com/docker/compose-cli/protos/contexts/v1" - streamsv1 "github.com/docker/compose-cli/protos/streams/v1" - volumesv1 "github.com/docker/compose-cli/protos/volumes/v1" - "github.com/docker/compose-cli/server/proxy/streams" + "github.com/docker/compose-cli/api/config" + composev1 "github.com/docker/compose-cli/cli/server/protos/compose/v1" + containersv1 "github.com/docker/compose-cli/cli/server/protos/containers/v1" + contextsv1 "github.com/docker/compose-cli/cli/server/protos/contexts/v1" + streamsv1 "github.com/docker/compose-cli/cli/server/protos/streams/v1" + volumesv1 "github.com/docker/compose-cli/cli/server/protos/volumes/v1" + "github.com/docker/compose-cli/cli/server/proxy/streams" ) type clientKey struct{} diff --git a/server/proxy/streams.go b/cli/server/proxy/streams.go similarity index 91% rename from server/proxy/streams.go rename to cli/server/proxy/streams.go index dee404d3..763d61ac 100644 --- a/server/proxy/streams.go +++ b/cli/server/proxy/streams.go @@ -21,8 +21,8 @@ import ( "github.com/sirupsen/logrus" "google.golang.org/grpc/metadata" - streamsv1 "github.com/docker/compose-cli/protos/streams/v1" - "github.com/docker/compose-cli/server/proxy/streams" + streamsv1 "github.com/docker/compose-cli/cli/server/protos/streams/v1" + "github.com/docker/compose-cli/cli/server/proxy/streams" ) func (p *proxy) NewStream(stream streamsv1.Streaming_NewStreamServer) error { diff --git a/server/proxy/streams/io.go b/cli/server/proxy/streams/io.go similarity index 94% rename from server/proxy/streams/io.go rename to cli/server/proxy/streams/io.go index b7e29462..28fd6fd0 100644 --- a/server/proxy/streams/io.go +++ b/cli/server/proxy/streams/io.go @@ -19,7 +19,7 @@ package streams import ( "github.com/golang/protobuf/ptypes" - streamsv1 "github.com/docker/compose-cli/protos/streams/v1" + streamsv1 "github.com/docker/compose-cli/cli/server/protos/streams/v1" ) // IO implements an io.ReadWriter that forwards everything to the stream diff --git a/server/proxy/streams/logs.go b/cli/server/proxy/streams/logs.go similarity index 92% rename from server/proxy/streams/logs.go rename to cli/server/proxy/streams/logs.go index 58a94851..52cff554 100644 --- a/server/proxy/streams/logs.go +++ b/cli/server/proxy/streams/logs.go @@ -21,7 +21,7 @@ import ( "google.golang.org/grpc" - containersv1 "github.com/docker/compose-cli/protos/containers/v1" + containersv1 "github.com/docker/compose-cli/cli/server/protos/containers/v1" ) // Log implements an io.Writer that proxies logs over a gRPC stream diff --git a/server/proxy/streams/logs_test.go b/cli/server/proxy/streams/logs_test.go similarity index 96% rename from server/proxy/streams/logs_test.go rename to cli/server/proxy/streams/logs_test.go index 46a59e15..eaa60b23 100644 --- a/server/proxy/streams/logs_test.go +++ b/cli/server/proxy/streams/logs_test.go @@ -24,7 +24,7 @@ import ( "gotest.tools/v3/assert" "gotest.tools/v3/assert/cmp" - v1 "github.com/docker/compose-cli/protos/containers/v1" + v1 "github.com/docker/compose-cli/cli/server/protos/containers/v1" ) type logServer struct { diff --git a/server/proxy/streams/stream.go b/cli/server/proxy/streams/stream.go similarity index 93% rename from server/proxy/streams/stream.go rename to cli/server/proxy/streams/stream.go index 79d07b96..e10b3962 100644 --- a/server/proxy/streams/stream.go +++ b/cli/server/proxy/streams/stream.go @@ -19,7 +19,7 @@ package streams import ( "sync" - streamsv1 "github.com/docker/compose-cli/protos/streams/v1" + streamsv1 "github.com/docker/compose-cli/cli/server/protos/streams/v1" ) // Stream is a bidirectional stream for container IO diff --git a/server/proxy/streams/stream_test.go b/cli/server/proxy/streams/stream_test.go similarity index 97% rename from server/proxy/streams/stream_test.go rename to cli/server/proxy/streams/stream_test.go index 1bc22aa2..bb6ea0b2 100644 --- a/server/proxy/streams/stream_test.go +++ b/cli/server/proxy/streams/stream_test.go @@ -29,7 +29,7 @@ import ( "gotest.tools/v3/assert" "gotest.tools/v3/assert/cmp" - streamsv1 "github.com/docker/compose-cli/protos/streams/v1" + streamsv1 "github.com/docker/compose-cli/cli/server/protos/streams/v1" ) type byteStream struct { diff --git a/server/proxy/volumes.go b/cli/server/proxy/volumes.go similarity index 97% rename from server/proxy/volumes.go rename to cli/server/proxy/volumes.go index 6da27432..164d4151 100644 --- a/server/proxy/volumes.go +++ b/cli/server/proxy/volumes.go @@ -21,7 +21,7 @@ import ( "github.com/docker/compose-cli/aci" "github.com/docker/compose-cli/api/volumes" - volumesv1 "github.com/docker/compose-cli/protos/volumes/v1" + volumesv1 "github.com/docker/compose-cli/cli/server/protos/volumes/v1" ) // VolumesCreate creates a volume. diff --git a/server/server.go b/cli/server/server.go similarity index 97% rename from server/server.go rename to cli/server/server.go index e5adfa53..a5511af1 100644 --- a/server/server.go +++ b/cli/server/server.go @@ -25,7 +25,7 @@ import ( "google.golang.org/grpc/health" "google.golang.org/grpc/health/grpc_health_v1" - "github.com/docker/compose-cli/metrics" + "github.com/docker/compose-cli/cli/metrics" ) // New returns a new GRPC server. diff --git a/server/socket_unix.go b/cli/server/socket_unix.go similarity index 100% rename from server/socket_unix.go rename to cli/server/socket_unix.go diff --git a/server/socket_windows.go b/cli/server/socket_windows.go similarity index 100% rename from server/socket_windows.go rename to cli/server/socket_windows.go diff --git a/docs/architecture.md b/docs/architecture.md index e6910be1..e21bb3d6 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -23,6 +23,6 @@ What follows is a list of useful links to help navigate the code: * An example backend can be found in [`example/`](../example) * The API is defined by protobufs that can be found in [`protos/`](../protos) * The API server is in [`server/`](../server) -* The context management and interface can be found in [`context/`](../context) +* The context management and interface can be found in [`context/`](../api/context) * The Node SDK is autogenerated (except for default endpoints managed by Docker Desktop), and can be found in [`docker/node-sdk`](https://github.com/docker/node-sdk) \ No newline at end of file diff --git a/ecs/aws.go b/ecs/aws.go index 83156b22..80234b38 100644 --- a/ecs/aws.go +++ b/ecs/aws.go @@ -21,6 +21,7 @@ import ( "github.com/aws/aws-sdk-go/service/cloudformation" "github.com/aws/aws-sdk-go/service/ecs" + "github.com/docker/compose-cli/api/compose" "github.com/docker/compose-cli/api/secrets" ) diff --git a/ecs/awsResources.go b/ecs/awsResources.go index 0ab60146..71d9d477 100644 --- a/ecs/awsResources.go +++ b/ecs/awsResources.go @@ -23,7 +23,7 @@ import ( "strings" "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/errdefs" "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/service/elbv2" diff --git a/ecs/aws_mock.go b/ecs/aws_mock.go index 6d7ef4f6..1ed432d1 100644 --- a/ecs/aws_mock.go +++ b/ecs/aws_mock.go @@ -6,12 +6,14 @@ package ecs import ( context "context" + reflect "reflect" + cloudformation "github.com/aws/aws-sdk-go/service/cloudformation" ecs "github.com/aws/aws-sdk-go/service/ecs" + gomock "github.com/golang/mock/gomock" + compose "github.com/docker/compose-cli/api/compose" secrets "github.com/docker/compose-cli/api/secrets" - gomock "github.com/golang/mock/gomock" - reflect "reflect" ) // MockAPI is a mock of API interface diff --git a/ecs/backend.go b/ecs/backend.go index 3831ac45..bb075b4c 100644 --- a/ecs/backend.go +++ b/ecs/backend.go @@ -20,16 +20,17 @@ import ( "context" "fmt" + "github.com/docker/compose-cli/api/backend" + + "github.com/docker/compose-cli/api/cloud" "github.com/docker/compose-cli/api/compose" "github.com/docker/compose-cli/api/containers" + apicontext "github.com/docker/compose-cli/api/context" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/api/resources" "github.com/docker/compose-cli/api/secrets" "github.com/docker/compose-cli/api/volumes" - "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" - "github.com/docker/compose-cli/errdefs" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" diff --git a/ecs/cloudformation.go b/ecs/cloudformation.go index d8f6e12d..afb50358 100644 --- a/ecs/cloudformation.go +++ b/ecs/cloudformation.go @@ -24,7 +24,7 @@ import ( "strings" "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/config" + "github.com/docker/compose-cli/api/config" ecsapi "github.com/aws/aws-sdk-go/service/ecs" "github.com/aws/aws-sdk-go/service/elbv2" diff --git a/ecs/context.go b/ecs/context.go index 8c76635c..e1f43f3e 100644 --- a/ecs/context.go +++ b/ecs/context.go @@ -24,9 +24,9 @@ import ( "sort" "strings" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/errdefs" - "github.com/docker/compose-cli/prompt" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/api/errdefs" + "github.com/docker/compose-cli/utils/prompt" "github.com/AlecAivazis/survey/v2/terminal" "github.com/aws/aws-sdk-go/aws" diff --git a/ecs/context_test.go b/ecs/context_test.go index a69385e7..f196edc4 100644 --- a/ecs/context_test.go +++ b/ecs/context_test.go @@ -21,8 +21,8 @@ import ( "os" "testing" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/prompt" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/utils/prompt" "github.com/golang/mock/gomock" "gotest.tools/v3/assert" diff --git a/ecs/down.go b/ecs/down.go index 047613ad..95982989 100644 --- a/ecs/down.go +++ b/ecs/down.go @@ -21,7 +21,7 @@ import ( "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/progress" + "github.com/docker/compose-cli/api/progress" ) func (b *ecsAPIService) Down(ctx context.Context, projectName string, options compose.DownOptions) error { diff --git a/ecs/local/backend.go b/ecs/local/backend.go index 952c48ca..7d80380d 100644 --- a/ecs/local/backend.go +++ b/ecs/local/backend.go @@ -23,14 +23,14 @@ import ( "github.com/docker/docker/client" + "github.com/docker/compose-cli/api/backend" + "github.com/docker/compose-cli/api/cloud" "github.com/docker/compose-cli/api/compose" "github.com/docker/compose-cli/api/containers" + "github.com/docker/compose-cli/api/context/store" "github.com/docker/compose-cli/api/resources" "github.com/docker/compose-cli/api/secrets" "github.com/docker/compose-cli/api/volumes" - "github.com/docker/compose-cli/backend" - "github.com/docker/compose-cli/context/cloud" - "github.com/docker/compose-cli/context/store" ) const backendType = store.EcsLocalSimulationContextType diff --git a/ecs/local/compose.go b/ecs/local/compose.go index d5c9728f..b20741af 100644 --- a/ecs/local/compose.go +++ b/ecs/local/compose.go @@ -25,10 +25,11 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/compose-spec/compose-go/types" - "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/errdefs" "github.com/pkg/errors" "github.com/sanathkr/go-yaml" + + "github.com/docker/compose-cli/api/compose" + "github.com/docker/compose-cli/api/errdefs" ) func (e ecsLocalSimulation) Build(ctx context.Context, project *types.Project) error { diff --git a/ecs/local/context.go b/ecs/local/context.go index ebd71c22..c623a0f9 100644 --- a/ecs/local/context.go +++ b/ecs/local/context.go @@ -19,9 +19,9 @@ package local import ( "context" - "github.com/docker/compose-cli/context/cloud" + "github.com/docker/compose-cli/api/cloud" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/ecs" - "github.com/docker/compose-cli/errdefs" ) var _ cloud.Service = ecsLocalSimulation{} diff --git a/ecs/run.go b/ecs/run.go index 6e3f8bf9..4699ec41 100644 --- a/ecs/run.go +++ b/ecs/run.go @@ -20,8 +20,9 @@ import ( "context" "github.com/compose-spec/compose-go/types" + "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/errdefs" ) func (b *ecsAPIService) RunOneOffContainer(ctx context.Context, project *types.Project, opts compose.RunOptions) error { diff --git a/ecs/sdk.go b/ecs/sdk.go index 1c9fa57d..92a2b3f2 100644 --- a/ecs/sdk.go +++ b/ecs/sdk.go @@ -25,8 +25,8 @@ import ( "time" "github.com/docker/compose-cli/api/compose" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/api/secrets" - "github.com/docker/compose-cli/errdefs" "github.com/docker/compose-cli/internal" "github.com/aws/aws-sdk-go/aws" diff --git a/ecs/tags.go b/ecs/tags.go index 01dead2f..6e7206ee 100644 --- a/ecs/tags.go +++ b/ecs/tags.go @@ -19,6 +19,7 @@ package ecs import ( "github.com/awslabs/goformation/v4/cloudformation/tags" "github.com/compose-spec/compose-go/types" + "github.com/docker/compose-cli/api/compose" ) diff --git a/ecs/up.go b/ecs/up.go index a47f7adb..6a71b1bf 100644 --- a/ecs/up.go +++ b/ecs/up.go @@ -26,7 +26,7 @@ import ( "github.com/sirupsen/logrus" "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/errdefs" "github.com/compose-spec/compose-go/types" ) diff --git a/ecs/volumes.go b/ecs/volumes.go index 81aefe73..df1a296f 100644 --- a/ecs/volumes.go +++ b/ecs/volumes.go @@ -21,8 +21,8 @@ import ( "fmt" "github.com/docker/compose-cli/api/compose" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/api/volumes" - "github.com/docker/compose-cli/errdefs" "github.com/awslabs/goformation/v4/cloudformation" "github.com/awslabs/goformation/v4/cloudformation/efs" diff --git a/ecs/wait.go b/ecs/wait.go index 183c5954..3d3e7069 100644 --- a/ecs/wait.go +++ b/ecs/wait.go @@ -26,7 +26,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/iancoleman/strcase" - "github.com/docker/compose-cli/progress" + "github.com/docker/compose-cli/api/progress" ) func (b *ecsAPIService) WaitStackCompletion(ctx context.Context, name string, operation int, ignored ...string) error { //nolint:gocyclo diff --git a/example/backend.go b/example/backend.go index 58cf7a6c..94427fda 100644 --- a/example/backend.go +++ b/example/backend.go @@ -23,14 +23,14 @@ import ( "errors" "fmt" + "github.com/docker/compose-cli/api/backend" + "github.com/docker/compose-cli/api/cloud" "github.com/docker/compose-cli/api/compose" "github.com/docker/compose-cli/api/containers" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/api/resources" "github.com/docker/compose-cli/api/secrets" "github.com/docker/compose-cli/api/volumes" - "github.com/docker/compose-cli/backend" - "github.com/docker/compose-cli/context/cloud" - "github.com/docker/compose-cli/errdefs" "github.com/compose-spec/compose-go/types" ) diff --git a/import-restrictions.yaml b/import-restrictions.yaml index 7b344557..6e03d903 100644 --- a/import-restrictions.yaml +++ b/import-restrictions.yaml @@ -5,29 +5,21 @@ - github.com/docker/compose-cli/ecs - github.com/docker/compose-cli/example - github.com/docker/compose-cli/local - - github.com/docker/compose-cli/metrics - - github.com/docker/compose-cli/server - path: ./ecs forbiddenImports: - github.com/docker/compose-cli/aci - github.com/docker/compose-cli/cli - github.com/docker/compose-cli/example - github.com/docker/compose-cli/local - - github.com/docker/compose-cli/metrics - - github.com/docker/compose-cli/server - path: ./example forbiddenImports: - github.com/docker/compose-cli/aci - github.com/docker/compose-cli/cli - github.com/docker/compose-cli/ecs - github.com/docker/compose-cli/local - - github.com/docker/compose-cli/metrics - - github.com/docker/compose-cli/server - path: ./local forbiddenImports: - github.com/docker/compose-cli/aci - github.com/docker/compose-cli/cli - github.com/docker/compose-cli/ecs - github.com/docker/compose-cli/example - - github.com/docker/compose-cli/metrics - - github.com/docker/compose-cli/server diff --git a/local/backend.go b/local/backend.go index 8e25d8b5..0e5ea277 100644 --- a/local/backend.go +++ b/local/backend.go @@ -21,13 +21,13 @@ import ( "github.com/docker/docker/client" + "github.com/docker/compose-cli/api/backend" + "github.com/docker/compose-cli/api/cloud" "github.com/docker/compose-cli/api/compose" "github.com/docker/compose-cli/api/containers" "github.com/docker/compose-cli/api/resources" "github.com/docker/compose-cli/api/secrets" "github.com/docker/compose-cli/api/volumes" - "github.com/docker/compose-cli/backend" - "github.com/docker/compose-cli/context/cloud" local_compose "github.com/docker/compose-cli/local/compose" ) diff --git a/local/compose/compose.go b/local/compose/compose.go index 88cb6fc4..894db8fe 100644 --- a/local/compose/compose.go +++ b/local/compose/compose.go @@ -29,7 +29,7 @@ import ( "github.com/docker/docker/client" "github.com/sanathkr/go-yaml" - errdefs2 "github.com/docker/compose-cli/errdefs" + errdefs2 "github.com/docker/compose-cli/api/errdefs" ) // NewComposeService create a local implementation of the compose.Service API diff --git a/local/compose/convergence.go b/local/compose/convergence.go index 0402cc5f..f5f98e2a 100644 --- a/local/compose/convergence.go +++ b/local/compose/convergence.go @@ -28,8 +28,8 @@ import ( "github.com/docker/docker/api/types/network" "golang.org/x/sync/errgroup" + "github.com/docker/compose-cli/api/progress" status "github.com/docker/compose-cli/local/moby" - "github.com/docker/compose-cli/progress" ) const ( diff --git a/local/compose/create.go b/local/compose/create.go index 575c18ca..84ea697d 100644 --- a/local/compose/create.go +++ b/local/compose/create.go @@ -38,8 +38,8 @@ import ( "golang.org/x/sync/errgroup" "github.com/docker/compose-cli/api/compose" + "github.com/docker/compose-cli/api/progress" convert "github.com/docker/compose-cli/local/moby" - "github.com/docker/compose-cli/progress" ) func (s *composeService) Create(ctx context.Context, project *types.Project, opts compose.CreateOptions) error { diff --git a/local/compose/down.go b/local/compose/down.go index bd699ae6..b104194c 100644 --- a/local/compose/down.go +++ b/local/compose/down.go @@ -23,7 +23,7 @@ import ( "github.com/docker/compose-cli/api/compose" - "github.com/docker/compose-cli/progress" + "github.com/docker/compose-cli/api/progress" "github.com/compose-spec/compose-go/cli" "github.com/compose-spec/compose-go/types" diff --git a/local/compose/pull.go b/local/compose/pull.go index 133056cd..caf75b08 100644 --- a/local/compose/pull.go +++ b/local/compose/pull.go @@ -32,8 +32,8 @@ import ( "github.com/docker/docker/registry" "golang.org/x/sync/errgroup" - "github.com/docker/compose-cli/config" - "github.com/docker/compose-cli/progress" + "github.com/docker/compose-cli/api/config" + "github.com/docker/compose-cli/api/progress" ) func (s *composeService) Pull(ctx context.Context, project *types.Project) error { diff --git a/local/compose/push.go b/local/compose/push.go index 351c1c01..934b2e9e 100644 --- a/local/compose/push.go +++ b/local/compose/push.go @@ -25,8 +25,8 @@ import ( "github.com/docker/buildx/driver" - "github.com/docker/compose-cli/config" - "github.com/docker/compose-cli/progress" + "github.com/docker/compose-cli/api/config" + "github.com/docker/compose-cli/api/progress" "github.com/compose-spec/compose-go/types" cliconfig "github.com/docker/cli/cli/config" diff --git a/local/containers.go b/local/containers.go index 3c6d7e6b..e3e72d25 100644 --- a/local/containers.go +++ b/local/containers.go @@ -34,7 +34,7 @@ import ( "github.com/pkg/errors" "github.com/docker/compose-cli/api/containers" - "github.com/docker/compose-cli/errdefs" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/local/moby" ) diff --git a/tests/aci-e2e/e2e-aci_test.go b/tests/aci-e2e/e2e-aci_test.go index 3bcdea55..0ac81b97 100644 --- a/tests/aci-e2e/e2e-aci_test.go +++ b/tests/aci-e2e/e2e-aci_test.go @@ -51,9 +51,9 @@ import ( "github.com/docker/compose-cli/aci/convert" "github.com/docker/compose-cli/aci/login" "github.com/docker/compose-cli/api/containers" + "github.com/docker/compose-cli/api/context/store" + "github.com/docker/compose-cli/api/errdefs" "github.com/docker/compose-cli/cli/cmd" - "github.com/docker/compose-cli/context/store" - "github.com/docker/compose-cli/errdefs" . "github.com/docker/compose-cli/tests/framework" ) diff --git a/tests/framework/unit.go b/tests/framework/unit.go index d2c8dc14..6f37d63d 100644 --- a/tests/framework/unit.go +++ b/tests/framework/unit.go @@ -20,13 +20,6 @@ import ( "context" "io/ioutil" "os" - "testing" - - "gotest.tools/v3/assert" - "gotest.tools/v3/assert/cmp" - - apicontext "github.com/docker/compose-cli/context" - "github.com/docker/compose-cli/context/store" ) // TestCLI is a helper struct for CLI tests. @@ -36,33 +29,6 @@ type TestCLI struct { reader *os.File } -// NewTestCLI returns a CLI testing helper. -func NewTestCLI(t *testing.T) *TestCLI { - dir, err := ioutil.TempDir("", "store") - assert.Check(t, cmp.Nil(err)) - - originalStdout := os.Stdout - - t.Cleanup(func() { - os.Stdout = originalStdout - _ = os.RemoveAll(dir) - }) - - s, err := store.New(dir) - assert.Check(t, cmp.Nil(err)) - err = s.Create("example", "example", "", store.ContextMetadata{}) - assert.Check(t, cmp.Nil(err)) - - ctx := context.Background() - ctx = store.WithContextStore(ctx, s) - ctx = apicontext.WithCurrentContext(ctx, "example") - - r, w, err := os.Pipe() - os.Stdout = w - assert.Check(t, cmp.Nil(err)) - return &TestCLI{ctx, w, r} -} - // Context returns a configured context func (c *TestCLI) Context() context.Context { return c.ctx diff --git a/prompt/prompt.go b/utils/prompt/prompt.go similarity index 100% rename from prompt/prompt.go rename to utils/prompt/prompt.go diff --git a/prompt/prompt_mock.go b/utils/prompt/prompt_mock.go similarity index 99% rename from prompt/prompt_mock.go rename to utils/prompt/prompt_mock.go index 06886e0f..b2f2ea7c 100644 --- a/prompt/prompt_mock.go +++ b/utils/prompt/prompt_mock.go @@ -5,8 +5,9 @@ package prompt import ( - gomock "github.com/golang/mock/gomock" reflect "reflect" + + gomock "github.com/golang/mock/gomock" ) // MockUI is a mock of UI interface diff --git a/formatter/units.go b/utils/units.go similarity index 98% rename from formatter/units.go rename to utils/units.go index d26902cd..401dddbe 100644 --- a/formatter/units.go +++ b/utils/units.go @@ -14,7 +14,7 @@ limitations under the License. */ -package formatter +package utils import ( "github.com/docker/go-units" diff --git a/formatter/units_test.go b/utils/units_test.go similarity index 98% rename from formatter/units_test.go rename to utils/units_test.go index ea21a210..2e35e11b 100644 --- a/formatter/units_test.go +++ b/utils/units_test.go @@ -14,7 +14,7 @@ limitations under the License. */ -package formatter +package utils import ( "testing"