Replace runtime sources verification with jsonschema validation
Change-Id: I3d17336d26ed14970c6d9f96c10b65468da12f1f
This commit is contained in:
parent
9242c23d9e
commit
3b24a8039c
|
@ -30,18 +30,6 @@ def create_rendered_dockerfile(path, name, tmp_path, config):
|
|||
git_url = config['sources'].get(project_name, {}).get('git_url')
|
||||
source_dir = config['sources'].get(project_name, {}).get('source_dir')
|
||||
|
||||
if not git_url and not source_dir:
|
||||
LOG.error('%s: Neither git_url nor source_dir specified for '
|
||||
'project %s (exactly one should be specified)',
|
||||
name, project_name)
|
||||
sys.exit(1)
|
||||
|
||||
if git_url and source_dir:
|
||||
LOG.error('%s: Both git_url and source_dir specified for '
|
||||
'project %s (exactly one should be specified)',
|
||||
name, project_name)
|
||||
sys.exit(1)
|
||||
|
||||
if git_url:
|
||||
LOG.info('%s: Cloning repository "%s"', name, git_url)
|
||||
repo = git.Repo.clone_from(git_url, tmp_dir)
|
||||
|
|
|
@ -11,6 +11,7 @@ from fuel_ccp.config import kubernetes
|
|||
from fuel_ccp.config import registry
|
||||
from fuel_ccp.config import replicas
|
||||
from fuel_ccp.config import repositories
|
||||
from fuel_ccp.config import sources
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -51,6 +52,11 @@ class _Wrapper(object):
|
|||
|
||||
CONF = _Wrapper()
|
||||
|
||||
CONFIG_MODULES = [
|
||||
builder, cli, images, kubernetes, registry, replicas, repositories,
|
||||
sources,
|
||||
]
|
||||
|
||||
|
||||
def get_config_defaults():
|
||||
defaults = _yaml.AttrDict({
|
||||
|
@ -58,10 +64,9 @@ def get_config_defaults():
|
|||
'verbose_level': 1,
|
||||
'log_file': None,
|
||||
})
|
||||
for name in ['configs', 'nodes', 'roles', 'sources', 'versions']:
|
||||
for name in ['configs', 'nodes', 'roles', 'versions']:
|
||||
defaults[name] = _yaml.AttrDict()
|
||||
for module in [cli, builder, images, kubernetes, registry, replicas,
|
||||
repositories]:
|
||||
for module in CONFIG_MODULES:
|
||||
defaults._merge(module.DEFAULTS)
|
||||
return defaults
|
||||
|
||||
|
@ -76,15 +81,14 @@ def get_config_schema():
|
|||
'log_file': {'anyOf': [{'type': 'null'}, {'type': 'string'}]},
|
||||
},
|
||||
}
|
||||
for module in [cli, builder, images, kubernetes, registry, replicas,
|
||||
repositories]:
|
||||
for module in CONFIG_MODULES:
|
||||
schema['properties'].update(module.SCHEMA)
|
||||
# Don't validate all options used to be added from oslo.log and oslo.config
|
||||
ignore_opts = ['debug', 'verbose', 'log_file']
|
||||
for name in ignore_opts:
|
||||
schema['properties'][name] = {}
|
||||
# Also for now don't validate sections that used to be in deploy config
|
||||
for name in ['configs', 'nodes', 'roles', 'sources', 'versions']:
|
||||
for name in ['configs', 'nodes', 'roles', 'versions']:
|
||||
schema['properties'][name] = {'type': 'object'}
|
||||
return schema
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
SCHEMA = {
|
||||
'sources': {
|
||||
'type': 'object',
|
||||
'additionalProperties': {
|
||||
'additionalProperties': False,
|
||||
'properties': {
|
||||
'git_url': {'type': 'string'},
|
||||
'git_ref': {'type': 'string'},
|
||||
'source_dir': {'type': 'string'},
|
||||
},
|
||||
'oneOf': [
|
||||
{'required': ['git_url', 'git_ref']},
|
||||
{'required': ['source_dir']},
|
||||
],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
DEFAULTS = {
|
||||
'sources': {},
|
||||
}
|
Loading…
Reference in New Issue