Skip to content

Commit

Permalink
Add automatic parsing of configuration by regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
mblaschke committed Feb 18, 2017
1 parent 37c47a1 commit 69b5c7d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 31 deletions.
5 changes: 5 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ if __name__ == '__main__':
if 'pathRegex' in configuration['docker']:
configuration['docker']['autoPullBlacklist'] = re.compile(configuration['docker']['autoPullBlacklist'])

if 'dockerTest' in configuration:
if 'configuration' in configuration['dockerTest']:
if 'imageConfigurationRegex' in configuration['dockerTest']['configuration']:
configuration['dockerTest']['configuration']['imageConfigurationRegex'] = re.compile(configuration['dockerTest']['configuration']['imageConfigurationRegex'])

configuration = Configuration.merge(configuration)
configuration = Configuration.dotdictify(configuration)

Expand Down
7 changes: 7 additions & 0 deletions bin/webdevops/taskloader/DockerTestServerspecTaskLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ def generate_serverspec_configuration(path, dockerfile, configuration, is_toolim
if default_env_list:
ret = default_env_list.to_dict().copy()

# parse configuration by regexp
image_configuration_regex = configuration.get('dockerTest.configuration.imageConfigurationRegex', False)
if image_configuration_regex:
parsed_configuration = ([m.groupdict() for m in image_configuration_regex.finditer(dockerfile['image']['fullname'])])
if parsed_configuration:
ret.update(parsed_configuration[0])

# add docker image specific vars
image_env_list = configuration.get('dockerTest.configuration.image')
if image_env_list:
Expand Down
32 changes: 1 addition & 31 deletions conf/console.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,53 +37,23 @@ dockerTest:
- 'ENV VARNISH_BACKEND_HOST webdevops.io'

configuration:
imageConfigurationRegex: ':(?P<OS_FAMILY>alpine|debian|ubuntu|centos)-(?P<OS_VERSION>[^-]+)'
default:
OS_FAMILY: 'ubuntu'
OS_VERSION: '16.04'
image:
':alpine':
OS_FAMILY: 'alpine'
OS_VERSION: '3'
PHP_MHASH: '0'
PHP_REDIS: '0'
':ubuntu-12.04':
OS_FAMILY: 'ubuntu'
OS_VERSION: '12.04'
PHP_REDIS: '0'
PHP_APCU: '0'
':ubuntu-14.04':
OS_FAMILY: 'ubuntu'
OS_VERSION: '14.04'
':ubuntu-15.04':
OS_FAMILY: 'ubuntu'
OS_VERSION: '15.04'
':ubuntu-15.10':
OS_FAMILY: 'ubuntu'
OS_VERSION: '15.10'
':ubuntu-16.04':
OS_FAMILY: 'ubuntu'
OS_VERSION: '16.04'
':debian-7':
OS_FAMILY: 'debian'
OS_VERSION: '7'
PHP_REDIS: '0'
PHP_APCU: '0'
':debian-8':
OS_FAMILY: 'debian'
OS_VERSION: '8'
':debian-8-php7':
OS_FAMILY: 'debian'
OS_VERSION: '8'
PHP_XDEBUG: '0'
':debian-9':
OS_FAMILY: 'debian'
OS_VERSION: '9'
':centos-7':
OS_FAMILY: 'redhat'
OS_VERSION: '7'
':centos-7-php56':
OS_FAMILY: 'redhat'
OS_VERSION: '7'
PHP_APCU: '0'
PHP_REDIS: '0'
'/ssh':
Expand Down

0 comments on commit 69b5c7d

Please sign in to comment.