Documentation
¶
Index ¶
- Variables
- func MustNewValidator(logger log.Logger, linksValidateConfig []byte, anchorDir string, ...) mdformatter.LinkTransformer
- func NewChain(c ...mdformatter.LinkTransformer) mdformatter.LinkTransformer
- func NewLocalizer(logger log.Logger, address *regexp.Regexp, anchorDir string) mdformatter.LinkTransformer
- func NewValidator(ctx context.Context, logger log.Logger, linksValidateConfig []byte, ...) (mdformatter.LinkTransformer, error)
- type Config
- type GitHubPullsIssuesValidator
- type GitHubResponse
- type IgnoreValidator
- type LocalValidator
- type LookupError
- type RoundTripValidator
- type Validator
- type ValidatorConfig
- type ValidatorType
Constants ¶
This section is empty.
Variables ¶
var ( FileNotFoundErr = LookupError(errors.New("file not found")) IDNotFoundErr = LookupError(errors.New("file exists, but does not have such id")) )
Functions ¶
func MustNewValidator ¶ added in v0.2.0
func MustNewValidator(logger log.Logger, linksValidateConfig []byte, anchorDir string, storage *cache.SQLite3Storage) mdformatter.LinkTransformer
MustNewValidator returns mdformatter.LinkTransformer that crawls all links.
func NewChain ¶
func NewChain(c ...mdformatter.LinkTransformer) mdformatter.LinkTransformer
func NewLocalizer ¶
func NewLocalizer(logger log.Logger, address *regexp.Regexp, anchorDir string) mdformatter.LinkTransformer
NewLocalizer returns mdformatter.LinkTransformer that transforms links that matches address via given regexp to local markdown file path (if exists).
func NewValidator ¶
func NewValidator(ctx context.Context, logger log.Logger, linksValidateConfig []byte, anchorDir string, storage *cache.SQLite3Storage, reg *prometheus.Registry) (mdformatter.LinkTransformer, error)
NewValidator returns mdformatter.LinkTransformer that crawls all links. TODO(bwplotka): Add optimization and debug modes - this is the main source of latency and pain.
Types ¶
type Config ¶ added in v0.9.0
type Config struct {
Version int
Cache cache.Config `yaml:"cache"`
// ExplicitLocalValidators forces all links (remote and local) to go through validators.
// If false (default), only http(s) links go to validators.
// Use it for additional the validation options on local links.
ExplicitLocalValidators bool `yaml:"explicitLocalValidators"`
Validators []ValidatorConfig `yaml:"validators"`
Timeout string `yaml:"timeout"`
Parallelism int `yaml:"parallelism"`
// HostMaxConns has to be a pointer because a zero value means no limits
// and we have to tell apart 0 from not-present configurations.
HostMaxConns *int `yaml:"host_max_conns"`
RandomDelay string `yaml:"random_delay"`
// contains filtered or unexported fields
}
func ParseConfig ¶ added in v0.9.0
func (Config) GetValidatorForURL ¶ added in v0.9.0
GetValidatorForURL returns correct Validator by matching URL.
type GitHubPullsIssuesValidator ¶ added in v0.9.0
type GitHubPullsIssuesValidator struct {
// contains filtered or unexported fields
}
func (GitHubPullsIssuesValidator) IsValid ¶ added in v0.9.0
func (v GitHubPullsIssuesValidator) IsValid(k futureKey, r *validator) (bool, error)
GitHubPullsIssuesValidator.IsValid skips visiting all GitHub issue/PR links.
type GitHubResponse ¶ added in v0.9.0
type GitHubResponse struct {
Number int `json:"number"`
}
type IgnoreValidator ¶ added in v0.9.0
type IgnoreValidator struct {
// contains filtered or unexported fields
}
func (IgnoreValidator) IsValid ¶ added in v0.9.0
func (v IgnoreValidator) IsValid(k futureKey, r *validator) (bool, error)
IsValid returns true if matched so that link in not checked.
type LocalValidator ¶ added in v0.10.0
type LocalValidator struct {
// contains filtered or unexported fields
}
func (LocalValidator) IsValid ¶ added in v0.10.0
func (v LocalValidator) IsValid(k futureKey, r *validator) (bool, error)
type LookupError ¶
type LookupError error
type RoundTripValidator ¶ added in v0.9.0
type RoundTripValidator struct {
// contains filtered or unexported fields
}
func (RoundTripValidator) IsValid ¶ added in v0.9.0
func (v RoundTripValidator) IsValid(k futureKey, r *validator) (bool, error)
RoundTripValidator.IsValid returns true if URL is checked by colly or it is a valid local link.
type ValidatorConfig ¶ added in v0.9.0
type ValidatorConfig struct {
// Regex for type of validator. For `githubPullsIssues` this is: (^http[s]?:\/\/)(www\.)?(github\.com\/){ORG_NAME}\/{REPO_NAME}(\/pull\/|\/issues\/).
Regex string `yaml:"regex"`
// By default type is `roundtrip`. Could be `githubPullsIssues`, `ignore`, or `local`.
Type ValidatorType `yaml:"type"`
// GitHub repo token to avoid getting rate limited.
Token string `yaml:"token"`
// Anchor for additional path to add before the local link check.
Anchor string `yaml:"anchor"`
// contains filtered or unexported fields
}
type ValidatorType ¶ added in v0.9.0
type ValidatorType string