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:
Daniel Nephin 2015-03-31 21:20:02 -04:00 committed by Aanand Prasad
commit e4e802d1f8
7 changed files with 56 additions and 4 deletions

2
tests/fixtures/build-ctx/Dockerfile vendored Normal file
View file

@ -0,0 +1,2 @@
FROM busybox:latest
CMD echo "success"

View file

@ -0,0 +1,2 @@
foo:
build: ../build-ctx/

View file

@ -1,2 +1,2 @@
service:
build: tests/fixtures/dockerfile_with_entrypoint
build: .

View file

@ -1,2 +1,2 @@
simple:
build: tests/fixtures/simple-dockerfile
build: .

View file

@ -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}])