Merge pull request #1213 from moysesb/relative_build
Make value of 'build:' relative to the yml file.
(cherry picked from commit 0f70b8638f)
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
b24a60ba9f
commit
e4e802d1f8
7 changed files with 56 additions and 4 deletions
2
tests/fixtures/build-ctx/Dockerfile
vendored
Normal file
2
tests/fixtures/build-ctx/Dockerfile
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
FROM busybox:latest
|
||||
CMD echo "success"
|
||||
2
tests/fixtures/build-path/docker-compose.yml
vendored
Normal file
2
tests/fixtures/build-path/docker-compose.yml
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
foo:
|
||||
build: ../build-ctx/
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
service:
|
||||
build: tests/fixtures/dockerfile_with_entrypoint
|
||||
build: .
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
simple:
|
||||
build: tests/fixtures/simple-dockerfile
|
||||
build: .
|
||||
|
|
|
|||
|
|
@ -381,3 +381,36 @@ class ExtendsTest(unittest.TestCase):
|
|||
]
|
||||
|
||||
self.assertEqual(set(dicts[0]['volumes']), set(paths))
|
||||
|
||||
|
||||
class BuildPathTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.abs_context_path = os.path.join(os.getcwd(), 'tests/fixtures/build-ctx')
|
||||
|
||||
def test_nonexistent_path(self):
|
||||
options = {'build': 'nonexistent.path'}
|
||||
self.assertRaises(
|
||||
config.ConfigurationError,
|
||||
lambda: config.make_service_dict('foo', options, 'tests/fixtures/build-path'),
|
||||
)
|
||||
|
||||
def test_relative_path(self):
|
||||
relative_build_path = '../build-ctx/'
|
||||
service_dict = config.make_service_dict(
|
||||
'relpath',
|
||||
{'build': relative_build_path},
|
||||
working_dir='tests/fixtures/build-path'
|
||||
)
|
||||
self.assertEquals(service_dict['build'], self.abs_context_path)
|
||||
|
||||
def test_absolute_path(self):
|
||||
service_dict = config.make_service_dict(
|
||||
'abspath',
|
||||
{'build': self.abs_context_path},
|
||||
working_dir='tests/fixtures/build-path'
|
||||
)
|
||||
self.assertEquals(service_dict['build'], self.abs_context_path)
|
||||
|
||||
def test_from_file(self):
|
||||
service_dict = config.load('tests/fixtures/build-path/docker-compose.yml')
|
||||
self.assertEquals(service_dict, [{'name': 'foo', 'build': self.abs_context_path}])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue