Update schema validation to be internal validation.

This commit is contained in:
Felipe Monteiro 2017-07-24 16:55:17 +01:00
parent 7f6788db89
commit cb29a3f0ba
4 changed files with 26 additions and 7 deletions

View File

@ -118,7 +118,6 @@ def document_create(values, session=None):
"""Create a document."""
values = values.copy()
values['_metadata'] = values.pop('metadata')
print(values)
values['name'] = values['_metadata']['name']
session = session or get_session()

View File

@ -14,7 +14,8 @@
import jsonschema
from deckhand.engine.schema.v1_0 import default_schema
from deckhand.engine.schema.v1_0 import default_policy_validation
from deckhand.engine.schema.v1_0 import default_schema_validation
from deckhand import errors
@ -38,11 +39,17 @@ class DocumentValidation(object):
Retrieves the schema that corresponds to "apiVersion" in the YAML
data. This schema is responsible for performing pre-validation on
YAML data.
"""
# TODO: Update kind according to requirements.
schema_versions_info = [{'version': 'v1', 'kind': 'default',
'schema': default_schema}]
The built-in validation schemas that are always executed include:
- `deckhand-document-schema-validation`
- `deckhand-policy-validation`
"""
internal_validations = [
{'version': 'v1', 'fqn': 'deckhand-document-schema-validation',
'schema': default_schema_validation},
{'version': 'v1', 'fqn': 'deckhand-policy-validation',
'schema': default_policy_validation}]
def __init__(self, schema_version):
self.schema_version = schema_version
@ -50,7 +57,7 @@ class DocumentValidation(object):
@property
def schema(self):
# TODO: return schema based on version and kind.
return [v['schema'] for v in self.schema_versions_info
return [v['schema'] for v in self.internal_validations
if v['version'] == self.schema_version][0].schema
def pre_validate_data(self):

View File

@ -0,0 +1,13 @@
# Copyright 2017 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.