示例#1
0
def config_check_service(environments, ctx, service_name, service):
    try:
        ctx = ctx + [service_name] 
        validate.value(ctx, service, 'object')
        env_name = validate.obj_field_opt(ctx, service, 'environment', 'string')
        default = env_name is None
        if default:
            env_name = 'default'
        env = environments.get(env_name)
        if env is None:
            if default:
                raise validate.ConfigError(('The service at %s has no environment field, and no ' +
                                            'environment called "default" exists.')
                                            % validate.render_path(ctx))
            else:
                raise validate.ConfigError('In %s, unrecognized environment %s'
                                  % (validate.render_path(ctx), env_name))
        compiler = service_compilers.get(env['kind'])
        compiler.validateService(ctx, service_name, service)
        for child_name, child in compiler.children(service):
            config_check_service(environments, ctx, child_name, child)
    except validate.ConfigError as e:
        if e.note is None:
            e.note = ('Did you mean for %s to be a visible field (: instead of ::)?'
                      % validate.render_path(ctx))
        raise
示例#2
0
    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)
示例#3
0
 def validateService(self, ctx, service_name, service):
     ctx = ctx + [service_name]
     validate.obj_field_opt(ctx, service, 'outputs', validate.is_string_map)
     validate.obj_field_opt(ctx, service, 'infrastructure', 'object')