def validateImage(self, root, path): super(GoogleService, self).validateImage(root, path) validate.path_val(root, path + ['machineType'], 'string', 'n1-standard-1') validate.path_val(root, path + ['source'], 'string') validate.path_val(root, path + ['zone'], 'string') validate.obj_only(root, path, {'cmds', 'machineType', 'source', 'zone'})
def validateImage(self, root, path): super(AmazonService, self).validateImage(root, path) validate.path_val(root, path + ['instanceType'], 'string', 'n1-standard-1') validate.path_val(root, path + ['sourceAmi'], 'string') validate.path_val(root, path + ['sshUser'], 'string') validate.obj_only(root, path, {'cmds', 'instanceType', 'sourceAmi', 'sshUser'})
def validateEnvironment(self, root, path): fields = {'kind', 'project', 'region', 'sshUser', 'serviceAccount'} validate.obj_only(root, path, fields) validate.path_val(root, path + ['project'], 'string') validate.path_val(root, path + ['region'], 'string') validate.path_val(root, path + ['sshUser'], 'string') acc = validate.path_val(root, path + ['serviceAccount'], 'object') validate.path_val(root, path + ['serviceAccount', 'client_email'], 'string') validate.path_val(root, path + ['serviceAccount', 'private_key'], 'string') validate.path_val(root, path + ['serviceAccount', 'type'], validate.is_value('service_account'), 'service_account') validate.path_val(root, path + ['serviceAccount', 'client_id'], 'string', '') validate.path_val(root, path + ['serviceAccount', 'private_key_id'], 'string', '') fields = {'client_email', 'private_key', 'type', 'client_id', 'private_key_id'} validate.obj_only(root, path + ['serviceAccount'], fields)
def validateEnvironment(self, env_name, env): ctx = 'Environment "%s"' % env_name fields = ['kind', 'project', 'region', 'sshUser', 'serviceAccount'] validate.obj_only(ctx, env, fields) validate.obj_field(ctx, env, 'project', 'string') validate.obj_field(ctx, env, 'region', 'string') validate.obj_field(ctx, env, 'sshUser', 'string') acc = validate.obj_field(ctx, env, 'serviceAccount', validate.is_type('object')) validate.obj_field(ctx + ' serviceAccount', acc, 'client_email', 'string') validate.obj_field(ctx + ' serviceAccount', acc, 'private_key', 'string') validate.obj_field_opt(ctx + ' serviceAccount', acc, 'type', validate.is_value('service_account')) validate.obj_field_opt(ctx + ' serviceAccount', acc, 'client_id', 'string') validate.obj_field_opt(ctx + ' serviceAccount', acc, 'private_key_id', 'string') fields = ['client_email', 'private_key', 'type', 'client_id', 'private_key_id'] validate.obj_only(ctx + ' serviceAccount', acc, fields)
def validateCmds(self, root, path): cmds = validate.array(root, path, validate.is_any_type({'string', 'object'}), []) for i, cmd in enumerate(cmds): cmd_path = path + [i] if isinstance(cmd, basestring): # Any string will do for validation purposes. pass elif isinstance(cmd, dict): kinds = {'CopyFile', 'LiteralFile', 'EnsureDir'} kind = validate.path_val(root, cmd_path + ['kind'], validate.is_any_value(kinds)) if kind == 'CopyFile': fields = {'owner', 'group', 'dirPermissions', 'filePermissions', 'from', 'to'} for f in fields: validate.path_val(root, cmd_path + [f], 'string') validate.obj_only(root, cmd_path, fields | {'kind'}) elif kind == 'LiteralFile': fields = {'owner', 'group', 'filePermissions', 'content', 'to'} for f in fields: validate.path_val(root, cmd_path + [f], 'string') validate.obj_only(root, cmd_path, fields | {'kind'}) elif cmd['kind'] == 'EnsureDir': fields = {'owner', 'group', 'dirPermissions', 'dir'} for f in fields: validate.path_val(root, cmd_path + [f], 'string') validate.obj_only(root, cmd_path, fields | {'kind'}) else: raise RuntimeError('Internal error: %s' % kind) else: raise RuntimeError('Internal error: %s' % type(cmd))
def validateCmds(self, root, path): cmds = validate.array(root, path, validate.is_any_type({'string', 'object'}), []) for i, cmd in enumerate(cmds): cmd_path = path + [i] if isinstance(cmd, basestring): # Any string will do for validation purposes. pass elif isinstance(cmd, dict): kinds = {'CopyFile', 'LiteralFile', 'EnsureDir'} kind = validate.path_val(root, cmd_path + ['kind'], validate.is_any_value(kinds)) if kind == 'CopyFile': fields = { 'owner', 'group', 'dirPermissions', 'filePermissions', 'from', 'to' } for f in fields: validate.path_val(root, cmd_path + [f], 'string') validate.obj_only(root, cmd_path, fields | {'kind'}) elif kind == 'LiteralFile': fields = { 'owner', 'group', 'filePermissions', 'content', 'to' } for f in fields: validate.path_val(root, cmd_path + [f], 'string') validate.obj_only(root, cmd_path, fields | {'kind'}) elif cmd['kind'] == 'EnsureDir': fields = {'owner', 'group', 'dirPermissions', 'dir'} for f in fields: validate.path_val(root, cmd_path + [f], 'string') validate.obj_only(root, cmd_path, fields | {'kind'}) else: raise RuntimeError('Internal error: %s' % kind) else: raise RuntimeError('Internal error: %s' % type(cmd))
def validateEnvironment(self, root, path): fields = {'kind', 'accessKey', 'secretKey', 'region'} validate.obj_only(root, path, fields) validate.path_val(root, path + ['region'], 'string') validate.path_val(root, path + ['accessKey'], 'string') validate.path_val(root, path + ['secretKey'], 'string')