Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
352 changes: 250 additions & 102 deletions Gopkg.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ required = ["github.com/wadey/gocovmerge"]
name = "github.com/opencontainers/runc"
version = "v1.0.0-rc5"

[[constraint]]
[[override]]
name = "github.com/docker/cli"
branch = "master"
source = "https://github.com/ijc/docker-cli"
version = "plugins.wip20190129"

[[constraint]]
name = "github.com/sirupsen/logrus"
Expand All @@ -53,7 +54,7 @@ required = ["github.com/wadey/gocovmerge"]

[[override]]
name = "github.com/docker/docker"
revision = "53e55db9d3f0f0910ea95515222c8a35e106f10e"
revision = "0b7cb16dde4a20d024c7be59801d63bcfd18611b"

[[override]]
name = "github.com/docker/distribution"
Expand Down Expand Up @@ -81,7 +82,7 @@ required = ["github.com/wadey/gocovmerge"]

[[override]]
name = "google.golang.org/grpc"
revision = "v1.3.0"
revision = "v1.12.0"

# This is using a fork waiting for go-yaml/yaml#375 to be merged
# This PR allows to set a max decoded value, thus not being exposed to yaml bombs
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-app/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func runDeploy(dockerCli command.Cli, flags *pflag.FlagSet, appname string, opts
return err
}
defer app.Cleanup()
deployOrchestrator, err := command.GetStackOrchestrator(opts.deployOrchestrator, dockerCli.ConfigFile().StackOrchestrator, dockerCli.Err())
deployOrchestrator, err := command.GetStackOrchestrator(opts.deployOrchestrator, "", dockerCli.ConfigFile().StackOrchestrator, dockerCli.Err())
if err != nil {
return err
}
Expand Down
24 changes: 11 additions & 13 deletions cmd/docker-app/main.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package main

