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

Commit be84671

Browse files
committed
Some more obsolete code
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 590a3dd commit be84671

File tree

9 files changed

+7
-209
lines changed

9 files changed

+7
-209
lines changed

README.md

Lines changed: 5 additions & 8 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

integrations/intellij/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The plugin exposes the following commands in a top-level `Docker` menu:
2424

2525
This command displays a dialog that can be used to initialize a new Docker Application.
2626

27-
It gives you the option to chose the name, description and maintainers of the application, as well as whether to use single-file mode or not.
27+
It gives you the option to chose the name, description and maintainers of the application.
2828

2929
## Select application
3030

internal/packager/extract.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func Extract(name string, ops ...func(*types.App) error) (*types.App, error) {
7272
)
7373
return loader.LoadFromDirectory(appname, appOpts...)
7474
}
75-
// not a dir: single-file or a tarball package, extract that in a temp dir
75+
// not a dir: a tarball package, extract that in a temp dir
7676
app, err := loader.LoadFromTar(appname, ops...)
7777
if err != nil {
7878
return nil, err

internal/packager/split.go

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

loader/loader.go

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package loader
22

33
import (
4-
"bytes"
54
"io"
65
"io/ioutil"
76
"os"
@@ -13,75 +12,6 @@ import (
1312
"github.com/pkg/errors"
1413
)
1514

16-
var (
17-
crlf = []byte{'\r', '\n'}
18-
lf = []byte{'\n'}
19-
delimiters = [][]byte{
20-
[]byte("\r\n---\r\n"),
21-
[]byte("\n---\r\n"),
22-
[]byte("\r\n---\n"),
23-
[]byte("\n---\n"),
24-
}
25-
)
26-
27-
// useCRLF detects which line break should be used
28-
func useCRLF(data []byte) bool {
29-
nbCrlf := bytes.Count(data, crlf)
30-
nbLf := bytes.Count(data, lf)
31-
switch {
32-
case nbCrlf == nbLf:
33-
// document contains only CRLF
34-
return true
35-
case nbCrlf == 0:
36-
// document does not contain any CRLF
37-
return false
38-
default:
39-
// document contains mixed line breaks, so use the OS default
40-
return bytes.Equal(defaultLineBreak, crlf)
41-
}
42-
}
43-
44-
// splitSingleFile split a multidocument using all possible document delimiters
45-
func splitSingleFile(data []byte) [][]byte {
46-
parts := [][]byte{data}
47-
for _, delimiter := range delimiters {
48-
var intermediate [][]byte
49-
for _, part := range parts {
50-
intermediate = append(intermediate, bytes.Split(part, delimiter)...)
51-
}
52-
parts = intermediate
53-
}
54-
return parts
55-
}
56-
57-
// LoadFromSingleFile loads a docker app from a single-file format (as a reader)
58-
func LoadFromSingleFile(path string, r io.Reader, ops ...func(*types.App) error) (*types.App, error) {
59-
data, err := ioutil.ReadAll(r)
60-
if err != nil {
61-
return nil, errors.Wrap(err, "error reading single-file")
62-
}
63-
64-
parts := splitSingleFile(data)
65-
if len(parts) != 3 {
66-
return nil, errors.Errorf("malformed single-file application: expected 3 documents, got %d", len(parts))
67-
}
68-
69-
// 0. is metadata
70-
metadata := bytes.NewBuffer(parts[0])
71-
// 1. is compose
72-
compose := bytes.NewBuffer(parts[1])
73-
// 2. is parameters
74-
params := bytes.NewBuffer(parts[2])
75-
76-
appOps := append([]func(*types.App) error{
77-
types.WithComposes(compose),
78-
types.WithParameters(params),
79-
types.Metadata(metadata),
80-
types.WithCRLF(useCRLF(data)),
81-
}, ops...)
82-
return types.NewApp(path, appOps...)
83-
}
84-
8515
// LoadFromDirectory loads a docker app from a directory
8616
func LoadFromDirectory(path string, ops ...func(*types.App) error) (*types.App, error) {
8717
if _, err := os.Stat(filepath.Join(path, internal.ParametersFileName)); os.IsNotExist(err) {

loader/loader_test.go

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
package loader
22

33
import (
4-
"fmt"
54
"io/ioutil"
6-
"strings"
75
"testing"
86

97
"github.com/docker/app/internal"
108
"github.com/docker/app/types"
119
"github.com/docker/docker/pkg/archive"
12-
"github.com/pkg/errors"
13-
1410
"gotest.tools/assert"
1511
is "gotest.tools/assert/cmp"
1612
"gotest.tools/fs"
@@ -29,47 +25,6 @@ services:
2925
`
3026
)
3127

32-
func TestLoadFromSingleFile(t *testing.T) {
33-
testCases := []struct {
34-
name string
35-
file string
36-
}{
37-
{
38-
name: "line-feed",
39-
file: fmt.Sprintf("%s\n---\n%s\n---\n%s", metadata, compose, params),
40-
},
41-
{
42-
name: "carriage-return-line-feed",
43-
file: fmt.Sprintf("%s\r\n---\r\n%s\r\n---\r\n%s", metadata, compose, params),
44-
},
45-
{
46-
name: "mixed-carriage-return-line-feed",
47-
file: fmt.Sprintf("%s\r\n---\r\n%s\r\n---\n%s", metadata, compose, params),
48-
},
49-
}
50-
for _, test := range testCases {
51-
t.Run(test.name, func(t *testing.T) {
52-
app, err := LoadFromSingleFile("my-app", strings.NewReader(test.file))
53-
assert.NilError(t, err)
54-
assert.Assert(t, app != nil)
55-
assert.Assert(t, is.Equal(app.Path, "my-app"))
56-
assertAppContent(t, app)
57-
})
58-
}
59-
}
60-
61-
func TestLoadFromSingleFileInvalidReader(t *testing.T) {
62-
_, err := LoadFromSingleFile("my-app", &faultyReader{})
63-
assert.ErrorContains(t, err, "faulty reader")
64-
}
65-
66-
func TestLoadFromSingleFileMalformed(t *testing.T) {
67-
_, err := LoadFromSingleFile("my-app", strings.NewReader(`foo: foo
68-
---
69-
bar: bar`))
70-
assert.ErrorContains(t, err, "malformed single-file application")
71-
}
72-
7328
func TestLoadFromDirectory(t *testing.T) {
7429
dir := fs.NewDir(t, "my-app",
7530
fs.WithFile(internal.MetadataFileName, metadata),
@@ -140,9 +95,3 @@ func assertAppContent(t *testing.T, app *types.App) {
14095
assertContentIs(t, app.Composes()[0], compose)
14196
assertContentIs(t, app.MetadataRaw(), metadata)
14297
}
143-
144-
type faultyReader struct{}
145-
146-
func (r *faultyReader) Read(_ []byte) (int, error) {
147-
return 0, errors.New("faulty reader")
148-
}

loader/loader_unix.go

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

loader/loader_windows.go

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

types/types.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ const (
2626
AppSourceArchive
2727
)
2828

29-
// YamlSingleFileSeparator returns the separator used in single-file app, depending detected CRLF
30-
func YamlSingleFileSeparator(hasCRLF bool) []byte {
31-
if hasCRLF {
32-
return []byte("\r\n---\r\n")
33-
}
34-
return []byte("\n---\n")
35-
}
36-
3729
// ShouldRunInsideDirectory returns whether the package is run from a directory on disk
3830
func (a AppSourceKind) ShouldRunInsideDirectory() bool {
3931
return a == AppSourceSplit || a == AppSourceImage || a == AppSourceArchive

0 commit comments

Comments
 (0)