in marketplace/deployer_util/config_helper.py [0:0]
def __init__(self, name, dictionary, required):
self._name = name
self._d = dictionary
self._required = required
self._default = dictionary.get('default', None)
self._x = dictionary.get(XGOOGLE, None)
self._application_uid = None
self._image = None
self._password = None
self._reporting_secret = None
self._service_account = None
self._storage_class = None
self._string = None
self._tls_certificate = None
if not NAME_RE.match(name):
raise InvalidSchema('Invalid property name: {}'.format(name))
self._type = _must_get_and_apply(
dictionary, 'type', lambda v: {
'int': int,
'integer': int,
'string': str,
'number': float,
'boolean': bool,
}.get(v, None), 'Property {} has no type'.format(name))
if not self._type:
raise InvalidSchema('Property {} has unsupported type: {}'.format(
name, dictionary['type']))
if self._default:
if not isinstance(self._default, self._type):
raise InvalidSchema(
'Property {} has a default value of invalid type'.format(name))
if self._x:
xt = _must_get(self._x, 'type',
'Property {} has {} without a type'.format(name, XGOOGLE))
if xt in (XTYPE_NAME, XTYPE_NAMESPACE, XTYPE_DEPLOYER_IMAGE,
XTYPE_MASKED_FIELD):
_property_must_have_type(self, str)
elif xt in (XTYPE_ISTIO_ENABLED, XTYPE_INGRESS_AVAILABLE):
_property_must_have_type(self, bool)
elif xt == XTYPE_APPLICATION_UID:
_property_must_have_type(self, str)
d = self._x.get('applicationUid', {})
self._application_uid = SchemaXApplicationUid(d)
elif xt == XTYPE_IMAGE:
_property_must_have_type(self, str)
d = self._x.get('image', {})
self._image = SchemaXImage(d, self._default)
elif xt == XTYPE_PASSWORD:
_property_must_have_type(self, str)
d = self._x.get('generatedPassword', {})
spec = {
'length': d.get('length', 10),
'include_symbols': d.get('includeSymbols', False),
'base64': d.get('base64', True),
}
self._password = SchemaXPassword(**spec)
elif xt == XTYPE_SERVICE_ACCOUNT:
_property_must_have_type(self, str)
d = self._x.get('serviceAccount', {})
self._service_account = SchemaXServiceAccount(d)
elif xt == XTYPE_STORAGE_CLASS:
_property_must_have_type(self, str)
d = self._x.get('storageClass', {})
self._storage_class = SchemaXStorageClass(d)
elif xt == XTYPE_STRING:
_property_must_have_type(self, str)
d = self._x.get('string', {})
self._string = SchemaXString(d)
elif xt == XTYPE_REPORTING_SECRET:
_property_must_have_type(self, str)
d = self._x.get('reportingSecret', {})
self._reporting_secret = SchemaXReportingSecret(d)
elif xt == XTYPE_TLS_CERTIFICATE:
_property_must_have_type(self, str)
d = self._x.get('tlsCertificate', {})
self._tls_certificate = SchemaXTlsCertificate(d)
else:
raise InvalidSchema('Property {} has an unknown type: {}'.format(
name, xt))