Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

render command renders App image only #724

Merged
merged 3 commits into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion e2e/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ func testRenderApp(appPath string, env ...string) func(*testing.T) {
dir := fs.NewDir(t, "")
defer dir.Remove()

// Build the App
cmd.Command = dockerCli.Command("app", "build", ".", "--folder", filepath.Join(appPath, "my.dockerapp"), "--tag", "a-simple-tag", "--no-resolve-image")
icmd.RunCmd(cmd).Assert(t, icmd.Success)

// Render the App
envParameters := map[string]string{}
data, err := ioutil.ReadFile(filepath.Join(appPath, "env.yml"))
assert.NilError(t, err)
assert.NilError(t, yaml.Unmarshal(data, &envParameters))
args := dockerCli.Command("app", "render", filepath.Join(appPath, "my.dockerapp"), "--parameters-file", filepath.Join(appPath, "parameters-0.yml"))
args := dockerCli.Command("app", "render", "a-simple-tag", "--parameters-file", filepath.Join(appPath, "parameters-0.yml"))
for k, v := range envParameters {
args = append(args, "--set", fmt.Sprintf("%s=%s", k, v))
}
Expand All @@ -70,6 +75,16 @@ func testRenderApp(appPath string, env ...string) func(*testing.T) {
}
}

func TestRenderAppNotFound(t *testing.T) {
cmd, cleanup := dockerCli.createTestCmd()
defer cleanup()

appName := "non_existing_app:some_tag"
cmd.Command = dockerCli.Command("app", "render", appName)
checkContains(t, icmd.RunCmd(cmd).Assert(t, icmd.Expected{ExitCode: 1}).Combined(),
[]string{fmt.Sprintf("could not render %q: no such App image", appName)})
}

func TestRenderFormatters(t *testing.T) {
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) {
cmd := info.configuredCmd
Expand Down
5 changes: 4 additions & 1 deletion e2e/envfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ func TestRenderWithEnvFile(t *testing.T) {
defer cleanup()
appPath := filepath.Join("testdata", "envfile", "envfile.dockerapp")

cmd.Command = dockerCli.Command("app", "render", appPath)
cmd.Command = dockerCli.Command("app", "build", "-f", appPath, "--tag", "a-simple-tag", "--no-resolve-image", ".")
icmd.RunCmd(cmd).Assert(t, icmd.Success)

cmd.Command = dockerCli.Command("app", "render", "a-simple-tag")
icmd.RunCmd(cmd).Assert(t, icmd.Expected{Out: `version: "3.7"
services:
db:
Expand Down
11 changes: 6 additions & 5 deletions internal/commands/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/config"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)

Expand All @@ -28,10 +29,10 @@ func renderCmd(dockerCli command.Cli) *cobra.Command {
Use: "render [OPTIONS] APP_IMAGE",
Short: "Render the Compose file for an App image",
Example: `$ docker app render myrepo/myapp:1.0.0 --set key=value --parameters-file myparam.yml`,
Args: cli.RequiresMaxArgs(1),
Args: cli.ExactArgs(1),
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runRender(dockerCli, firstOrEmpty(args), opts)
return runRender(dockerCli, args[0], opts)
},
}
opts.parametersOptions.addFlags(cmd.Flags())
Expand Down Expand Up @@ -75,11 +76,11 @@ func prepareCustomAction(actionName string, dockerCli command.Cli, appname strin
if err != nil {
return nil, nil, nil, err
}
bundle, ref, err := cnab.ResolveBundle(dockerCli, bundleStore, appname)
bundle, ref, err := cnab.GetBundle(dockerCli, bundleStore, appname)
if err != nil {
return nil, nil, nil, err
return nil, nil, nil, errors.Wrapf(err, "could not render %q: no such App image", appname)
}
installation, err := appstore.NewInstallation("custom-action", ref)
installation, err := appstore.NewInstallation("custom-action", ref.String())
if err != nil {
return nil, nil, nil, err
}
Expand Down