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

Commit 6f5737a

Browse files
Merge pull request #724 from jcsirot/app-render-image-only
render command renders App image only
2 parents 38bedc0 + c2f76a8 commit 6f5737a

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

e2e/commands_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ func testRenderApp(appPath string, env ...string) func(*testing.T) {
4848
dir := fs.NewDir(t, "")
4949
defer dir.Remove()
5050

51+
// Build the App
52+
cmd.Command = dockerCli.Command("app", "build", ".", "--folder", filepath.Join(appPath, "my.dockerapp"), "--tag", "a-simple-tag", "--no-resolve-image")
53+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
54+
55+
// Render the App
5156
envParameters := map[string]string{}
5257
data, err := ioutil.ReadFile(filepath.Join(appPath, "env.yml"))
5358
assert.NilError(t, err)
5459
assert.NilError(t, yaml.Unmarshal(data, &envParameters))
55-
args := dockerCli.Command("app", "render", filepath.Join(appPath, "my.dockerapp"), "--parameters-file", filepath.Join(appPath, "parameters-0.yml"))
60+
args := dockerCli.Command("app", "render", "a-simple-tag", "--parameters-file", filepath.Join(appPath, "parameters-0.yml"))
5661
for k, v := range envParameters {
5762
args = append(args, "--set", fmt.Sprintf("%s=%s", k, v))
5863
}
@@ -70,6 +75,16 @@ func testRenderApp(appPath string, env ...string) func(*testing.T) {
7075
}
7176
}
7277

78+
func TestRenderAppNotFound(t *testing.T) {
79+
cmd, cleanup := dockerCli.createTestCmd()
80+
defer cleanup()
81+
82+
appName := "non_existing_app:some_tag"
83+
cmd.Command = dockerCli.Command("app", "render", appName)
84+
checkContains(t, icmd.RunCmd(cmd).Assert(t, icmd.Expected{ExitCode: 1}).Combined(),
85+
[]string{fmt.Sprintf("could not render %q: no such App image", appName)})
86+
}
87+
7388
func TestRenderFormatters(t *testing.T) {
7489
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
7590
cmd := info.configuredCmd

e2e/envfile_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ func TestRenderWithEnvFile(t *testing.T) {
1212
defer cleanup()
1313
appPath := filepath.Join("testdata", "envfile", "envfile.dockerapp")
1414

15-
cmd.Command = dockerCli.Command("app", "render", appPath)
15+
cmd.Command = dockerCli.Command("app", "build", "-f", appPath, "--tag", "a-simple-tag", "--no-resolve-image", ".")
16+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
17+
18+
cmd.Command = dockerCli.Command("app", "render", "a-simple-tag")
1619
icmd.RunCmd(cmd).Assert(t, icmd.Expected{Out: `version: "3.7"
1720
services:
1821
db:

internal/commands/render.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/docker/cli/cli"
1414
"github.com/docker/cli/cli/command"
1515
"github.com/docker/cli/cli/config"
16+
"github.com/pkg/errors"
1617
"github.com/spf13/cobra"
1718
)
1819

@@ -28,10 +29,10 @@ func renderCmd(dockerCli command.Cli) *cobra.Command {
2829
Use: "render [OPTIONS] APP_IMAGE",
2930
Short: "Render the Compose file for an App image",
3031
Example: `$ docker app render myrepo/myapp:1.0.0 --set key=value --parameters-file myparam.yml`,
31-
Args: cli.RequiresMaxArgs(1),
32+
Args: cli.ExactArgs(1),
3233
Hidden: true,
3334
RunE: func(cmd *cobra.Command, args []string) error {
34-
return runRender(dockerCli, firstOrEmpty(args), opts)
35+
return runRender(dockerCli, args[0], opts)
3536
},
3637
}
3738
opts.parametersOptions.addFlags(cmd.Flags())
@@ -75,11 +76,11 @@ func prepareCustomAction(actionName string, dockerCli command.Cli, appname strin
7576
if err != nil {
7677
return nil, nil, nil, err
7778
}
78-
bundle, ref, err := cnab.ResolveBundle(dockerCli, bundleStore, appname)
79+
bundle, ref, err := cnab.GetBundle(dockerCli, bundleStore, appname)
7980
if err != nil {
80-
return nil, nil, nil, err
81+
return nil, nil, nil, errors.Wrapf(err, "could not render %q: no such App image", appname)
8182
}
82-
installation, err := appstore.NewInstallation("custom-action", ref)
83+
installation, err := appstore.NewInstallation("custom-action", ref.String())
8384
if err != nil {
8485
return nil, nil, nil, err
8586
}

0 commit comments

Comments
 (0)