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

Commit 68accf3

Browse files
committed
Only push applications from the local store
`cnab.ResolveBundle` would try the local store first and pull if the app is not found. This is not what we want when we push. We only want to push local applications. Signed-off-by: Djordje Lukic <[email protected]>
1 parent 080e680 commit 68accf3

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

internal/commands/push.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
"github.com/containerd/containerd/platforms"
1515
"github.com/docker/app/internal"
16-
"github.com/docker/app/internal/cnab"
1716
"github.com/docker/app/internal/log"
1817
"github.com/docker/cli/cli"
1918
"github.com/docker/cli/cli/command"
@@ -53,37 +52,40 @@ func pushCmd(dockerCli command.Cli) *cobra.Command {
5352
}
5453

5554
func runPush(dockerCli command.Cli, name string) error {
55+
defer muteDockerCli(dockerCli)()
5656
bundleStore, err := prepareBundleStore()
5757
if err != nil {
5858
return err
5959
}
6060

61-
defer muteDockerCli(dockerCli)()
6261
// Get the bundle
63-
bndl, ref, err := resolveReferenceAndBundle(dockerCli, bundleStore, name)
62+
ref, err := reference.ParseDockerRef(name)
6463
if err != nil {
65-
return err
64+
return errors.Wrapf(err, "could not push %q", name)
6665
}
6766

68-
cnabRef, err := reference.ParseNormalizedNamed(ref)
67+
bndl, err := resolveReferenceAndBundle(bundleStore, ref)
6968
if err != nil {
7069
return err
7170
}
72-
cnabRef = reference.TagNameOnly(cnabRef)
71+
72+
cnabRef := reference.TagNameOnly(ref)
7373

7474
// Push the bundle
7575
return pushBundle(dockerCli, bndl, cnabRef)
7676
}
7777

78-
func resolveReferenceAndBundle(dockerCli command.Cli, bundleStore store.BundleStore, name string) (*relocated.Bundle, string, error) {
79-
bndl, ref, err := cnab.ResolveBundle(dockerCli, bundleStore, name)
78+
func resolveReferenceAndBundle(bundleStore store.BundleStore, ref reference.Reference) (*relocated.Bundle, error) {
79+
bndl, err := bundleStore.Read(ref)
8080
if err != nil {
81-
return nil, "", err
81+
return nil, errors.Wrapf(err, "could not push %q: no such App image", reference.FamiliarString(ref))
8282
}
83+
8384
if err := bndl.Validate(); err != nil {
84-
return nil, "", err
85+
return nil, err
8586
}
86-
return bndl, ref, err
87+
88+
return bndl, err
8789
}
8890

8991
func pushBundle(dockerCli command.Cli, bndl *relocated.Bundle, cnabRef reference.Named) error {

0 commit comments

Comments
 (0)