repository

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

Source Code Repositories

Voucher is capable of retrieving commit metadata from different version control sources (i.e., GitHub, GitLab, GitTea, etc.).

At the moment, Voucher supports GitHub metadata as a source.

Documentation

Index

Constants

View Source
const (
	Protocol      = "((?P<protocol>https?|git)(?:://|@))?"
	VCSName       = "(?P<vcs>[^/:]+)"
	OrgName       = "(?P<org>[^/.]+)"
	RepoName      = "(?P<repo>[^/.]+)"
	RepoExtension = "(?:.git)?"

	VCSRegex  = "^" + Protocol + VCSName + "/?$"
	OrgRegex  = "^" + Protocol + VCSName + "[/:]" + OrgName + "/?$"
	RepoRegex = "^" + Protocol + VCSName + "[/:]" + OrgName + "/" + RepoName + RepoExtension + "$"
)
View Source
const (
	CommitStatusError    = "ERROR"
	CommitStatusExpected = "EXPECTED"
	CommitStatusFAilure  = "FAILURE"
	CommitStatusPending  = "PENDING"
	CommitStatusSuccess  = "SUCCESS"
)
View Source
const GithubInstallType = "githubinstall"

GithubInstallType is the type representing a Github install

View Source
const TokenAuthType = "token"

TokenAuthType is the type representing a token-based authentication method

View Source
const UserPasswordAuthType = "userpassword"

UserPasswordAuthType is the type representing a token-based authentication method

Variables

This section is empty.

Functions

func NewTypeMismatchError

func NewTypeMismatchError(expected string, actual string) error

NewTypeMismatchError creates a new TypeMismatchError

Types

type App

type App struct {
	Name string
	URL  string
}

App contains the relevant information associated with a CI/CD app

type Auth

type Auth struct {
	Token          string `json:"token"`
	Username       string `json:"username"`
	Password       string `json:"password"`
	AppID          string `json:"_app_id"`
	InstallationID string `json:"_installation_id"`
	PrivateKey     string `json:"private_key"`
}

Auth holds the necessary information to connect to a repository source

func (*Auth) Type

func (a *Auth) Type() string

Type determines the authentication method being used to connect to a source

type Branch

type Branch struct {
	Name       string
	CommitRefs []CommitRef
}

Branch contains the information related to the repository's default branch

func NewBranch

func NewBranch(name string, commits []CommitRef) Branch

NewBranch returns a new Branch object

type BuildArtifact

type BuildArtifact struct {
	ID       string `json:"repository"`
	Checksum string `json:"commit"`
}

BuildArtifact is a type that describes the artifact info related to a build

func (*BuildArtifact) String

func (b *BuildArtifact) String() string

type BuildDetail

type BuildDetail struct {
	RepositoryURL string          `json:"repository"`
	Commit        string          `json:"commit"`
	BuildCreator  string          `json:"build_creator"`
	BuildURL      string          `json:"build_url"`
	ProjectID     string          `json:"project_id"`
	Artifacts     []BuildArtifact `json:"artifacts"`
}

BuildDetail is a type that describes the details/metadata info related to a build

func (*BuildDetail) String

func (b *BuildDetail) String() string

type Check

type Check struct {
	Status     string
	Conclusion string
}

Check is a collection of the check runs created by a single CI/CD App for a specific commit

func NewCheck

func NewCheck(status string, conclusion string) Check

NewCheck returns a new Check object

type Client

type Client interface {
	GetCommit(ctx context.Context, details BuildDetail) (Commit, error)
	GetOrganization(ctx context.Context, details BuildDetail) (Organization, error)
	GetBranch(ctx context.Context, details BuildDetail, name string) (Branch, error)
	GetDefaultBranch(ctx context.Context, details BuildDetail) (Branch, error)
}

Client is a client for a version control source

type Commit

type Commit struct {
	URL                    string
	Checks                 []Check
	Status                 string
	IsSigned               bool
	AssociatedPullRequests []PullRequest
}

Commit contains information pertaining to the validity of a commit

func NewCommit

func NewCommit(commitURL string, checks []Check, commitStatus string, isSigned bool, associatedPullRequests []PullRequest) Commit

NewCommit returns a new Commit object

type CommitRef

type CommitRef struct {
	URL string
}

CommitRef contains a URL referencing a commit

func NewCommitRef

func NewCommitRef(commitURL string) CommitRef

NewCommitRef returns a new CommitRef object

type Config

type Config struct {
	Auth            KeyRing
	Organization    string `json:"org-name"`
	OrganizationURL string `json:"org-url"`
}

Config contains the necessary parameters to authenticate/communicate with a source repository

type KeyRing

type KeyRing map[string]Auth

KeyRing contains all the authentication keys needed to communicate an org's repository source

type Metadata

type Metadata struct {
	VCS          string `json:"vcs"`
	Organization string `json:"organization"`
	Name         string `json:"name"`
}

Metadata describes the top level metadata information about a repo that one can get from the gitUrl

func NewRepositoryMetadata

func NewRepositoryMetadata(url string) *Metadata

func (*Metadata) String

func (metadata *Metadata) String() string

type MockClient

type MockClient struct {
	mock.Mock
}

func (*MockClient) GetBranch

func (m *MockClient) GetBranch(ctx context.Context, details BuildDetail, name string) (Branch, error)

func (*MockClient) GetCommit

func (m *MockClient) GetCommit(ctx context.Context, details BuildDetail) (Commit, error)

func (*MockClient) GetDefaultBranch

func (m *MockClient) GetDefaultBranch(ctx context.Context, details BuildDetail) (Branch, error)

func (*MockClient) GetOrganization

func (m *MockClient) GetOrganization(ctx context.Context, details BuildDetail) (Organization, error)

type Organization

type Organization struct {
	Alias string
	VCS   string
	Name  string
}

Organization contains repository information pertaining to an organization

func NewOrganization

func NewOrganization(alias string, url string) *Organization

type PullRequest

type PullRequest struct {
	BaseBranchName       string
	HeadBranchName       string
	IsMerged             bool
	MergeCommit          CommitRef
	HasRequiredApprovals bool
}

PullRequest contains information pertaining to a pull request

func NewPullRequest

func NewPullRequest(baseBranchName string, headBranchName string, isMerged bool, mergeCommit CommitRef, hasRequiredApprovals bool) PullRequest

NewPullRequest returns a new PullRequest object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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