Skip to main content
Glama
attrs_validators.bzl1.79 kB
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under both the MIT license found in the # LICENSE-MIT file in the root directory of this source tree and the Apache # License, Version 2.0 found in the LICENSE-APACHE file in the root directory # of this source tree. _ATTRS_VALIDATORS_NAME = "attrs_validators" AttrsValidatorsInfo = provider( fields = { "func": typing.Callable[[AnalysisActions, Label, struct], dict[str, Artifact]], }, ) def get_attrs_validation_specs(ctx: AnalysisContext) -> list[ValidationSpec]: validators = getattr(ctx.attrs, _ATTRS_VALIDATORS_NAME, []) if not validators: return [] specs = [] for validator in validators: for name, output in validator[AttrsValidatorsInfo].func(ctx.actions, ctx.label, ctx.attrs).items(): specs.append(ValidationSpec(name = name, validation_result = output)) return specs def _attrs_validators_arg(): return { _ATTRS_VALIDATORS_NAME: attrs.option( attrs.list(attrs.dep(providers = [AttrsValidatorsInfo])), default = None, ), } def _validation_specs_arg(): return { "validation_specs": attrs.dict( attrs.string(), attrs.source(doc = """ An artifact pointing to a JSON file that will be used in ValidationSpec. { "version": 1, "data": { "message": "What goes in stderr", "status": "success" | "failure", } } """), default = {}, ), } validation_common = struct( attrs_validators_arg = _attrs_validators_arg, validation_specs_arg = _validation_specs_arg, )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/systeminit/si'

If you have feedback or need assistance with the MCP directory API, please join our Discord server