provider

package
v0.16.4 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderGitHub          = ProviderType(giturlapis.ProviderGitHub)
	ProviderGitlab          = ProviderType(giturlapis.ProviderGitLab)
	ProviderBitbucket       = ProviderType(giturlapis.ProviderBitBucket)
	ProviderAzure           = ProviderType(giturlapis.ProviderAzure)
	ProviderBitbucketServer = ProviderType("bitbucketserver")
	ProviderGitea           = ProviderType("gitea")
)
View Source
const (
	APITokenType = "api-token"
)

Variables

This section is empty.

Functions

func FromURL

func FromURL(repoURL string, options ...ProviderOption) (Provider, Repository, error)

Types

type Change

type Change struct {
	Path         string
	PreviousPath string
	Patch        string
	Sha          string
	Additions    int
	Deletions    int
	Changes      int
	Added        bool
	Renamed      bool
	Deleted      bool
}

type Comment

type Comment struct {
	ID   int
	Link string
	Body string
}

type GitHubAppConfig added in v0.16.4

type GitHubAppConfig struct {
	AppID          int64
	InstallationID int64
	PrivateKey     []byte
}

GitHubAppConfig holds the configuration for GitHub App authentication.

type GitHubProvider

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

func (*GitHubProvider) AddCommentToPullRequest

func (p *GitHubProvider) AddCommentToPullRequest(ctx context.Context, pr PullRequest, body []byte) (*Comment, error)

func (*GitHubProvider) GetLastComments

func (p *GitHubProvider) GetLastComments(ctx context.Context, pr PullRequest, since time.Time) ([]*Comment, error)

func (*GitHubProvider) ListPullRequestChanges

func (p *GitHubProvider) ListPullRequestChanges(ctx context.Context, pr PullRequest) ([]Change, error)

func (*GitHubProvider) ListPullRequests

func (p *GitHubProvider) ListPullRequests(ctx context.Context, repo Repository) ([]PullRequest, error)

func (*GitHubProvider) SetHostname

func (p *GitHubProvider) SetHostname(hostname string) error

func (*GitHubProvider) SetLogger

func (p *GitHubProvider) SetLogger(log logr.Logger) error

func (*GitHubProvider) SetToken

func (p *GitHubProvider) SetToken(tokenType, token string) error

func (*GitHubProvider) Setup

func (p *GitHubProvider) Setup() error

func (*GitHubProvider) UpdateCommentOfPullRequest

func (p *GitHubProvider) UpdateCommentOfPullRequest(ctx context.Context, pr PullRequest, commentID int, body []byte) error

type GitLabOAuthConfig added in v0.16.4

type GitLabOAuthConfig struct {
	ClientID     string
	ClientSecret string
	Token        string
	RefreshToken string
}

GitLabOAuthConfig holds the configuration for GitLab OAuth2 authentication with automatic token refresh.

type GitLabProvider added in v0.16.4

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

func (*GitLabProvider) AddCommentToPullRequest added in v0.16.4

func (p *GitLabProvider) AddCommentToPullRequest(ctx context.Context, pr PullRequest, body []byte) (*Comment, error)

func (*GitLabProvider) GetLastComments added in v0.16.4

func (p *GitLabProvider) GetLastComments(ctx context.Context, pr PullRequest, since time.Time) ([]*Comment, error)

func (*GitLabProvider) ListPullRequestChanges added in v0.16.4

func (p *GitLabProvider) ListPullRequestChanges(ctx context.Context, pr PullRequest) ([]Change, error)

func (*GitLabProvider) ListPullRequests added in v0.16.4

func (p *GitLabProvider) ListPullRequests(ctx context.Context, repo Repository) ([]PullRequest, error)

func (*GitLabProvider) SetHostname added in v0.16.4

func (p *GitLabProvider) SetHostname(hostname string) error

func (*GitLabProvider) SetLogger added in v0.16.4

func (p *GitLabProvider) SetLogger(log logr.Logger) error

func (*GitLabProvider) SetToken added in v0.16.4

func (p *GitLabProvider) SetToken(tokenType, token string) error

func (*GitLabProvider) Setup added in v0.16.4

func (p *GitLabProvider) Setup() error

func (*GitLabProvider) UpdateCommentOfPullRequest added in v0.16.4

func (p *GitLabProvider) UpdateCommentOfPullRequest(ctx context.Context, pr PullRequest, commentID int, body []byte) error

type Provider

type Provider interface {
	ListPullRequests(ctx context.Context, repo Repository) ([]PullRequest, error)
	AddCommentToPullRequest(ctx context.Context, repo PullRequest, body []byte) (*Comment, error)
	GetLastComments(ctx context.Context, pr PullRequest, since time.Time) ([]*Comment, error)
	UpdateCommentOfPullRequest(ctx context.Context, pr PullRequest, commentID int, body []byte) error
	ListPullRequestChanges(ctx context.Context, pr PullRequest) ([]Change, error)

	SetLogger(logr.Logger) error
	SetToken(tokenType, token string) error
	SetHostname(hostname string) error

	Setup() error
}

func New

func New(provider ProviderType, options ...ProviderOption) (Provider, error)

type ProviderOption

type ProviderOption func(Provider) error

func OptsFromSecret added in v0.16.4

func OptsFromSecret(data map[string][]byte) ([]ProviderOption, error)

OptsFromSecret builds provider options from a Kubernetes Secret's data map. It detects the auth type based on which keys are present:

  • "githubAppID" + "githubAppInstallationID" + "githubAppPrivateKey": GitHub App auth
  • "gitlabOAuthClientID" + "gitlabOAuthClientSecret" + "gitlabOAuthRefreshToken": GitLab OAuth2 with auto-refresh
  • "token": API token auth (PAT, Project/Group Access Token, etc.)

func WithDomain

func WithDomain(domain string) ProviderOption

func WithGitHubApp added in v0.16.4

func WithGitHubApp(cfg GitHubAppConfig) ProviderOption

func WithGitLabOAuth added in v0.16.4

func WithGitLabOAuth(cfg GitLabOAuthConfig) ProviderOption

func WithLogger

func WithLogger(log logr.Logger) ProviderOption

func WithSCMOAuth added in v0.16.4

func WithSCMOAuth(cfg SCMOAuthConfig) ProviderOption

func WithToken

func WithToken(tokenType, token string) ProviderOption

type ProviderType

type ProviderType string

type PullRequest

type PullRequest struct {
	Repository Repository
	Number     int
	BaseBranch string
	HeadBranch string
	BaseSha    string
	HeadSha    string
	Closed     bool
}

type Repository

type Repository struct {
	Project string
	Org     string
	Name    string
}

func RepoFromURL added in v0.16.4

func RepoFromURL(repoURL string) (Repository, error)

RepoFromURL parses a repository URL and returns the Repository without creating a provider. This is useful when the provider is already cached.

func (Repository) String

func (r Repository) String() string

type SCMOAuthConfig added in v0.16.4

type SCMOAuthConfig struct {
	ClientID     string
	ClientSecret string
	Token        string
	RefreshToken string
}

SCMOAuthConfig holds OAuth2 credentials for generic SCM providers (Bitbucket Cloud, Gitea) that support the refresh token grant.

type URLParserFn

type URLParserFn = func(repoURL string, options ...ProviderOption) (Provider, Repository, error)

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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