Esempio n. 1
0
def validate_build_config(build_config):
    if build_config.service_role is not None:
        # Verify that the service role exists in the customers account
        from ebcli.lib.iam import get_roles
        role = build_config.service_role
        validated_role = None
        existing_roles = get_roles()
        for existing_role in existing_roles:
            if role == existing_role['Arn'] or role == existing_role[
                    'RoleName']:
                validated_role = existing_role['Arn']

        if validated_role is None:
            LOG.debug(
                "Role '{0}' not found in retrieved list of roles".format(role))
            raise ValidationError("Role '{0}' does not exist.".format(role))
        build_config.service_role = validated_role
    else:
        io.log_warning(
            "To learn more about creating a service role for CodeBuild, see Docs:"
            " https://docs-aws.amazon.com/codebuild/latest/userguide/setting-up.html#setting-up-service-role"
        )
        raise ValidationError(
            "No service role specified in buildspec; this is a required argument."
        )
        # Fail because the service role is required
    if build_config.image is None:
        #  Fail because the image is required
        raise ValidationError(
            "No image specified in buildspec; this is a required argument.")
Esempio n. 2
0
def validate_build_config(build_config):
    if build_config.service_role is not None:
        # Verify that the service role exists in the customers account
        from ebcli.lib.iam import get_roles
        role = build_config.service_role
        validated_role = None
        existing_roles = get_roles()
        for existing_role in existing_roles:
            if role == existing_role['Arn'] or role == existing_role['RoleName']:
                validated_role = existing_role['Arn']

        if validated_role is None:
            LOG.debug("Role '{0}' not found in retrieved list of roles".format(role))
            raise ValidationError("Role '{0}' does not exist.".format(role))
        build_config.service_role = validated_role
    else:
        io.log_warning("To learn more about creating a service role for CodeBuild, see Docs:"
                       " https://docs-aws.amazon.com/codebuild/latest/userguide/setting-up.html#setting-up-service-role")
        raise ValidationError("No service role specified in buildspec; this is a required argument.")
        # Fail because the service role is required
    if build_config.image is None:
        #  Fail because the image is required
        raise ValidationError("No image specified in buildspec; this is a required argument.")