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 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) 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, 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 Validators []ValidatorConfig `yaml:"validators"` Timeout string `yaml:"timeout"` // 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)
IgnoreValidator.IsValid returns true if matched so that link in not checked.
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.
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` or `ignore`. Type ValidatorType `yaml:"type"` // GitHub repo token to avoid getting rate limited. Token string `yaml:"token"` // contains filtered or unexported fields }
type ValidatorType ¶ added in v0.9.0
type ValidatorType string