def validateConfig(config): result = validate_dict(['siteFolder', 'filesFolder'], config) if not result: return result if 'database' not in config: return validate_dict(['user', 'pass', 'name'], config['database'], 'database')
def getDockerConfig(docker_config_name, runLocally=False, printErrors=True): settings = getAll() if 'dockerHosts' not in settings: return False dockerHosts = settings['dockerHosts'] if not dockerHosts or docker_config_name not in dockerHosts: return False docker_config = copy.deepcopy(dockerHosts[docker_config_name]) docker_config = resolve_inheritance(docker_config, dockerHosts) if 'runLocally' in docker_config and docker_config[ 'runLocally'] or runLocally: keys = ['rootFolder', 'tasks'] else: docker_config['runLocally'] = False keys = ['tasks', 'rootFolder', 'user', 'host', 'port'] errors = validate_dict(keys, docker_config) if len(errors) > 0: if printErrors: for key in errors: log.error('Missing key \'%s\' in docker-configuration %s' % (key, docker_config_name)) return False return docker_config
def validate_config_against_methods(config): from lib import methods errors = validate_dict(['rootFolder', 'type', 'needs'], config) methodNames = config['needs'] for methodName in methodNames: m = methods.getMethod(methodName) e = m.validateConfig(config) errors = data_merge(errors, e) if len(errors) > 0: for key, msg in errors.iteritems(): print red('Key \'%s\' in %s: %s' % (key, config['config_name'], msg)) exit(1)
def expandBlueprints(data): """ Expand a list of blueprint configurations with a list of variants. Helps documenting the available hosts better """ from lib import blueprints for blueprint in data['blueprints']: errors = validate_dict(['configName', 'variants'], blueprint) if len(errors) > 0: for key, error in errors.iteritems(): log.error('can not expand blueprints, %s: %s!' % (error, key)) exit(1) template = blueprints.getTemplate(blueprint['configName']) if not template: log.error('Missing blueprint config %s' % blueprint['configName']) for variant in blueprint['variants']: c = blueprints.apply(variant, template) data['hosts'][c['configName']] = c
def validateConfig(config): keys = ['host', 'user'] return validate_dict(keys, config)
def validateConfig(config): if 'docker' not in config: return validate_dict(['docker'], config) return validate_dict(['configuration', 'name'], config['docker'], 'docker')
def validateConfig(config): return validate_dict([], config)
def validateConfig(config): return validate_dict(['branch'], config)
def validateConfig(config): return validate_dict( ['rootFolder', 'siteFolder', 'filesFolder', 'backupFolder'], config)