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

Commit c9eb813

Browse files
author
Ulysses Souza
authored
Merge pull request #608 from ndeloof/nosingle
Remove support for "single file" app definition
2 parents 93626e0 + be84671 commit c9eb813

36 files changed

+52
-638
lines changed

README.md

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ With `docker app` [installed](#installation) let's create an Application Package
4040
based on this Compose file:
4141

4242
```console
43-
$ docker app init --single-file hello
43+
$ docker app init hello
4444
$ ls
4545
docker-compose.yml
4646
hello.dockerapp
4747
```
4848

49-
We created a new file `hello.dockerapp` that contains three YAML documents:
49+
We created a new folder `hello.dockerapp` that contains three YAML documents:
5050
- metadata
5151
- the Compose file
5252
- parameters for your application
@@ -60,22 +60,19 @@ description: A simple text server
6060
maintainers:
6161
- name: yourusername
6262
email:
63+
```
6364

64-
---
65+
```yaml
6566
version: '3.2'
6667
services:
6768
hello:
6869
image: hashicorp/http-echo
6970
command: ["-text", "hello world"]
7071
ports:
7172
- 5678:5678
72-
73-
---
74-
{}
7573
```
7674

77-
Let's edit the parameters section and add the following default values for our
78-
application:
75+
And an empty `parameters.yml. Let's edit and add the following default values for our applicatoin
7976

8077
```yaml
8178
port: 5678
@@ -287,19 +284,6 @@ New-Item -ItemType Directory -Path ~/.docker/cli-plugins -ErrorAction SilentlyCo
287284
cp docker-app-plugin-windows.exe ~/.docker/cli-plugins/docker-app.exe
288285
```
289286

290-
## Single file or directory representation
291-
292-
If you prefer having the three core documents in separate YAML files, omit the
293-
`--single-file` option to the `docker app init` command. This will create a
294-
directory instead of a single file, containing `metadata.yml`,
295-
`docker-compose.yml` and `parameters.yml`.
296-
297-
Converting between the two formats can be achieved by using the
298-
`docker app split` and `docker app merge` commands.
299-
300-
**Note**: You cannot store attachments in the single file format. If you want to
301-
use attachments you should use the directory format.
302-
303287
## Attachments (Storing additional files)
304288

305289
If you want to store additional files in the application package, such as
@@ -374,11 +358,9 @@ Commands:
374358
inspect Shows metadata, parameters and a summary of the Compose file for a given application
375359
install Install an application
376360
list List the installations and their last known installation result
377-
merge Merge a directory format Docker Application definition into a single file
378361
pull Pull an application package from a registry
379362
push Push an application package to a registry
380363
render Render the Compose file for an Application Package
381-
split Split a single-file Docker Application definition into the directory format
382364
status Get the installation status of an application
383365
uninstall Uninstall an application
384366
upgrade Upgrade an installed application

e2e/commands_test.go

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package e2e
22

33
import (
4-
"bytes"
54
"encoding/json"
65
"fmt"
76
"io/ioutil"
8-
"path"
97
"path/filepath"
108
"regexp"
119
"strings"
@@ -130,27 +128,6 @@ maintainers:
130128
cmd.Command = dockerCli.Command("app", "validate", testAppName)
131129
stdOut = icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined()
132130
golden.Assert(t, stdOut, "validate-output.golden")
133-
134-
// test single-file init
135-
cmd.Command = dockerCli.Command("app",
136-
"init", "myapp",
137-
"--compose-file", tmpDir.Join(internal.ComposeFileName),
138-
"--description", "some description",
139-
"--maintainer", "dev1",
140-
"--maintainer", "dev2:[email protected]",
141-
"--single-file",
142-
)
143-
icmd.RunCmd(cmd).Assert(t, icmd.Success)
144-
145-
appData, err := ioutil.ReadFile(tmpDir.Join("myapp.dockerapp"))
146-
assert.NilError(t, err)
147-
golden.Assert(t, string(appData), "init-singlefile.dockerapp")
148-
// Check various commands work on single-file app package
149-
cmd.Command = dockerCli.Command("app", "inspect", "myapp")
150-
icmd.RunCmd(cmd).Assert(t, icmd.Success)
151-
152-
cmd.Command = dockerCli.Command("app", "render", "myapp")
153-
icmd.RunCmd(cmd).Assert(t, icmd.Success)
154131
}
155132

156133
func TestDetectApp(t *testing.T) {
@@ -187,82 +164,6 @@ func TestDetectApp(t *testing.T) {
187164
})
188165
}
189166

