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

Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
Guillaume Tardif 2021-01-15 16:45:27 +01:00
parent 0ea97920c1
commit fe39267e3a
24 changed files with 24 additions and 21 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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"

View File

@ -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 {

View File

@ -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

View File

@ -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"
)

View File

@ -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

View File

@ -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"
)

View File

@ -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"

View File

@ -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 {

View File

@ -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

View File

@ -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,

View File

@ -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{

View File

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

View File

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