Documentation ¶
Index ¶
Constants ¶
const (
ContextKeyRegistryClient contextKey = iota
)
Variables ¶
This section is empty.
Functions ¶
func RegistryClient ¶ added in v0.6.1
func RegistryClient(ctx context.Context) connection.RegistryClient
Types ¶
type ApiDeploymentRule ¶
type ApiDeploymentRule struct { Name RuleName // OnlyIf determines whether this rule is applicable. OnlyIf func(p *rpc.ApiDeployment) bool // ApplyToApiDeployment accepts an ApiDeployment and checks it, // returning a slice of Problems it finds. ApplyToApiDeployment func(ctx context.Context, p *rpc.ApiDeployment) []*check.Problem }
func (*ApiDeploymentRule) Apply ¶
Apply calls ApplyToApiDeployment if the Resource is an ApiDeployment.
func (*ApiDeploymentRule) GetName ¶
func (r *ApiDeploymentRule) GetName() RuleName
GetName returns the name of the rule.
type ApiRule ¶
type ApiRule struct { Name RuleName // OnlyIf determines whether this rule is applicable. OnlyIf func(p *rpc.Api) bool // ApplyToApi accepts an Api and checks it, // returning a slice of Problems it finds. ApplyToApi func(ctx context.Context, p *rpc.Api) []*check.Problem }
type ApiSpecRule ¶
type ApiSpecRule struct { Name RuleName // OnlyIf determines whether this rule is applicable. OnlyIf func(p *rpc.ApiSpec) bool // ApiSpecRule accepts an ApiSpec and checks it, // returning a slice of Problems it finds. ApplyToApiSpec func(ctx context.Context, p *rpc.ApiSpec) []*check.Problem }
func (*ApiSpecRule) GetName ¶
func (r *ApiSpecRule) GetName() RuleName
GetName returns the name of the rule.
type ApiVersionRule ¶
type ApiVersionRule struct { Name RuleName // OnlyIf determines whether this rule is applicable. OnlyIf func(p *rpc.ApiVersion) bool // ApplyToApiVersion accepts a Version and checks it, // returning a slice of Problems it finds. ApplyToApiVersion func(ctx context.Context, p *rpc.ApiVersion) []*check.Problem }
func (*ApiVersionRule) GetName ¶
func (r *ApiVersionRule) GetName() RuleName
GetName returns the name of the rule.
type ArtifactRule ¶
type ArtifactRule struct { Name RuleName // OnlyIf determines whether this rule is applicable. OnlyIf func(p *rpc.Artifact) bool // ApplyToArtifact accepts an Artifact and checks it, // returning a slice of Problems it finds. ApplyToArtifact func(ctx context.Context, p *rpc.Artifact) []*check.Problem }
func (*ArtifactRule) GetName ¶
func (r *ArtifactRule) GetName() RuleName
GetName returns the name of the rule.
type Checker ¶
Checker checks API files and returns a list of detected problems.
func New ¶
func New(rules RuleRegistry, configs Configs) *Checker
New creates and returns a checker with the given rules and configs.
func (*Checker) Check ¶
func (l *Checker) Check(ctx context.Context, admin connection.AdminClient, client connection.RegistryClient, root names.Name, filter string, jobs int) (response *check.CheckReport, err error)
type Config ¶
type Config struct { IncludedPaths []string `json:"included_paths" yaml:"included_paths"` ExcludedPaths []string `json:"excluded_paths" yaml:"excluded_paths"` EnabledRules []string `json:"enabled_rules" yaml:"enabled_rules"` DisabledRules []string `json:"disabled_rules" yaml:"disabled_rules"` }
Config stores rule configurations for certain resource names such that the resource name must match any of the included paths but none of the excluded ones.
type Configs ¶
type Configs []Config
Configs determine if a rule is enabled or not.
func ReadConfigsFromFile ¶
ReadConfigsFromFile reads Configs from a file. It supports JSON(.json) and YAML(.yaml or .yml) files.
func ReadConfigsJSON ¶
ReadConfigsJSON reads Configs from a JSON file.
func ReadConfigsYAML ¶
ReadConfigsYAML reads Configs from a YAML(.yml or .yaml) file.
type FieldRule ¶
type FieldRule struct { Name RuleName // OnlyIf determines whether this rule is applicable. OnlyIf func(resource Resource, field string) bool // ApplyToField accepts a Field name and value and checks it, returning a slice of // Problems it finds. ApplyToField func(ctx context.Context, resource Resource, field string, value interface{}) []*check.Problem }
FieldRule defines a rule that is run on each field within a file.
type ProjectRule ¶
type ProjectRule struct { Name RuleName // OnlyIf determines whether this rule is applicable. OnlyIf func(p *rpc.Project) bool // ApplyToProject accepts a Project and checks it, // returning a slice of Problems it finds. ApplyToProject func(ctx context.Context, p *rpc.Project) []*check.Problem }
func (*ProjectRule) GetName ¶
func (r *ProjectRule) GetName() RuleName
GetName returns the name of the rule.
type Rule ¶
type Rule interface { // GetName returns the name of the rule. GetName() RuleName // Apply accepts a resource and checks it, // returning a slice of Problems it finds. Apply(ctx context.Context, resource Resource) []*check.Problem }
Rule defines a rule for checking a Resource. Anything that satisfies this interface can be used as a rule, but most rule authors will want to use the implementations provided.
type RuleName ¶
type RuleName string
RuleName is an identifier for a rule. Allowed characters include a-z, 0-9, -.
The namespace separator :: is allowed between RuleName segments (for example, my-namespace::my-rule).
func NewRuleName ¶
NewRuleName creates a RuleName from an rule number and a unique name within that rule.
func (RuleName) HasPrefix ¶
HasPrefix returns true if r contains prefix as a namespace. prefix parameters can be "::" delimited or specified as independent parameters. For example:
r := NewRuleName("foo", "bar", "baz") // string(r) == "foo::bar::baz"
r.HasPrefix("foo::bar") == true r.HasPrefix("foo", "bar") == true r.HasPrefix("foo", "bar", "baz") == true // matches the entire string r.HasPrefix("foo", "ba") == false // prefix must end on a delimiter
type RuleRegistry ¶
RuleRegistry is a registry for registering and looking up rules.
func NewRuleRegistry ¶
func NewRuleRegistry() RuleRegistry
NewRuleRegistry creates a new rule registry.