190-
func patchEndOfLine(t *testing.T, eol []byte, name, fromDir, toDir string) {
191-
buf := golden.Get(t, filepath.Join(fromDir, name))
192-
bytes.ReplaceAll(buf, []byte{'\n'}, eol)
193-
assert.NilError(t, ioutil.WriteFile(filepath.Join(toDir, name), buf, 0644))
194-
}
195-
196-
func TestSplitMerge(t *testing.T) {
197-
testCases := []struct {
198-
name string
199-
lineEnding []byte
200-
}{
201-
{
202-
name: "without-crlf",
203-
lineEnding: []byte{'\n'},
204-
},
205-
{
206-
name: "with-crlf",
207-
lineEnding: []byte{'\r', '\n'},
208-
},
209-
}
210-
for _, test := range testCases {
211-
t.Run(test.name, func(t *testing.T) {
212-
cmd, cleanup := dockerCli.createTestCmd()
213-
defer cleanup()
214-
215-
tmpDir := fs.NewDir(t, "split_merge", fs.WithDir("my.dockerapp"))
216-
defer tmpDir.Remove()
217-
218-
inputDir := filepath.Join("render", "envvariables", "my.dockerapp")
219-
testDataDir := tmpDir.Join("my.dockerapp")
220-
221-
// replace the line ending from the versioned test data files and put them to a temp dir
222-
for _, name := range internal.FileNames {
223-
patchEndOfLine(t, test.lineEnding, name, inputDir, testDataDir)
224-
}
225-
226-
// Merge a multi-files app to a single-file app
227-
cmd.Command = dockerCli.Command("app", "merge", testDataDir, "--output", tmpDir.Join("remerged.dockerapp"))
228-
icmd.RunCmd(cmd).Assert(t, icmd.Success)
229-
230-
cmd.Dir = tmpDir.Path()
231-
232-
// test that inspect works on single-file
233-
cmd.Command = dockerCli.Command("app", "inspect", "remerged")
234-
result := icmd.RunCmd(cmd).Assert(t, icmd.Success)
235-
golden.Assert(t, result.Combined(), "envvariables-inspect.golden")
236-
237-
// split it
238-
cmd.Command = dockerCli.Command("app", "split", "remerged", "--output", "split.dockerapp")
239-
icmd.RunCmd(cmd).Assert(t, icmd.Success)
240-
241-
// test that inspect still works
242-
cmd.Command = dockerCli.Command("app", "inspect", "remerged")
243-
result = icmd.RunCmd(cmd).Assert(t, icmd.Success)
244-
golden.Assert(t, result.Combined(), "envvariables-inspect.golden")
245-
246-
// the split app must be the same as the original one
247-
manifest := fs.Expected(
248-
t,
249-
fs.WithMode(0755),
250-
fs.WithFile(internal.MetadataFileName, string(golden.Get(t, path.Join(testDataDir, internal.MetadataFileName))), fs.WithMode(0644)),
251-
fs.WithFile(internal.ComposeFileName, string(golden.Get(t, path.Join(testDataDir, internal.ComposeFileName))), fs.WithMode(0644)),
252-
fs.WithFile(internal.ParametersFileName, string(golden.Get(t, path.Join(testDataDir, internal.ParametersFileName))), fs.WithMode(0644)),
253-
)
254-
assert.Assert(t, fs.Equal(tmpDir.Join("split.dockerapp"), manifest))
255-
256-
// test inplace
257-
cmd.Command = dockerCli.Command("app", "merge", "split")
258-
icmd.RunCmd(cmd).Assert(t, icmd.Success)
259-
260-
cmd.Command = dockerCli.Command("app", "split", "split")
261-
icmd.RunCmd(cmd).Assert(t, icmd.Success)
262-
})
263-
}
264-
}
265-
266167
func TestBundle(t *testing.T) {
267168
cmd, cleanup := dockerCli.createTestCmd()
268169
defer cleanup()

e2e/testdata/plugin-usage-experimental.golden

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ Commands:
99
inspect Shows metadata, parameters and a summary of the Compose file for a given application
1010
install Install an application
1111
list List the installations and their last known installation result
12-
merge Merge a directory format Docker Application definition into a single file
1312
pull Pull an application package from a registry
1413
push Push an application package to a registry
1514
render Render the Compose file for an Application Package
16-
split Split a single-file Docker Application definition into the directory format
1715
status Get the installation status of an application
1816
uninstall Uninstall an application
1917
upgrade Upgrade an installed application

e2e/testdata/plugin-usage.golden

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ Commands:
99
inspect Shows metadata, parameters and a summary of the Compose file for a given application
1010
install Install an application
1111
list List the installations and their last known installation result
12-
merge Merge a directory format Docker Application definition into a single file
1312
pull Pull an application package from a registry
1413
push Push an application package to a registry
1514
render Render the Compose file for an Application Package
16-
split Split a single-file Docker Application definition into the directory format
1715
status Get the installation status of an application
1816
uninstall Uninstall an application
1917
upgrade Upgrade an installed application

e2e/testdata/render/singlefile/env.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

e2e/testdata/render/singlefile/expected.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

e2e/testdata/render/singlefile/my.dockerapp

Lines changed: 0 additions & 16 deletions
This file was deleted.

e2e/testdata/render/singlefile/parameters-0.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/cnab-simple/hello.dockerapp

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: '3.6'
2+
services:
3+
hello:
4+
image: hashicorp/http-echo:0.2.3
5+
command: ["-text", "${text}"]
6+
ports:
7+
- ${port}:5678

0 commit comments

Comments
 (0)