v1

package
v0.0.47 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package v1 for providers provides the public interfaces for the providers implemented by minder. The providers are the sources of the data that is used by the rules.

Package v1 for providers provides the public interfaces for the providers implemented by minder. The providers are the sources of the data that is used by the rules.

Index

Constants

View Source
const (
	// CredentialStateSet is the state of a credential when it is set
	CredentialStateSet = "set"
	// CredentialStateUnset is the state of a credential when it is unset
	CredentialStateUnset = "unset"
	// CredentialStateNotApplicable is the state of a credential when it is not applicable
	CredentialStateNotApplicable = "not_applicable"
)
View Source
const (
	V1 = "v1"
)

V1 is the version of the providers interface

Variables

View Source
var (
	// ErrProviderGitBranchNotFound is returned when the branch is not found
	ErrProviderGitBranchNotFound = errors.New("branch not found")
	// ErrRepositoryEmpty is returned when the repository is empty
	ErrRepositoryEmpty = errors.New("repository is empty")
)

Functions

func ParseAndValidate

func ParseAndValidate(rawConfig json.RawMessage, to any) error

ParseAndValidate parses the given provider configuration and validates it.

Types

type Credential added in v0.0.36

type Credential interface {
}

Credential is the general interface for all credentials

type Git

type Git interface {
	Provider

	// Clone clones a git repository
	Clone(ctx context.Context, url string, branch string) (*git.Repository, error)
}

Git is the interface for git providers

type GitCredential added in v0.0.36

type GitCredential interface {
	AddToPushOptions(options *git.PushOptions, owner string)
	AddToCloneOptions(options *git.CloneOptions)
}

GitCredential is the interface for credentials used when performing git operations

type GitHub

type GitHub interface {
	Provider
	RepoLister
	REST
	Git

	GetCredential() GitHubCredential
	GetRepository(context.Context, string, string) (*github.Repository, error)
	GetBranchProtection(context.Context, string, string, string) (*github.Protection, error)
	UpdateBranchProtection(context.Context, string, string, string, *github.ProtectionRequest) error
	ListPackagesByRepository(context.Context, string, string, int64, int, int) ([]*github.Package, error)
	GetPackageByName(context.Context, string, string, string) (*github.Package, error)
	GetPackageVersions(context.Context, string, string, string) ([]*github.PackageVersion, error)
	GetPackageVersionByTag(context.Context, string, string, string, string) (*github.PackageVersion, error)
	GetPackageVersionById(context.Context, string, string, string, int64) (*github.PackageVersion, error)
	GetPullRequest(context.Context, string, string, int) (*github.PullRequest, error)
	CreateReview(context.Context, string, string, int, *github.PullRequestReviewRequest) (*github.PullRequestReview, error)
	UpdateReview(context.Context, string, string, int, int64, string) (*github.PullRequestReview, error)
	ListReviews(context.Context, string, string, int, *github.ListOptions) ([]*github.PullRequestReview, error)
	DismissReview(context.Context, string, string, int, int64,
		*github.PullRequestReviewDismissalRequest) (*github.PullRequestReview, error)
	SetCommitStatus(context.Context, string, string, string, *github.RepoStatus) (*github.RepoStatus, error)
	ListFiles(ctx context.Context, owner string, repo string, prNumber int,
		perPage int, pageNumber int) ([]*github.CommitFile, *github.Response, error)
	IsOrg() bool
	ListHooks(ctx context.Context, owner, repo string) ([]*github.Hook, error)
	DeleteHook(ctx context.Context, owner, repo string, id int64) (*github.Response, error)
	EditHook(ctx context.Context, owner, repo string, id int64, hook *github.Hook) (*github.Hook, error)
	CreateHook(ctx context.Context, owner, repo string, hook *github.Hook) (*github.Hook, error)
	CreateSecurityAdvisory(ctx context.Context, owner, repo, severity, summary, description string,
		v []*github.AdvisoryVulnerability) (string, error)
	CloseSecurityAdvisory(ctx context.Context, owner, repo, id string) error
	CreatePullRequest(ctx context.Context, owner, repo, title, body, head, base string) (*github.PullRequest, error)
	ClosePullRequest(ctx context.Context, owner, repo string, number int) (*github.PullRequest, error)
	ListPullRequests(ctx context.Context, owner, repo string, opt *github.PullRequestListOptions) ([]*github.PullRequest, error)
	GetUserId(ctx context.Context) (int64, error)
	GetName(ctx context.Context) (string, error)
	GetLogin(ctx context.Context) (string, error)
	GetPrimaryEmail(ctx context.Context) (string, error)
	CreateIssueComment(ctx context.Context, owner, repo string, number int, comment string) (*github.IssueComment, error)
	ListIssueComments(ctx context.Context, owner, repo string, number int,
		opts *github.IssueListCommentsOptions,
	) ([]*github.IssueComment, error)
	UpdateIssueComment(ctx context.Context, owner, repo string, number int64, comment string) error
	AddAuthToPushOptions(ctx context.Context, options *git.PushOptions) error
}

GitHub is the interface for interacting with the GitHub REST API Add methods here for interacting with the GitHub Rest API

type GitHubCredential added in v0.0.36

type GitHubCredential interface {
	RestCredential
	GitCredential

	GetCacheKey() string
	GetAsOAuth2TokenSource() oauth2.TokenSource
	// as we add new OCI providers this will change to a procedure / mutator, right now it's GitHub specific
	GetAsContainerAuthenticator(owner string) authn.Authenticator
}

GitHubCredential is the interface for credentials used when interacting with GitHub

type Provider

type Provider interface {
}

Provider is the general interface for all providers

type REST

type REST interface {
	Provider

	// GetBaseURL returns the base URL for the REST API.
	GetBaseURL() string

	// NewRequest creates an HTTP request.
	NewRequest(method, url string, body any) (*http.Request, error)

	// Do executes an HTTP request.
	Do(ctx context.Context, req *http.Request) (*http.Response, error)
}

REST is the interface for interacting with an REST API.

type RepoLister

type RepoLister interface {
	Provider

	ListAllRepositories(context.Context) ([]*minderv1.Repository, error)
}

RepoLister is the interface for listing repositories

type RestCredential added in v0.0.36

type RestCredential interface {
	SetAuthorizationHeader(req *http.Request)
}

RestCredential is the interface for credentials used in REST requests

Jump to

Keyboard shortcuts

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