linktransformer

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 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 ParseConfig(c []byte) (Config, error)

func (Config) GetValidatorForURL added in v0.9.0

func (v Config) GetValidatorForURL(URL string) Validator

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 Validator added in v0.9.0

type Validator interface {
	IsValid(k futureKey, r *validator) (bool, error)
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL