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

Commit 447b9e2

Browse files
committed
Remove platform flag for push
Signed-off-by: Yves Brissaud <yves.brissaud@docker.com>
1 parent 7c4126b commit 447b9e2

4 files changed

Lines changed: 2 additions & 157 deletions

File tree

Gopkg.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/pushpull_test.go

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"testing"
1111

1212
"github.com/docker/cnab-to-oci/converter"
13-
"github.com/docker/distribution/manifest/manifestlist"
1413
"github.com/opencontainers/go-digest"
1514
v1 "github.com/opencontainers/image-spec/specs-go/v1"
1615
"gotest.tools/assert"
@@ -26,97 +25,6 @@ type dindSwarmAndRegistryInfo struct {
2625
registryLogs func() string
2726
}
2827

29-
func TestPushArchs(t *testing.T) {
30-
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
31-
testCases := []struct {
32-
name string
33-
args []string
34-
expectedPlatforms []manifestlist.PlatformSpec
35-
}{
36-
{
37-
name: "default",
38-
args: []string{},
39-
expectedPlatforms: []manifestlist.PlatformSpec{
40-
{
41-
OS: "linux",
42-
Architecture: "amd64",
43-
},
44-
},
45-
},
46-
{
47-
name: "all-platforms",
48-
args: []string{"--all-platforms"},
49-
expectedPlatforms: []manifestlist.PlatformSpec{
50-
{
51-
OS: "linux",
52-
Architecture: "amd64",
53-
},
54-
{
55-
OS: "linux",
56-
Architecture: "386",
57-
},
58-
{
59-
OS: "linux",
60-
Architecture: "ppc64le",
61-
},
62-
{
63-
OS: "linux",
64-
Architecture: "s390x",
65-
},
66-
{
67-
OS: "linux",
68-
Architecture: "arm",
69-
Variant: "v5",
70-
},
71-
{
72-
OS: "linux",
73-
Architecture: "arm",
74-
Variant: "v6",
75-
},
76-
{
77-
OS: "linux",
78-
Architecture: "arm",
79-
Variant: "v7",
80-
},
81-
{
82-
OS: "linux",
83-
Architecture: "arm64",
84-
Variant: "v8",
85-
},
86-
},
87-
},
88-
}
89-
90-
for _, testCase := range testCases {
91-
t.Run(testCase.name, func(t *testing.T) {
92-
cmd := info.configuredCmd
93-
ref := info.registryAddress + "/test/push-pull:1"
94-
args := []string{"app", "push", "--tag", ref}
95-
args = append(args, testCase.args...)
96-
args = append(args, filepath.Join("testdata", "push-pull", "push-pull.dockerapp"))
97-
cmd.Command = dockerCli.Command(args...)
98-
icmd.RunCmd(cmd).Assert(t, icmd.Success)
99-
100-
var index v1.Index
101-
headers := map[string]string{
102-
"Accept": "application/vnd.docker.distribution.manifest.list.v2+json",
103-
}
104-
err := httpGet("http://"+info.registryAddress+"/v2/test/push-pull/manifests/1", headers, &index)
105-
assert.NilError(t, err, info.registryLogs())
106-
digest, err := getManifestListDigest(index)
107-
assert.NilError(t, err, info.registryLogs())
108-
var manifestList manifestlist.ManifestList
109-
err = httpGet("http://"+info.registryAddress+"/v2/test/push-pull/manifests/"+digest.String(), headers, &manifestList)
110-
assert.NilError(t, err)
111-
assert.Equal(t, len(manifestList.Manifests), len(testCase.expectedPlatforms), "Unexpected number of platforms")
112-
for _, m := range manifestList.Manifests {
113-
assert.Assert(t, cmp.Contains(testCase.expectedPlatforms, m.Platform), "Platform expected but not found: %s", m.Platform)
114-
}
115-
})
116-
}
117-
})
118-
}
119-
12028
func TestPushInsecureRegistry(t *testing.T) {
12129
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
12230
ref := info.registryAddress + "/test/push-insecure"

internal/commands/push.go

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"github.com/pkg/errors"
2424
"github.com/sirupsen/logrus"
2525
"github.com/spf13/cobra"
26-
"github.com/spf13/pflag"
2726
)
2827

2928
const ( // Docker specific annotations and values
@@ -40,8 +39,6 @@ const ( // Docker specific annotations and values
4039

4140
type pushOptions struct {
4241
tag string
43-
platforms []string
44-
allPlatforms bool
4542
}
4643

4744
func pushCmd(dockerCli command.Cli) *cobra.Command {
@@ -51,17 +48,12 @@ func pushCmd(dockerCli command.Cli) *cobra.Command {
5148
Short: "Push an App image to a registry",
5249
Example: `$ docker app push myapp --tag myrepo/myapp:mytag`,
5350
Args: cli.RequiresMaxArgs(1),
54-
PreRunE: func(cmd *cobra.Command, args []string) error {
55-
return checkFlags(cmd.Flags(), opts)
56-
},
5751
RunE: func(cmd *cobra.Command, args []string) error {
5852
return runPush(dockerCli, firstOrEmpty(args), opts)
5953
},
6054
}
6155
flags := cmd.Flags()
6256
flags.StringVarP(&opts.tag, "tag", "t", "", "Target registry reference (default: <name>:<version> from metadata)")
63-
flags.StringSliceVar(&opts.platforms, "platform", []string{"linux/amd64"}, "For multi-arch service images, push the specified platforms")
64-
flags.BoolVar(&opts.allPlatforms, "all-platforms", false, "If present, push all platforms")
6557
return cmd
6658
}
6759

@@ -80,7 +72,7 @@ func runPush(dockerCli command.Cli, name string, opts pushOptions) error {
8072
cnabRef = reference.TagNameOnly(cnabRef)
8173

8274
// Push the bundle
83-
return pushBundle(dockerCli, opts, bndl, cnabRef)
75+
return pushBundle(dockerCli, bndl, cnabRef)
8476
}
8577

8678
func resolveReferenceAndBundle(dockerCli command.Cli, name string) (*bundle.Bundle, string, error) {
@@ -99,7 +91,7 @@ func resolveReferenceAndBundle(dockerCli command.Cli, name string) (*bundle.Bund
9991
return bndl, ref, err
10092
}
10193

102-
func pushBundle(dockerCli command.Cli, opts pushOptions, bndl *bundle.Bundle, cnabRef reference.Named) error {
94+
func pushBundle(dockerCli command.Cli, bndl *bundle.Bundle, cnabRef reference.Named) error {
10395
insecureRegistries, err := internal.InsecureRegistriesFromEngine(dockerCli)
10496
if err != nil {
10597
return errors.Wrap(err, "could not retrieve insecure registries")
@@ -114,9 +106,6 @@ func pushBundle(dockerCli command.Cli, opts pushOptions, bndl *bundle.Bundle, cn
114106
remotes.WithAutoBundleUpdate(),
115107
remotes.WithPushImages(dockerCli.Client(), dockerCli.Out()),
116108
}
117-
if platforms := platformFilter(opts); len(platforms) > 0 {
118-
fixupOptions = append(fixupOptions, remotes.WithComponentImagePlatforms(platforms))
119-
}
120109
// bundle fixup
121110
relocationMap, err := remotes.FixupBundle(context.Background(), bndl, cnabRef, resolver, fixupOptions...)
122111
if err != nil {
@@ -141,13 +130,6 @@ func withAppAnnotations(index *ocischemav1.Index) error {
141130
return nil
142131
}
143132

144-
func platformFilter(opts pushOptions) []string {
145-
if opts.allPlatforms {
146-
return nil
147-
}
148-
return opts.platforms
149-
}
150-
151133
type fixupDisplay interface {
152134
onEvent(remotes.FixupEvent)
153135
}
@@ -276,10 +258,3 @@ func (r *plainDisplay) onEvent(ev remotes.FixupEvent) {
276258
}
277259
}
278260
}
279-
280-
func checkFlags(flags *pflag.FlagSet, opts pushOptions) error {
281-
if opts.allPlatforms && flags.Changed("all-platforms") && flags.Changed("platform") {
282-
return fmt.Errorf("--all-plaforms and --plaform flags cannot be used at the same time")
283-
}
284-
return nil
285-
}

internal/commands/push_test.go

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

0 commit comments

Comments
 (0)