This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring a little bit the yaml package
- Split into smaller files (with test) to make it easier to read - Add a Build type that handle some Build magic - Add an External type that handle some external magic (networks, volumes) - Add Networks/Network type that handle some Networks magic - Refactor the Ulimit types to be simpler and not user reflection Also adds a merge_fixtures_test.go and testdata folder with some existing compose file to make sure it parses it well (should serve as quick regression tests in the future too). Signed-off-by: Vincent Demeester <vincent@sbr.pm>
- Loading branch information
1 parent
8161ca7
commit f336219
Showing
37 changed files
with
1,201 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package config | ||
|
||
import ( | ||
"io/ioutil" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func TestMergeOnValidFixtures(t *testing.T) { | ||
files, err := ioutil.ReadDir("testdata/") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
for _, file := range files { | ||
if file.IsDir() { | ||
continue | ||
} | ||
data, err := ioutil.ReadFile(filepath.Join("testdata", file.Name())) | ||
if err != nil { | ||
t.Fatalf("error reading %q: %v", file.Name(), err) | ||
} | ||
_, _, _, _, err = Merge(NewServiceConfigs(), nil, nil, file.Name(), data, nil) | ||
if err != nil { | ||
t.Errorf("error loading %q: %v\n %v", file.Name(), string(data), err) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package config | ||
|
||
import "testing" | ||
import ( | ||
"testing" | ||
) | ||
|
||
type NullLookup struct { | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: "2" | ||
|
||
services: | ||
simple: | ||
build: . | ||
image: myimage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
simple1: | ||
build: . | ||
simple2: | ||
build: . | ||
dockerfile: alternate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: "2" | ||
|
||
services: | ||
simple1: | ||
build: . | ||
simple2: | ||
context: ./dir | ||
simple3: | ||
context: ./another | ||
dockerfile: alternate | ||
args: | ||
buildno: 1 | ||
user: vincent | ||
simple4: | ||
context: ./another | ||
args: | ||
buildno: 2 | ||
user: josh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
simple1: | ||
image: myimage | ||
command: bundle exec thi-p 3000 | ||
simple2: | ||
image: myimage | ||
command: [bundle, exec, thin, -p, "3000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: '2' | ||
services: | ||
web: | ||
build: . | ||
depends_on: | ||
- db | ||
- redis | ||
redis: | ||
image: redis | ||
db: | ||
image: postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
simple: | ||
build: . | ||
dns: 8.8.8.8 | ||
dns: | ||
- 8.8.8.8 | ||
- 9.9.9.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
simple1: | ||
build: . | ||
entrypoint: | ||
- php | ||
- -d | ||
- zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so | ||
- -d | ||
- memory_limit=-1 | ||
- vendor/bin/phpunit | ||
simple2: | ||
build: . | ||
entrypoint: /code/entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: "2" | ||
services: | ||
simple1: | ||
build: . | ||
entrypoint: | ||
- php | ||
- -d | ||
- zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so | ||
- -d | ||
- memory_limit=-1 | ||
- vendor/bin/phpunit | ||
simple2: | ||
build: . | ||
entrypoint: /code/entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
simple1: | ||
image: myimage | ||
log_driver: syslog | ||
log_opt: | ||
syslog-address: "tcp://192.168.0.42:123" | ||
simple2: | ||
image: myimage | ||
log_driver: "none" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: "2" | ||
services: | ||
simple1: | ||
image: myimage | ||
logging: | ||
driver: syslog | ||
options: | ||
syslog-address: "tcp://192.168.0.42:123" | ||
simple2: | ||
image: myimage | ||
logging: | ||
driver: "none" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: "2" | ||
services: | ||
simple1: | ||
image: myimage | ||
network_mode: bridge | ||
simple2: | ||
image: myimage | ||
network_mode: "service:bridge" | ||
simple3: | ||
image: myimage | ||
network_mode: "container:test_container" | ||
simple4: | ||
image: myimage | ||
network_mode: host | ||
simple5: | ||
image: myimage | ||
network_mode: none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
version: "2" | ||
networks: | ||
default: | ||
driver: custom-driver | ||
network1: | ||
driver: bridge | ||
driver_opts: | ||
com.docker.network.enable_ipv6: "true" | ||
ipam: | ||
driver: default | ||
config: | ||
- subnet: 172.16.238.0/24 | ||
gateway: 172.16.238.1 | ||
- subnet: 2001:3984:3989::/64 | ||
gateway: 2001:3984:3989::1 | ||
network2: | ||
external: true | ||
network3: | ||
external: | ||
name: name-of-network | ||
network3: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
version: "2" | ||
services: | ||
simple1: | ||
image: myimage | ||
networks: | ||
- network1 | ||
- network2 | ||
simple2: | ||
image: myimage | ||
networks: | ||
network1: | ||
aliases: | ||
- alias1 | ||
- alias3 | ||
network2: | ||
aliases: | ||
- alias2 | ||
simple3: | ||
image: myimage | ||
networks: | ||
network1: | ||
ipv4_address: 172.16.238.10 | ||
ipv6_address: 2001:3984:3989::10 | ||
simple4: | ||
image: myimage | ||
networks: ["network1"] | ||
simple5: | ||
image: myimage | ||
networks: ["network1", "network2"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
simple1: | ||
image: myimage | ||
ulimits: | ||
nproc: 65535 | ||
nofile: | ||
soft: 20000 | ||
hard: 40000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: "2" | ||
services: | ||
simple1: | ||
image: myimage | ||
ulimits: | ||
nproc: 65535 | ||
nofile: | ||
soft: 20000 | ||
hard: 40000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: "2" | ||
volumes: | ||
volume1: | ||
driver: foo | ||
volume2: | ||
driver: bar | ||
driver_opts: | ||
foo: "bar" | ||
baz: "" | ||
volume3: | ||
external: true | ||
volume4: | ||
external: | ||
name: name-of-volume |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
simple1: | ||
image: myimage | ||
volumes: | ||
- /var/lib/mysql | ||
- /opt/data:/var/lib/mysql | ||
- ./cache:/tmp/cache | ||
- ~configs:/etc/configs/:ro | ||
- datavolume:/var/lib/mysql | ||
volume_driver: mydriver | ||
volumes_from: | ||
- service_name | ||
- service_name:ro | ||
- container_name | ||
- container_name:rw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: "2" | ||
services: | ||
simple1: | ||
image: myimage | ||
volumes: | ||
- /var/lib/mysql | ||
- /opt/data:/var/lib/mysql | ||
- ./cache:/tmp/cache | ||
- ~configs:/etc/configs/:ro | ||
- datavolume:/var/lib/mysql | ||
volume_driver: mydriver |
Oops, something went wrong.