clients

package
v3.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package clients defines the interface for RepoClient and related structs.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedFeature = errors.New("unsupported feature")

ErrUnsupportedFeature indicates an API that is not supported by the client.

Functions

This section is empty.

Types

type BadgeLevel added in v3.2.1

type BadgeLevel uint

BadgeLevel corresponds to CII-Best-Practices badge levels. https://bestpractices.coreinfrastructure.org/en

const (
	// Unknown or non-parsable CII Best Practices badge.
	Unknown BadgeLevel = iota
	// NotFound represents when CII Best Practices returns an empty response for a project.
	NotFound
	// InProgress state of CII Best Practices badge.
	InProgress
	// Passing level for CII Best Practices badge.
	Passing
	// Silver level for CII Best Practices badge.
	Silver
	// Gold level for CII Best Practices badge.
	Gold
)

type BadgeResponse added in v3.2.1

type BadgeResponse struct {
	BadgeLevel string `json:"badge_level"`
}

BadgeResponse struct is used to read/write CII Best Practices badge data.

func ParseBadgeResponseFromJSON added in v3.2.1

func ParseBadgeResponseFromJSON(data []byte) ([]BadgeResponse, error)

ParseBadgeResponseFromJSON parses input []byte value into []BadgeResponse.

func (BadgeResponse) AsJSON added in v3.2.1

func (resp BadgeResponse) AsJSON() ([]byte, error)

AsJSON outputs BadgeResponse struct in JSON format.

type BranchProtectionRule

type BranchProtectionRule struct {
	RequiredPullRequestReviews PullRequestReviewRule
	AllowDeletions             *bool
	AllowForcePushes           *bool
	RequireLinearHistory       *bool
	EnforceAdmins              *bool
	CheckRules                 StatusChecksRule
}

BranchProtectionRule captures the settings enabled on a branch for security.

type BranchRef

type BranchRef struct {
	Name                 *string
	Protected            *bool
	BranchProtectionRule BranchProtectionRule
}

BranchRef represents a single branch reference and its protection rules.

type CIIBestPracticesClient added in v3.2.1

type CIIBestPracticesClient interface {
	GetBadgeLevel(ctx context.Context, uri string) (BadgeLevel, error)
}

CIIBestPracticesClient interface returns the BadgeLevel for a repo URL.

func BlobCIIBestPracticesClient added in v3.2.1

func BlobCIIBestPracticesClient(bucketURL string) CIIBestPracticesClient

BlobCIIBestPracticesClient returns a blob-based implementation of the interface.

func DefaultCIIBestPracticesClient added in v3.2.1

func DefaultCIIBestPracticesClient() CIIBestPracticesClient

DefaultCIIBestPracticesClient returns http-based implementation of the interface.

type CheckRun

type CheckRun struct {
	Status     string
	Conclusion string
	URL        string
	App        CheckRunApp
}

CheckRun is a single instance of a VCS CheckRun.

type CheckRunApp

type CheckRunApp struct {
	Slug string
}

CheckRunApp is the app running the Check.

type Commit

type Commit struct {
	CommittedDate time.Time
	Message       string
	SHA           string
	Committer     User
}

Commit represents a Git commit.

type Contributor

type Contributor struct {
	Company          string
	User             User
	Organizations    []User
	NumContributions int
}

Contributor represents a contributor to a repo.

type Issue added in v3.2.1

type Issue struct {
	URI       *string
	UpdatedAt *time.Time
}

Issue represents a thread like GitHub issue comment thread.

type Label

type Label struct {
	Name string
}

Label represents a PR label.

type PullRequest

type PullRequest struct {
	MergedAt    time.Time
	MergeCommit Commit
	Number      int
	HeadSHA     string
	Labels      []Label
	Reviews     []Review
	Author      User
}

PullRequest struct represents a PR as returned by RepoClient. nolint: govet

type PullRequestReviewRule

type PullRequestReviewRule struct {
	RequiredApprovingReviewCount *int32
	DismissStaleReviews          *bool
	RequireCodeOwnerReviews      *bool
}

PullRequestReviewRule captures settings on a PullRequest.

type Release

type Release struct {
	TagName         string
	URL             string
	TargetCommitish string
	Assets          []ReleaseAsset
}

Release represents a release version of a package/repo.

type ReleaseAsset

type ReleaseAsset struct {
	Name string
	URL  string
}

ReleaseAsset is part of the Release bundle.

type Repo

type Repo interface {
	URI() string
	String() string
	Org() Repo
	IsValid() error
	Metadata() []string
	AppendMetadata(metadata ...string)
}

Repo interface uniquely identifies a repo.

type RepoClient

type RepoClient interface {
	InitRepo(repo Repo) error
	URI() string
	IsArchived() (bool, error)
	ListFiles(predicate func(string) (bool, error)) ([]string, error)
	GetFileContent(filename string) ([]byte, error)
	ListMergedPRs() ([]PullRequest, error)
	ListBranches() ([]*BranchRef, error)
	GetDefaultBranch() (*BranchRef, error)
	ListCommits() ([]Commit, error)
	ListIssues() ([]Issue, error)
	ListReleases() ([]Release, error)
	ListContributors() ([]Contributor, error)
	ListSuccessfulWorkflowRuns(filename string) ([]WorkflowRun, error)
	ListCheckRunsForRef(ref string) ([]CheckRun, error)
	ListStatuses(ref string) ([]Status, error)
	Search(request SearchRequest) (SearchResponse, error)
	Close() error
}

RepoClient interface is used by Scorecard checks to access a repo.

type Review

type Review struct {
	State string
}

Review represents a PR review.

type SearchRequest

type SearchRequest struct {
	Query    string
	Filename string
	Path     string
}

SearchRequest queries a repo for `Query`. If `Filename` is provided, only matching filenames are queried. If `Path` is provided, only files with matching paths are queried.

type SearchResponse

type SearchResponse struct {
	Results []SearchResult
	Hits    int
}

SearchResponse returns the results from a search request on a repo.

type SearchResult

type SearchResult struct {
	Path string
}

SearchResult represents a matching result from the search query.

type Status

type Status struct {
	State   string
	Context string
	URL     string
}

Status for a Git object/ref.

type StatusChecksRule

type StatusChecksRule struct {
	UpToDateBeforeMerge  *bool
	RequiresStatusChecks *bool
	Contexts             []string
}

StatusChecksRule captures settings on status checks.

type User

type User struct {
	Login string
}

User represents a Git user.

type WorkflowRun

type WorkflowRun struct {
	URL string
}

WorkflowRun represents VCS WorkflowRun.

Directories

Path Synopsis
Package githubrepo implements clients.RepoClient for GitHub.
Package githubrepo implements clients.RepoClient for GitHub.
roundtripper
Package roundtripper has implementations of http.RoundTripper useful to clients.RepoClient.
Package roundtripper has implementations of http.RoundTripper useful to clients.RepoClient.
roundtripper/tokens
Package tokens defines interface to access GitHub PATs.
Package tokens defines interface to access GitHub PATs.
roundtripper/tokens/server
Package main implements the GitHub token server.
Package main implements the GitHub token server.
Package localdir implements RepoClient on local source code.
Package localdir implements RepoClient on local source code.
Package mockrepo is a generated GoMock package.
Package mockrepo is a generated GoMock package.

Jump to

Keyboard shortcuts

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