tracker

package
v0.0.0-...-95f3e3d Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	IssueTitleTemplate: "Update {{.Name}} to {{.LatestVersion}}",
	IssueTextTemplate:  "An update for `{{.Name}}` (version `{{.LatestVersion}}`) is now available. Version `{{.CurrentVersion}}` is currently in use.",
	OutdatedLabel:      "outdated-dependency",
}
View Source
var ErrIssueNotFound = errors.New("no such issue")

Functions

This section is empty.

Types

type Config

type Config struct {
	// IssueRepository is the repo to create issues in. If empty, defaults to
	// GITHUB_REPOSITORY and fails if neither is set.
	IssueRepository string `yaml:"issue_repository"`

	// IssueTitleTemplate and IssueTextTemplate are go text/templates that will be
	// used for creating the issue titles and content, respectively.
	IssueTitleTemplate string `yaml:"issue_title_template"`
	IssueTextTemplate  string `yaml:"issue_text_template"`

	// OutdatedLabel is the label to attach to created issues.
	OutdatedLabel string `yaml:"outdated_label"`

	// GoModules are a list of go module dependencies to check.
	GoModules []GoModule `yaml:"go_modules"`

	// GithubDeps are a list of github repos to check.
	GithubDeps []GithubDependency `yaml:"github_repos"`
}

Config represents the tracker configuration.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig loads the Config via a file. The file is expected to be YAML.

func (*Config) SetDefaults

func (c *Config) SetDefaults() error

SetDefaults applies default values to fields in the config.

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(f func(v interface{}) error) error

type Dependency

type Dependency struct {
	Name           string
	CurrentVersion string
	LatestVersion  string
}

Dependency is a named dependency with the current version being used and the latest version available.

type DependencyOptions

type DependencyOptions struct {
	// IgnoreVersionPattern is a pattern that allows you to ignore specific
	// versions matching the given string.
	IgnoreVersionPattern *Regexp `yaml:"ignore_version_pattern"`
}

DependencyOptions are options for individual dependencies.

type Github

type Github struct {
	// contains filtered or unexported fields
}

Github checks for outdated dependencies on Github projects.

func NewGithub

func NewGithub(check []GithubDependency, cli *github.Client) *Github

NewGithub creates a new Github tracker.

func (*Github) CheckOutdated

func (c *Github) CheckOutdated(ctx context.Context) ([]Dependency, error)

CheckOutdated will return the list of go module dependencies that can be updated.

type GithubDependency

type GithubDependency struct {
	Project string            `yaml:"project"`
	Version string            `yaml:"version"`
	Options DependencyOptions `yaml:",inline"`
}

GithubDependency is a dependency on a Github project.

func (*GithubDependency) UnmarshalYAML

func (d *GithubDependency) UnmarshalYAML(f func(interface{}) error) error

UnmarshalYAML will unmarshal a string or an object into a GithubDependency.

type GoModule

type GoModule struct {
	Name    string            `yaml:"name"`
	Options DependencyOptions `yaml:",inline"`
}

GoModule is an individual module to check.

func (*GoModule) UnmarshalYAML

func (m *GoModule) UnmarshalYAML(f func(v interface{}) error) error

UnmarshalYAML unmarshals a GoModule. The value can either be a string or the GoModule struct.

type GoModules

type GoModules struct {
	// contains filtered or unexported fields
}

GoModules checks for outdated dependencies for Go modules.

func NewGoModules

func NewGoModules(module string, check []GoModule) *GoModules

NewGoModules creates a new GoModules tracker.

func (*GoModules) CheckOutdated

func (c *GoModules) CheckOutdated(ctx context.Context) ([]Dependency, error)

CheckOutdated will return the list of go module dependencies that can be updated.

type IssueCreator

type IssueCreator struct {
	// contains filtered or unexported fields
}

IssueCreator can create issues for a set of dependencies.

func NewIssueCreator

func NewIssueCreator(c *Config, cli *github.Client) (*IssueCreator, error)

NewIssueCreator creates a new issue creator.

func (*IssueCreator) CloseOutdated

func (c *IssueCreator) CloseOutdated(ctx context.Context, latest *github.Issue, dep Dependency) error

CloseOutdated closes issues for dep that are older than latest.

func (*IssueCreator) CreateIssue

func (c *IssueCreator) CreateIssue(ctx context.Context, dep Dependency) (*github.Issue, error)

Create will create issues for a dep. If an issue already exists (including if it is closed), then it will not be recreated. The associated issue is returned.

func (*IssueCreator) FindIssue

func (c *IssueCreator) FindIssue(ctx context.Context, dep Dependency) (*github.Issue, error)

FindIssue looks for an existing issue associated with a dependency.

type Multi

type Multi struct {
	// contains filtered or unexported fields
}

Multi combines multiple trackers.

func (*Multi) CheckOutdated

func (m *Multi) CheckOutdated(ctx context.Context) ([]Dependency, error)

CheckOutdated calls CheckOutdated for each tracker in the list.

type Regexp

type Regexp regexp.Regexp

Regexp is a regex that can be unmarshaled from a string.

func (*Regexp) Matches

func (r *Regexp) Matches(s string) bool

Matches returns true if s matches the regular expression.

func (*Regexp) UnmarshalYAML

func (r *Regexp) UnmarshalYAML(f func(v interface{}) error) error

type Tracker

type Tracker interface {
	// CheckOutdated should return a list of only outdated dependencies.
	CheckOutdated(ctx context.Context) ([]Dependency, error)
}

Tracker can return a list of outdated dependencies.

func New

func New(c *Config, repo string, cli *github.Client) Tracker

New creates a new Tracker that can return outdated dependencies.

Jump to

Keyboard shortcuts

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