-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add composefile v1 / v2 parsing and validation support #573
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package loader | ||
|
||
import ( | ||
"testing" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
|
||
func TestUnsupportedVersion(t *testing.T) { | ||
_, err := loadYAML(` | ||
version: "0.1" | ||
services: | ||
foo: | ||
image: busybox | ||
`) | ||
require.Error(t, err) | ||
require.Contains(t, err.Error(), "version") | ||
|
||
_, err = loadYAML(` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why testing the same error again? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are right, I'll remove 😛 |
||
version: "0.1" | ||
services: | ||
foo: | ||
image: busybox | ||
`) | ||
require.Error(t, err) | ||
require.Contains(t, err.Error(), "version") | ||
} | ||
|
||
|
||
func TestV1Supported(t *testing.T) { | ||
actual, err := loadYAML(` | ||
foo: | ||
image: busybox | ||
`) | ||
require.NoError(t, err) | ||
require.Len(t, actual.Services, 1) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package loader | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestV2Supported(t *testing.T) { | ||
actual, err := loadYAML(` | ||
version: "2.0" | ||
services: | ||
foo: | ||
image: busybox`) | ||
|
||
require.NoError(t, err) | ||
require.Len(t, actual.Services, 1) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
net: | ||
image: busybox | ||
volume: | ||
image: busybox | ||
volumes: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this is a "full" test it should probably include all the fields supported by v1 and one service with build, one with image There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dnephin yeah I just copied the file from `docker/compose so far 😛 |
||
- /data | ||
app: | ||
image: busybox | ||
net: "container:net" | ||
volumes_from: ["volume"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version: "2" | ||
|
||
volumes: | ||
data: | ||
driver: local | ||
|
||
networks: | ||
front: {} | ||
|
||
services: | ||
web: | ||
build: . | ||
networks: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, should include all the fields |
||
- front | ||
- default | ||
volumes_from: | ||
- other | ||
|
||
other: | ||
image: busybox:latest | ||
command: top | ||
volumes: | ||
- /data |
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should move this import up with other standard imports.