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

Commit 4e4ff4b

Browse files
Fix pushing a pre-bundled app from the bundle store shouldn't require an explicit tag.
The push was using the default value (app name + version) as a repo and tag, fixed using the bundle reference. Signed-off-by: Silvin Lubecki <[email protected]>
1 parent a804fb0 commit 4e4ff4b

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

e2e/pushpull_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,27 @@ func TestPushInstallBundle(t *testing.T) {
269269
cmd.Command = dockerCli.Command("service", "ls")
270270
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref2))
271271
})
272+
273+
// push it again using an app pre-bundled and tagged in the bundle store and install it to check it is also available
274+
t.Run("push-bundleref", func(t *testing.T) {
275+
name := strings.Replace(t.Name(), "/", "_", 1)
276+
ref2 := ref + ":v0.42"
277+
// Create a new command so the bundle store can be trashed before installing the app
278+
cmd2, cleanup2 := dockerCli.createTestCmd()
279+
// bundle the app again but this time with a tag to store it into the bundle store
280+
cmd2.Command = dockerCli.Command("app", "bundle", "--tag", ref2, "-o", bundleFile, filepath.Join("testdata", "push-pull", "push-pull.dockerapp"))
281+
icmd.RunCmd(cmd2).Assert(t, icmd.Success)
282+
// Push the app without tagging it explicitly
283+
cmd2.Command = dockerCli.Command("app", "push", "--insecure-registries="+info.registryAddress, ref2)
284+
icmd.RunCmd(cmd2).Assert(t, icmd.Success)
285+
// remove the bundle from the bundle store to be sure it won't be used instead of registry
286+
cleanup2()
287+
// install from the registry
288+
cmd.Command = dockerCli.Command("app", "install", "--insecure-registries="+info.registryAddress, ref2, "--name", name)
289+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
290+
cmd.Command = dockerCli.Command("service", "ls")
291+
assert.Check(t, cmp.Contains(icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined(), ref))
292+
})
272293
})
273294
}
274295

internal/commands/cnab.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ func extractAndLoadAppBasedBundle(dockerCli command.Cli, name string) (*bundle.B
251251
return bndl, "", err
252252
}
253253

254+
//resolveBundle looks for a CNAB bundle which can be in a Docker App Package format or
255+
// a bundle stored locally or in the bundle store. It returns a built or found bundle,
256+
// a reference to the bundle if it is found in the bundlestore, and an error.
254257
func resolveBundle(dockerCli command.Cli, bundleStore appstore.BundleStore, name string, pullRef bool, insecureRegistries []string) (*bundle.Bundle, string, error) {
255258
// resolution logic:
256259
// - if there is a docker-app package in working directory, or an http:// / https:// prefix, use packager.Extract result

internal/commands/push.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,14 @@ func runPush(dockerCli command.Cli, name string, opts pushOptions) error {
7878
return err
7979
}
8080

81-
bndl, _, err := resolveBundle(dockerCli, bundleStore, name, false, nil)
81+
bndl, ref, err := resolveBundle(dockerCli, bundleStore, name, false, nil)
8282
if err != nil {
8383
return err
8484
}
85+
// Use the bundle reference as a tag
86+
if ref != "" && opts.tag == "" {
87+
opts.tag = ref
88+
}
8589
if err := bndl.Validate(); err != nil {
8690
return err
8791
}

0 commit comments

Comments
 (0)