Skip to content
This repository has been archived by the owner on Mar 23, 2019. It is now read-only.

Commit

Permalink
Fixes missing build files when using --project-path
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Houseknecht committed Jul 20, 2017
1 parent fa72fab commit 8146eae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions container/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
from .exceptions import AnsibleContainerConfigException, AnsibleContainerNotInitializedException
from .utils import get_metadata_from_role, get_defaults_from_role

# TODO: Actually do some schema validation

# jag: Division of labor between outer utility and conductor:
#
# Out here, we will parse the container.yml and process AC_* environment
Expand Down Expand Up @@ -227,10 +225,21 @@ def _get_variables_from_file(self, var_file):

SUPPORTED_COMPOSE_VERSIONS = ['1', '2']

REQUIRED_TOP_LEVEL_KEYS = ['version', 'services']

REQUIRED_SERVICE_LEVEL_KEYS = ['from']

# TODO: Add more schema validation

def _validate_config(self, config):
for key in self.REQUIRED_TOP_LEVEL_KEYS:
if not config.get(key):
raise AnsibleContainerConfigException("Missing expected key {}".format(key))

for top_level in config:
if top_level not in self.TOP_LEVEL_WHITELIST:
raise AnsibleContainerConfigException("invalid key '{0}'".format(top_level))

if top_level == 'version':
if config['version'] not in self.SUPPORTED_COMPOSE_VERSIONS:
raise AnsibleContainerConfigException("requested version is not supported")
Expand All @@ -240,6 +249,12 @@ def _validate_config(self, config):
if config[top_level] is None:
config[top_level] = yaml.compat.ordereddict()

for service_name, service in iteritems(config['services']):
for key in self.REQUIRED_SERVICE_LEVEL_KEYS:
if not service.get(key):
raise AnsibleContainerConfigException("Service {} is missing key '{}'".format(service_name, key))


def __getitem__(self, item):
return self._config[item]

Expand Down
2 changes: 1 addition & 1 deletion container/docker/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ def build_conductor_image(self, base_path, base_image, cache=True):
for filename in ['ansible.cfg', 'ansible-requirements.txt',
'requirements.yml']:
file_path = os.path.join(source_dir, filename)
if os.path.exists(filename):
if os.path.exists(file_path):
tarball.add(file_path,
arcname=os.path.join('build-src', filename))
# Make an empty file just to make sure the build-src dir has something
Expand Down

0 comments on commit 8146eae

Please sign in to comment.