Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit dc7422e

Browse files
committed
Merge remote-tracking branch 'upstream/main' into error-on-unsupported-flags
2 parents fa7e063 + 3d8ba52 commit dc7422e

File tree

8 files changed

+28
-128
lines changed

8 files changed

+28
-128
lines changed

cmd/compose/down.go

Lines changed: 0 additions & 94 deletions
This file was deleted.

ecs/cloudformation.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ import (
3838
"github.com/compose-spec/compose-go/types"
3939
"github.com/distribution/distribution/v3/reference"
4040
cliconfig "github.com/docker/cli/cli/config"
41+
"github.com/docker/compose-cli/api/config"
4142
"github.com/docker/compose-cli/utils"
4243
"github.com/docker/compose/v2/pkg/api"
4344
"github.com/opencontainers/go-digest"
4445
"sigs.k8s.io/kustomize/kyaml/yaml"
4546
"sigs.k8s.io/kustomize/kyaml/yaml/merge2"
46-
47-
"github.com/docker/compose-cli/api/config"
4847
)
4948

5049
func (b *ecsAPIService) Convert(ctx context.Context, project *types.Project, options api.ConvertOptions) ([]byte, error) {

ecs/ps.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,5 @@ func (b *ecsAPIService) Ps(ctx context.Context, projectName string, options api.
6363
}
6464

6565
func checkUnsupportedPsOptions(o api.PsOptions) error {
66-
var errs error
67-
errs = utils.CheckUnsupported(errs, o.All, false, "ps", "all")
68-
return errs
66+
return utils.CheckUnsupported(nil, o.All, false, "ps", "all")
6967
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ require (
1919
github.com/awslabs/goformation/v4 v4.15.6
2020
github.com/buger/goterm v1.0.0
2121
github.com/cnabio/cnab-to-oci v0.3.1-beta1
22-
github.com/compose-spec/compose-go v0.0.0-20210906143156-938b039f7805
22+
github.com/compose-spec/compose-go v0.0.0-20210916141509-a7e1bc322970
2323
github.com/containerd/console v1.0.2
2424
github.com/containerd/containerd v1.5.4
2525
github.com/distribution/distribution/v3 v3.0.0-20210316161203-a01c71e2477e
2626
github.com/docker/cli v20.10.7+incompatible
27-
github.com/docker/compose/v2 v2.0.0-rc.3.0.20210916150857-15cd03448553
27+
github.com/docker/compose/v2 v2.0.0-rc.3.0.20210917090141-18059295f76e
2828
github.com/docker/docker v20.10.7+incompatible
2929
github.com/docker/go-connections v0.4.0
3030
github.com/docker/go-units v0.4.0

go.sum

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,9 @@ github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnht
255255
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
256256
github.com/codahale/hdrhistogram v0.0.0-20160425231609-f8ad88b59a58/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
257257
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
258-
github.com/compose-spec/compose-go v0.0.0-20210906143156-938b039f7805 h1:iFShT4oPik+NnXdzksa4yLvJYDDZBPMjHPN3qtJaXPA=
259258
github.com/compose-spec/compose-go v0.0.0-20210906143156-938b039f7805/go.mod h1:Hnmn5ZCVA3sSBN2urjCZNNIyNqCPayRGH7PmMSaV2Q0=
259+
github.com/compose-spec/compose-go v0.0.0-20210916141509-a7e1bc322970 h1:HJ3V4Wwayx8uVMdcxurMauknQQkuIYhAnFIqUBLQ+po=
260+
github.com/compose-spec/compose-go v0.0.0-20210916141509-a7e1bc322970/go.mod h1:Hnmn5ZCVA3sSBN2urjCZNNIyNqCPayRGH7PmMSaV2Q0=
260261
github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE=
261262
github.com/containerd/aufs v0.0.0-20201003224125-76a6863f2989/go.mod h1:AkGGQs9NM2vtYHaUen+NljV0/baGCAPELGm2q9ZXpWU=
262263
github.com/containerd/aufs v0.0.0-20210316121734-20793ff83c97/go.mod h1:kL5kd6KM5TzQjR79jljyi4olc1Vrx6XBlcyj3gNv2PU=
@@ -414,8 +415,8 @@ github.com/docker/cli v20.10.7+incompatible h1:pv/3NqibQKphWZiAskMzdz8w0PRbtTaEB
414415
github.com/docker/cli v20.10.7+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
415416
github.com/docker/cli-docs-tool v0.1.1/go.mod h1:oMzPNt1wC3TcxuY22GMnOODNOxkwGH51gV3AhqAjFQ4=
416417
github.com/docker/compose-on-kubernetes v0.4.19-0.20190128150448-356b2919c496/go.mod h1:iT2pYfi580XlpaV4KmK0T6+4/9+XoKmk/fhoDod1emE=
417-
github.com/docker/compose/v2 v2.0.0-rc.3.0.20210916150857-15cd03448553 h1:uv/kMiCOXbCaFR8vn6pISh50pPWo01rCeSHVxBXGVes=
418-
github.com/docker/compose/v2 v2.0.0-rc.3.0.20210916150857-15cd03448553/go.mod h1:1ElTlmGxnapGk1DF8EscG9uozzScMMBn3wkDeiQCE5k=
418+
github.com/docker/compose/v2 v2.0.0-rc.3.0.20210917090141-18059295f76e h1:prL1r0VoYZmQyEJmy/4q4GITkBOZDM531/qPqBFN3fI=
419+
github.com/docker/compose/v2 v2.0.0-rc.3.0.20210917090141-18059295f76e/go.mod h1:1ElTlmGxnapGk1DF8EscG9uozzScMMBn3wkDeiQCE5k=
419420
github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY=
420421
github.com/docker/distribution v2.6.0-rc.1.0.20180327202408-83389a148052+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
421422
github.com/docker/distribution v2.7.0+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=

kube/compose.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -356,17 +356,9 @@ func (s *composeService) Exec(ctx context.Context, project *types.Project, opts
356356

357357
func checkUnsupportedExecOptions(o api.RunOptions) error {
358358
var errs error
359-
checks := []struct {
360-
toCheck, expected interface{}
361-
option string
362-
}{
363-
{o.Index, 0, "index"},
364-
{o.Privileged, false, "privileged"},
365-
{o.WorkingDir, "", "workdir"},
366-
}
367-
for _, c := range checks {
368-
errs = utils.CheckUnsupported(errs, c.toCheck, c.expected, "exec", c.option)
369-
}
359+
errs = utils.CheckUnsupported(errs, o.Index, 0, "exec", "index")
360+
errs = utils.CheckUnsupported(errs, o.Privileged, false, "exec", "privileged")
361+
errs = utils.CheckUnsupported(errs, o.WorkingDir, "", "exec", "workdir")
370362
return errs
371363
}
372364

utils/check.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@ package utils
1919
import (
2020
"fmt"
2121
"strings"
22-
"time"
2322

2423
"github.com/docker/compose-cli/api/context/store"
2524
"github.com/docker/compose-cli/cli/config"
25+
"github.com/docker/compose/v2/pkg/api"
2626
"github.com/hashicorp/go-multierror"
2727
"github.com/pkg/errors"
2828
)
2929

30-
var ErrUnsupportedFlag = errors.New("unsupported flag")
31-
3230
func CheckUnsupported(errs error, toCheck, expectedValue interface{}, commandName, msg string) error {
3331
ctype := store.DefaultContextType
3432
currentContext := config.GetCurrentContext("", config.ConfDir(), nil)
@@ -43,16 +41,9 @@ func CheckUnsupported(errs error, toCheck, expectedValue interface{}, commandNam
4341
if cc != nil {
4442
ctype = cc.Type()
4543
}
46-
// Fixes type for posterior comparison
47-
switch toCheck.(type) {
48-
case *time.Duration:
49-
if expectedValue == nil {
50-
var nilDurationPtr *time.Duration
51-
expectedValue = nilDurationPtr
52-
}
53-
}
54-
if toCheck != expectedValue {
55-
return multierror.Append(errs, errors.Wrap(ErrUnsupportedFlag,
44+
45+
if !(isNil(toCheck) && isNil(expectedValue)) && toCheck != expectedValue {
46+
return multierror.Append(errs, errors.Wrap(api.ErrUnsupportedFlag,
5647
fmt.Sprintf(`option "%s --%s" on context type %s.`,
5748
commandName, msg, strings.ToUpper(ctype))))
5849
}

utils/units.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package utils
1818

1919
import (
20+
"reflect"
21+
2022
"github.com/docker/go-units"
2123
)
2224

@@ -50,3 +52,14 @@ func (m *MemBytes) Type() string {
5052
func (m *MemBytes) Value() int64 {
5153
return int64(*m)
5254
}
55+
56+
func isNil(i interface{}) bool {
57+
if i == nil {
58+
return true
59+
}
60+
switch reflect.TypeOf(i).Kind() {
61+
case reflect.Ptr, reflect.Map, reflect.Array, reflect.Chan, reflect.Slice:
62+
return reflect.ValueOf(i).IsNil()
63+
}
64+
return false
65+
}

0 commit comments

Comments
 (0)