import (
"os"

"github.com/docker/app/internal"
"github.com/docker/cli/cli-plugins/manager"
"github.com/docker/cli/cli-plugins/plugin"
"github.com/docker/cli/cli/command"
"github.com/docker/docker/pkg/term"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

func main() {
// Set terminal emulation based on platform as required.
stdin, stdout, stderr := term.StdStreams()
logrus.SetOutput(stderr)

dockerCli := command.NewDockerCli(stdin, stdout, stderr, false, nil)
cmd := newRootCmd(dockerCli)
if err := cmd.Execute(); err != nil {
os.Exit(1)
}
plugin.Run(func(dockerCli command.Cli) *cobra.Command {
return newRootCmd(dockerCli)
}, manager.Metadata{
SchemaVersion: "0.1.0",
Vendor: "Docker Inc.",
Version: internal.Version,
})
}
43 changes: 4 additions & 39 deletions cmd/docker-app/root.go
Original file line number Diff line number Diff line change
@@ -1,42 +1,19 @@
package main

import (
"fmt"

"github.com/docker/app/internal"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
cliconfig "github.com/docker/cli/cli/config"
"github.com/docker/cli/cli/debug"
cliflags "github.com/docker/cli/cli/flags"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

// rootCmd represents the base command when called without any subcommands
// FIXME(vdemeester) use command.Cli interface
func newRootCmd(dockerCli *command.DockerCli) *cobra.Command {
opts := cliflags.NewClientOptions()
var flags *pflag.FlagSet

func newRootCmd(dockerCli command.Cli) *cobra.Command {
cmd := &cobra.Command{
Use: "docker-app",
Short: "Docker Application Packages",
Long: `Build and deploy Docker Application Packages.`,
SilenceUsage: true,
TraverseChildren: true,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
opts.Common.SetDefaultOptions(flags)
dockerPreRun(opts)
return dockerCli.Initialize(opts)
},
Version: fmt.Sprintf("%s, build %s", internal.Version, internal.GitCommit),
Use: "app",
Short: "Docker Application Packages",
Long: `Build and deploy Docker Application Packages.`,
}
cli.SetupRootCommand(cmd)
flags = cmd.Flags()
flags.BoolP("version", "v", false, "Print version information")
opts.Common.InstallFlags(flags)
cmd.SetVersionTemplate("docker-app version {{.Version}}\n")
addCommands(cmd, dockerCli)
return cmd
}
Expand Down Expand Up @@ -72,15 +49,3 @@ func firstOrEmpty(list []string) string {
}
return ""
}

func dockerPreRun(opts *cliflags.ClientOptions) {
cliflags.SetLogLevel(opts.Common.LogLevel)

if opts.ConfigDir != "" {
cliconfig.SetDir(opts.ConfigDir)
}

if opts.Common.Debug {
debug.Enable()
}
}
68 changes: 34 additions & 34 deletions e2e/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func testRenderApp(appPath string, env ...string) func(*testing.T) {
data, err := ioutil.ReadFile(filepath.Join(appPath, "env.yml"))
assert.NilError(t, err)
assert.NilError(t, yaml.Unmarshal(data, &envParameters))
args := []string{dockerApp, "render", filepath.Join(appPath, "my.dockerapp"),
args := []string{dockerApp, "app", "render", filepath.Join(appPath, "my.dockerapp"),
"-f", filepath.Join(appPath, "parameters-0.yml"),
}
for k, v := range envParameters {
Expand All @@ -79,10 +79,10 @@ func testRenderApp(appPath string, env ...string) func(*testing.T) {

func TestRenderFormatters(t *testing.T) {
appPath := filepath.Join("testdata", "simple", "simple.dockerapp")
result := icmd.RunCommand(dockerApp, "render", "--formatter", "json", appPath).Assert(t, icmd.Success)
result := icmd.RunCommand(dockerApp, "app", "render", "--formatter", "json", appPath).Assert(t, icmd.Success)
assert.Assert(t, golden.String(result.Stdout(), "expected-json-render.golden"))

result = icmd.RunCommand(dockerApp, "render", "--formatter", "yaml", appPath).Assert(t, icmd.Success)
result = icmd.RunCommand(dockerApp, "app", "render", "--formatter", "yaml", appPath).Assert(t, icmd.Success)
assert.Assert(t, golden.String(result.Stdout(), "expected-yaml-render.golden"))
}

Expand Down Expand Up @@ -119,7 +119,7 @@ maintainers:
dirName := internal.DirNameFromAppName(testAppName)
defer os.RemoveAll(dirName)

icmd.RunCommand(dockerApp, "init", testAppName,
icmd.RunCommand(dockerApp, "app", "init", testAppName,
"-c", dir.Join(internal.ComposeFileName),
"-d", "my cool app",
"-m", "bob",
Expand All @@ -135,10 +135,10 @@ maintainers:
assert.Assert(t, fs.Equal(dirName, manifest))

// validate metadata with JSON Schema
icmd.RunCommand(dockerApp, "validate", testAppName).Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "validate", testAppName).Assert(t, icmd.Success)

// test single-file init
icmd.RunCommand(dockerApp, "init", "tac",
icmd.RunCommand(dockerApp, "app", "init", "tac",
"-c", dir.Join(internal.ComposeFileName),
"-d", "my cool app",
"-m", "bob",
Expand All @@ -150,8 +150,8 @@ maintainers:
assert.NilError(t, err)
assert.Assert(t, golden.Bytes(appData, "init-singlefile.dockerapp"))
// Check various commands work on single-file app package
icmd.RunCommand(dockerApp, "inspect", "tac").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "render", "tac").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "inspect", "tac").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "render", "tac").Assert(t, icmd.Success)
}

func TestDetectApp(t *testing.T) {
Expand All @@ -165,19 +165,19 @@ func TestDetectApp(t *testing.T) {
)
defer dir.Remove()
icmd.RunCmd(icmd.Cmd{
Command: []string{dockerApp, "inspect"},
Command: []string{dockerApp, "app", "inspect"},
Dir: dir.Path(),
}).Assert(t, icmd.Success)
icmd.RunCmd(icmd.Cmd{
Command: []string{dockerApp, "inspect"},
Command: []string{dockerApp, "app", "inspect"},
Dir: dir.Join("attachments.dockerapp"),
}).Assert(t, icmd.Success)
icmd.RunCmd(icmd.Cmd{
Command: []string{dockerApp, "inspect", "."},
Command: []string{dockerApp, "app", "inspect", "."},
Dir: dir.Join("attachments.dockerapp"),
}).Assert(t, icmd.Success)
result := icmd.RunCmd(icmd.Cmd{
Command: []string{dockerApp, "inspect"},
Command: []string{dockerApp, "app", "inspect"},
Dir: dir.Join("render"),
})
result.Assert(t, icmd.Expected{
Expand All @@ -191,42 +191,42 @@ func TestPack(t *testing.T) {
tempDir, err := ioutil.TempDir("", "dockerapp")
assert.NilError(t, err)
defer os.RemoveAll(tempDir)
icmd.RunCommand(dockerApp, "pack", "testdata/attachments", "-o", filepath.Join(tempDir, "test.dockerapp")).Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "pack", "testdata/attachments", "-o", filepath.Join(tempDir, "test.dockerapp")).Assert(t, icmd.Success)
// check that our commands run on the packed version
icmd.RunCommand(dockerApp, "inspect", filepath.Join(tempDir, "test")).Assert(t, icmd.Expected{
icmd.RunCommand(dockerApp, "app", "inspect", filepath.Join(tempDir, "test")).Assert(t, icmd.Expected{
Out: "myapp",
})
icmd.RunCommand(dockerApp, "render", filepath.Join(tempDir, "test")).Assert(t, icmd.Expected{
icmd.RunCommand(dockerApp, "app", "render", filepath.Join(tempDir, "test")).Assert(t, icmd.Expected{
Out: "nginx",
})
assert.NilError(t, os.Mkdir(filepath.Join(tempDir, "output"), 0755))
icmd.RunCmd(icmd.Cmd{
Command: []string{dockerApp, "unpack", "test", "-o", "output"},
Command: []string{dockerApp, "app", "unpack", "test", "-o", "output"},
Dir: tempDir,
}).Assert(t, icmd.Success)
_, err = os.Stat(filepath.Join(tempDir, "output", "test.dockerapp", "docker-compose.yml"))
assert.NilError(t, err)
}

func TestSplitMerge(t *testing.T) {
icmd.RunCommand(dockerApp, "merge", "testdata/render/envvariables/my.dockerapp", "-o", "remerged.dockerapp").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "merge", "testdata/render/envvariables/my.dockerapp", "-o", "remerged.dockerapp").Assert(t, icmd.Success)
defer os.Remove("remerged.dockerapp")
// test that inspect works on single-file
result := icmd.RunCommand(dockerApp, "inspect", "remerged").Assert(t, icmd.Success)
result := icmd.RunCommand(dockerApp, "app", "inspect", "remerged").Assert(t, icmd.Success)
assert.Assert(t, golden.String(result.Combined(), "envvariables-inspect.golden"))
// split it
icmd.RunCommand(dockerApp, "split", "remerged", "-o", "split.dockerapp").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "split", "remerged", "-o", "split.dockerapp").Assert(t, icmd.Success)
defer os.RemoveAll("split.dockerapp")
result = icmd.RunCommand(dockerApp, "inspect", "remerged").Assert(t, icmd.Success)
result = icmd.RunCommand(dockerApp, "app", "inspect", "remerged").Assert(t, icmd.Success)
assert.Assert(t, golden.String(result.Combined(), "envvariables-inspect.golden"))
// test inplace
icmd.RunCommand(dockerApp, "merge", "split").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "split", "split").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "merge", "split").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "split", "split").Assert(t, icmd.Success)
}

func TestURL(t *testing.T) {
url := "https://raw.githubusercontent.com/docker/app/v0.4.1/examples/hello-world/hello-world.dockerapp"
result := icmd.RunCommand(dockerApp, "inspect", url).Assert(t, icmd.Success)
result := icmd.RunCommand(dockerApp, "app", "inspect", url).Assert(t, icmd.Success)
assert.Assert(t, golden.String(result.Combined(), "helloworld-inspect.golden"))
}

Expand All @@ -235,20 +235,20 @@ func TestWithRegistry(t *testing.T) {
defer r.Stop(t)
registry := r.GetAddress(t)
// push to a registry
icmd.RunCommand(dockerApp, "push", "--namespace", registry+"/myuser", "testdata/render/envvariables/my.dockerapp").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "push", "--namespace", registry+"/myuser", "-t", "latest", "testdata/render/envvariables/my.dockerapp").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "inspect", registry+"/myuser/my.dockerapp:0.1.0").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "inspect", registry+"/myuser/my.dockerapp").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "inspect", registry+"/myuser/my").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "inspect", registry+"/myuser/my:0.1.0").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "push", "--namespace", registry+"/myuser", "testdata/render/envvariables/my.dockerapp").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "push", "--namespace", registry+"/myuser", "-t", "latest", "testdata/render/envvariables/my.dockerapp").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "inspect", registry+"/myuser/my.dockerapp:0.1.0").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "inspect", registry+"/myuser/my.dockerapp").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "inspect", registry+"/myuser/my").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "inspect", registry+"/myuser/my:0.1.0").Assert(t, icmd.Success)
// push a single-file app to a registry
dir := fs.NewDir(t, "save-prepare-build", fs.WithFile("my.dockerapp", singleFileApp))
defer dir.Remove()
icmd.RunCommand(dockerApp, "push", "--namespace", registry+"/myuser", dir.Join("my.dockerapp")).Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "push", "--namespace", registry+"/myuser", dir.Join("my.dockerapp")).Assert(t, icmd.Success)

