Skip to content

Commit de7e486

Browse files
authored
Add root context syntax (#108)
1 parent c810e31 commit de7e486

File tree

6 files changed

+131
-112
lines changed

6 files changed

+131
-112
lines changed

dockerc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ if [ "$CONTEXT" != '--' ]; then
743743

744744
CONTEXT_SKIP_ROOT_STANDARD='false'
745745

746-
if [ "$CONTEXT" = '-' ] || [ "$CONTEXT" = '.' ]; then
746+
if [ "$CONTEXT" = '-' ]; then
747747
# Use default context
748748
CONTEXT=''
749749

@@ -805,7 +805,7 @@ if [ "$CONTEXT" != '--' ]; then
805805
fi
806806

807807
# Parse context parts
808-
if [ -n "$CONTEXT" ]; then
808+
if [ -n "$CONTEXT" ] && [ "$CONTEXT" != '.' ]; then
809809

810810
if [ -n "$LVL1_COMPOSE_FILE_ARGS" ]; then
811811

@@ -1002,7 +1002,8 @@ if [ "$CONTEXT" != '--' ]; then
10021002
break
10031003
fi
10041004

1005-
elif [ "$CONTEXT" != 'prod' ]; then
1005+
elif [ "$CONTEXT" != '.' ] && [ "$CONTEXT" != 'prod' ]; then
1006+
# Neither "root" nor "prod" context
10061007
# Context not resolved: invalidate LVL1 & break loop
10071008
LVL1_COMPOSE_FILE_ARGS=''
10081009
break

test/test/standard_two/test_default.py

Lines changed: 0 additions & 109 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from test.src.TestDirContext import TestDirContext
2+
3+
def test_what_not_found(file = __file__):
4+
with TestDirContext(file) as ctx:
5+
dockerc = ctx.run_dockerc(
6+
'what',
7+
)
8+
dockerc.assert_context_not_found()
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from test.src.format_dockerc_stdout import format_dockerc_stdout
2+
from test.src.TestDirContext import TestDirContext
3+
4+
# def test_default_env(dir_files = dir_files):
5+
# reset_dir('./twd', dir_files + [
6+
# '.env',
7+
# ])
8+
# assert_context_ok(
9+
# None,
10+
# (
11+
# b'docker compose' \
12+
# b' -f ./docker-compose.yml' \
13+
# b' -f ./docker-compose.override.yml' \
14+
# b' --env-file ./.env' \
15+
# b' up -d'
16+
# ),
17+
# )
18+
19+
# def test_default_env_local(dir_files = dir_files):
20+
# reset_dir('./twd', dir_files + [
21+
# '.env.local',
22+
# ])
23+
# assert_context_ok(
24+
# None,
25+
# (
26+
# b'docker compose' \
27+
# b' -f ./docker-compose.yml' \
28+
# b' -f ./docker-compose.override.yml' \
29+
# b' --env-file ./.env.local' \
30+
# b' up -d'
31+
# ),
32+
# )
33+
34+
# def test_default_env_both():
35+
# reset_dir('./twd', dir_files + [
36+
# '.env',
37+
# '.env.local',
38+
# ])
39+
# assert_context_ok(
40+
# None,
41+
# (
42+
# b'docker compose' \
43+
# b' -f ./docker-compose.yml' \
44+
# b' -f ./docker-compose.override.yml' \
45+
# b' --env-file ./.env' \
46+
# b' --env-file ./.env.local' \
47+
# b' up -d'
48+
# ),
49+
# )
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from test.src.format_dockerc_stdout import format_dockerc_stdout
2+
from test.src.TestDirContext import TestDirContext
3+
4+
def test_default(file = __file__):
5+
with TestDirContext(file) as ctx:
6+
dockerc = ctx.run_dockerc()
7+
dockerc.assert_context_ok(
8+
format_dockerc_stdout(
9+
b'docker compose'
10+
b' -f ./docker-compose.yml'
11+
b' -f ./docker-compose.override.yml'
12+
b' up -d'
13+
),
14+
)
15+
16+
def test_override(file = __file__):
17+
with TestDirContext(file) as ctx:
18+
dockerc = ctx.run_dockerc(
19+
'override',
20+
)
21+
dockerc.assert_context_ok(
22+
format_dockerc_stdout(
23+
b'docker compose'
24+
b' -f ./docker-compose.yml'
25+
b' -f ./docker-compose.override.yml'
26+
b' up -d'
27+
),
28+
)
29+
30+
def test_dev(file = __file__):
31+
with TestDirContext(file) as ctx:
32+
dockerc = ctx.run_dockerc(
33+
'dev',
34+
)
35+
dockerc.assert_context_ok(
36+
format_dockerc_stdout(
37+
b'docker compose'
38+
b' -f ./docker-compose.yml'
39+
b' -f ./docker-compose.override.yml'
40+
b' up -d'
41+
),
42+
)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from test.src.format_dockerc_stdout import format_dockerc_stdout
2+
from test.src.TestDirContext import TestDirContext
3+
4+
def test_root(file = __file__):
5+
with TestDirContext(file) as ctx:
6+
dockerc = ctx.run_dockerc(
7+
'.',
8+
)
9+
dockerc.assert_context_ok(
10+
format_dockerc_stdout(
11+
b'docker compose'
12+
b' -f ./docker-compose.yml'
13+
b' up -d'
14+
),
15+
)
16+
17+
def test_prod(file = __file__):
18+
with TestDirContext(file) as ctx:
19+
dockerc = ctx.run_dockerc(
20+
'prod',
21+
)
22+
dockerc.assert_context_ok(
23+
format_dockerc_stdout(
24+
b'docker compose'
25+
b' -f ./docker-compose.yml'
26+
b' up -d'
27+
),
28+
)

0 commit comments

Comments
 (0)