浏览代码

Move formatter => cli/formatter. Needed to move formatter.MemBytes => utils.MemBytes (helper class on memory display)

Signed-off-by: Guillaume Tardif <[email protected]>
Guillaume Tardif 4 年之前
父节点
当前提交
fe39267e3a

+ 2 - 2
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

+ 1 - 1
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 {

+ 1 - 1
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 {

+ 1 - 1
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 {

+ 1 - 1
cli/cmd/compose/up.go

@@ -26,7 +26,7 @@ import (
 	"github.com/docker/compose-cli/api/compose"
 	"github.com/docker/compose-cli/api/context/store"
 	"github.com/docker/compose-cli/api/progress"
-	"github.com/docker/compose-cli/formatter"
+	"github.com/docker/compose-cli/cli/formatter"
 
 	"github.com/compose-spec/compose-go/cli"
 	"github.com/compose-spec/compose-go/types"

+ 1 - 1
cli/cmd/context/ls.go

@@ -28,8 +28,8 @@ import (
 
 	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"
-	"github.com/docker/compose-cli/formatter"
 )
 
 type lsOpts struct {

+ 1 - 1
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

+ 1 - 1
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"
 )
 

+ 1 - 1
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

+ 1 - 1
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"
 )
 

+ 1 - 1
cli/cmd/volume/command.go

@@ -25,8 +25,8 @@ import (
 	"github.com/docker/compose-cli/api/context/store"
 	"github.com/docker/compose-cli/api/progress"
 	"github.com/docker/compose-cli/cli/formatter"
+	formatter2 "github.com/docker/compose-cli/cli/formatter"
 	"github.com/docker/compose-cli/ecs"
-	formatter2 "github.com/docker/compose-cli/formatter"
 
 	"github.com/hashicorp/go-multierror"
 	"github.com/spf13/cobra"

+ 1 - 1
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 {

+ 0 - 0
formatter/colors.go → cli/formatter/colors.go


+ 0 - 0
formatter/consts.go → cli/formatter/consts.go


+ 0 - 0
formatter/formatter.go → cli/formatter/formatter.go


+ 0 - 0
formatter/formatter_test.go → cli/formatter/formatter_test.go


+ 0 - 0
formatter/json.go → cli/formatter/json.go


+ 0 - 0
formatter/logs.go → cli/formatter/logs.go


+ 0 - 0
formatter/pretty.go → cli/formatter/pretty.go


+ 3 - 2
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

+ 3 - 2
cli/server/proxy/containers.go

@@ -20,6 +20,8 @@ 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"
@@ -27,7 +29,6 @@ import (
 	"github.com/docker/compose-cli/api/containers"
 	containersv1 "github.com/docker/compose-cli/cli/server/protos/containers/v1"
 	"github.com/docker/compose-cli/cli/server/proxy/streams"
-	"github.com/docker/compose-cli/formatter"
 )
 
 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,

+ 3 - 2
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"
 	containersv1 "github.com/docker/compose-cli/cli/server/protos/containers/v1"
-	"github.com/docker/compose-cli/formatter"
 )
 
 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{

+ 1 - 1
formatter/units.go → utils/units.go

@@ -14,7 +14,7 @@
    limitations under the License.
 */
 
-package formatter
+package utils
 
 import (
 	"github.com/docker/go-units"

+ 1 - 1
formatter/units_test.go → utils/units_test.go

@@ -14,7 +14,7 @@
    limitations under the License.
 */
 
-package formatter
+package utils
 
 import (
 	"testing"