// push with custom repo name
icmd.RunCommand(dockerApp, "push", "-t", "marshmallows", "--namespace", registry+"/rainbows", "--repo", "unicorns", "testdata/render/envvariables/my.dockerapp").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "inspect", registry+"/rainbows/unicorns:marshmallows").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "push", "-t", "marshmallows", "--namespace", registry+"/rainbows", "--repo", "unicorns", "testdata/render/envvariables/my.dockerapp").Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "inspect", registry+"/rainbows/unicorns:marshmallows").Assert(t, icmd.Success)
}

func TestAttachmentsWithRegistry(t *testing.T) {
Expand All @@ -261,10 +261,10 @@ func TestAttachmentsWithRegistry(t *testing.T) {
)
defer dir.Remove()

icmd.RunCommand(dockerApp, "push", "--namespace", registry+"/acmecorp", dir.Join("attachments.dockerapp")).Assert(t, icmd.Success)
icmd.RunCommand(dockerApp, "app", "push", "--namespace", registry+"/acmecorp", dir.Join("attachments.dockerapp")).Assert(t, icmd.Success)

// inspect will run the core pull code too
result := icmd.RunCommand(dockerApp, "inspect", registry+"/acmecorp/attachments.dockerapp:0.1.0")
result := icmd.RunCommand(dockerApp, "app", "inspect", registry+"/acmecorp/attachments.dockerapp:0.1.0")

result.Assert(t, icmd.Success)
resultOutput := result.Combined()
Expand Down
2 changes: 1 addition & 1 deletion e2e/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestExamplesAreValid(t *testing.T) {
case !info.IsDir():
return nil
default:
result := icmd.RunCommand(dockerApp, "validate", filepath.Join(p, filepath.Base(p)+".dockerapp"))
result := icmd.RunCommand(dockerApp, "app", "validate", filepath.Join(p, filepath.Base(p)+".dockerapp"))
result.Assert(t, icmd.Success)
return filepath.SkipDir
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestMain(m *testing.M) {
if err != nil {
panic(err)
}
cmd := exec.Command(dockerApp, "version")
cmd := exec.Command(dockerApp, "app", "version")
output, err := cmd.CombinedOutput()
if err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion internal/packager/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func findApp() (string, error) {
for _, c := range content {
if strings.HasSuffix(c.Name(), internal.AppExtension) {
if hit != "" {
return "", fmt.Errorf("multiple applications found in current directory, specify the application name on the command line")
return "", fmt.Errorf("Error: multiple applications found in current directory, specify the application name on the command line")
}
hit = c.Name()
}
Expand Down
15 changes: 15 additions & 0 deletions vendor/cloud.google.com/go/AUTHORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions vendor/cloud.google.com/go/CONTRIBUTORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading