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

Commit c2f76a8

Browse files
author
Jean-Christophe Sirot
committed
Fix error handling and message when the App to render does not exist
Signed-off-by: Jean-Christophe Sirot <[email protected]>
1 parent 7263c18 commit c2f76a8

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

e2e/commands_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,14 @@ func testRenderApp(appPath string, env ...string) func(*testing.T) {
7575
}
7676
}
7777

78-
func TestRenderAppDirectoryFails(t *testing.T) {
78+
func TestRenderAppNotFound(t *testing.T) {
7979
cmd, cleanup := dockerCli.createTestCmd()
8080
defer cleanup()
81-
appPath := filepath.Join("testdata", "envfile", "envfile.dockerapp")
8281

83-
cmd.Command = dockerCli.Command("app", "render", appPath)
84-
icmd.RunCmd(cmd).Assert(t, icmd.Expected{
85-
ExitCode: 1,
86-
Err: fmt.Sprintf("%q looks like a docker App directory and App must be built first before rendering", appPath),
87-
})
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)})
8886
}
8987

9088
func TestRenderFormatters(t *testing.T) {

internal/commands/render.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"io"
77
"os"
8-
"strings"
98

109
"github.com/deislabs/cnab-go/action"
1110
"github.com/docker/app/internal"
@@ -14,6 +13,7 @@ import (
1413
"github.com/docker/cli/cli"
1514
"github.com/docker/cli/cli/command"
1615
"github.com/docker/cli/cli/config"
16+
"github.com/pkg/errors"
1717
"github.com/spf13/cobra"
1818
)
1919

@@ -78,10 +78,7 @@ func prepareCustomAction(actionName string, dockerCli command.Cli, appname strin
7878
}
7979
bundle, ref, err := cnab.GetBundle(dockerCli, bundleStore, appname)
8080
if err != nil {
81-
if strings.HasSuffix(appname, ".dockerapp") {
82-
return nil, nil, nil, fmt.Errorf("%q looks like a docker App directory and App must be built first before rendering", appname)
83-
}
84-
return nil, nil, nil, err
81+
return nil, nil, nil, errors.Wrapf(err, "could not render %q: no such App image", appname)
8582
}
8683
installation, err := appstore.NewInstallation("custom-action", ref.String())
8784
if err != nil {

0 commit comments

Comments
 (0)