external

package
v1.0.1-0...-c326910 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMatches = errors.New("no matches found")

ErrNoMatches is returned when no matches were found.

View Source
var Matchers = map[string]MatcherConstructor{
	"github":    NewGitHubMatcher,
	"gitlab":    NewGitLabMatcher,
	"bitbucket": NewBitBucketMatcher,
}

Matchers is the registered external matcher constructors mapped to shorthands.

Functions

func PathExists

func PathExists(path string) bool

PathExists reports whether a file or directory exists.

Types

type BitBucketMatcher

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

BitBucketMatcher matches emails and BitBucket users.

func (BitBucketMatcher) MatchByCommit

func (m BitBucketMatcher) MatchByCommit(
	ctx context.Context, email, repo, commit string) (user string, err error)

MatchByCommit queries the identity of a given email address in a particular commit context.

func (BitBucketMatcher) MatchByEmail

func (m BitBucketMatcher) MatchByEmail(ctx context.Context, email string) (user string, err error)

MatchByEmail returns the latest BitBucket user with the given email.

func (BitBucketMatcher) OnIdle

func (m BitBucketMatcher) OnIdle() error

OnIdle does nothing here.

func (BitBucketMatcher) SupportsMatchingByCommit

func (m BitBucketMatcher) SupportsMatchingByCommit() bool

SupportsMatchingByCommit indicates whether this Matcher allows querying identities by commit metadata.

type CachedMatcher

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

CachedMatcher is a wrapper around Matcher with the cache for queried emails.

func NewCachedMatcher

func NewCachedMatcher(matcher Matcher, cachePath string) (*CachedMatcher, error)

NewCachedMatcher creates a new matcher with a cache for a given matcher interface.

func (CachedMatcher) DumpCache

func (m CachedMatcher) DumpCache() error

DumpCache saves the current CachedMatcher cache on disk. It is a proxy for safeUserCache.DumpOnDisk() function.

func (*CachedMatcher) LoadCache

func (m *CachedMatcher) LoadCache() error

LoadCache reads the CachedMatcher cache from disk. It is a proxy for safeUserCache.LoadFromDisk() function.

func (*CachedMatcher) MatchByCommit

func (m *CachedMatcher) MatchByCommit(
	ctx context.Context, email, repo, commit string) (user string, err error)

MatchByCommit looks in the cache first, and if there is a cache miss, forwards to the underlying Matcher.

func (*CachedMatcher) MatchByEmail

func (m *CachedMatcher) MatchByEmail(ctx context.Context, email string) (user string, err error)

MatchByEmail looks in the cache first, and if there is a cache miss, forwards to the underlying Matcher.

func (CachedMatcher) OnIdle

func (m CachedMatcher) OnIdle() error

OnIdle saves the current CachedMatcher cache on disk.

func (*CachedMatcher) SupportsMatchingByCommit

func (m *CachedMatcher) SupportsMatchingByCommit() bool

SupportsMatchingByCommit acts the same as the underlying Matcher.

type CachedUser

type CachedUser struct {
	User    string
	Matched bool // false if there is no match from the external API
}

CachedUser represents personal name and username of a person

type GitHubMatcher

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

GitHubMatcher matches emails and GitHub users.

func (GitHubMatcher) MatchByCommit

func (m GitHubMatcher) MatchByCommit(
	ctx context.Context, email, repo, commit string) (user string, err error)

MatchByCommit queries the identity of a given email address in a particular commit context.

func (GitHubMatcher) MatchByEmail

func (m GitHubMatcher) MatchByEmail(ctx context.Context, email string) (user string, err error)

MatchByEmail returns the latest GitHub user with the given email.

func (GitHubMatcher) OnIdle

func (m GitHubMatcher) OnIdle() error

OnIdle does nothing here.

func (GitHubMatcher) SupportsMatchingByCommit

func (m GitHubMatcher) SupportsMatchingByCommit() bool

SupportsMatchingByCommit indicates whether this Matcher allows querying identities by commit metadata.

type GitLabMatcher

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

GitLabMatcher matches emails and GitLab users.

func (GitLabMatcher) MatchByCommit

func (m GitLabMatcher) MatchByCommit(
	ctx context.Context, email, repo, commit string) (user string, err error)

MatchByCommit queries the identity of a given email address in a particular commit context.

func (GitLabMatcher) MatchByEmail

func (m GitLabMatcher) MatchByEmail(ctx context.Context, email string) (user string, err error)

MatchByEmail returns the latest GitLab user with the given email.

func (GitLabMatcher) OnIdle

func (m GitLabMatcher) OnIdle() error

OnIdle does nothing here.

func (GitLabMatcher) SupportsMatchingByCommit

func (m GitLabMatcher) SupportsMatchingByCommit() bool

SupportsMatchingByCommit indicates whether this Matcher allows querying identities by commit metadata.

type Matcher

type Matcher interface {
	// MatchByEmail queries the identity of a given email address.
	MatchByEmail(ctx context.Context, email string) (user string, err error)
	// SupportsMatchingByCommit indicates whether this Matcher allows querying identities by commit metadata.
	SupportsMatchingByCommit() bool
	// MatchByCommit queries the identity of a given email address in a particular commit context.
	MatchByCommit(ctx context.Context, email, repo, commit string) (user string, err error)
	// OnIdle signals the underlying implementation that the current series of queries is over.
	OnIdle() error
}

Matcher defines the external matching service API, either by email or by commit.

func NewBitBucketMatcher

func NewBitBucketMatcher(apiURL, token string) (Matcher, error)

NewBitBucketMatcher creates a new matcher given a BitBucket personal access token. https://id.atlassian.com/manage/api-tokens

func NewGitHubMatcher

func NewGitHubMatcher(apiURL, token string) (Matcher, error)

NewGitHubMatcher creates a new matcher given a GitHub token. https://github.com/settings/tokens

func NewGitLabMatcher

func NewGitLabMatcher(apiURL, token string) (Matcher, error)

NewGitLabMatcher creates a new matcher given a GitLab OAuth token. https://gitlab.com/profile/personal_access_tokens

type MatcherConstructor

type MatcherConstructor func(apiURL, token string) (Matcher, error)

MatcherConstructor is the Matcher constructor function type.

Jump to

Keyboard shortcuts

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