Documentation
¶
Index ¶
- Variables
- func InCI() bool
- type Branch
- type DefaultGithubClient
- func (g *DefaultGithubClient) CreateRelease(opts *github.RepositoryRelease) (*github.RepositoryRelease, error)
- func (g *DefaultGithubClient) Env() GithubEnv
- func (g *DefaultGithubClient) GetReleaseByTag(tag string) (*github.RepositoryRelease, error)
- func (g *DefaultGithubClient) ListBranches() ([]Branch, error)
- func (g *DefaultGithubClient) ListPullRequestComments(prNumber int) ([]PullRequestComment, error)
- func (g *DefaultGithubClient) PostPullRequestComment(prNumber int, body string) error
- func (g *DefaultGithubClient) UploadReleaseAsset(releaseID int64, path string) error
- type DefaultGithubClientOption
- func WithCreds(creds *common.Secret) DefaultGithubClientOption
- func WithCredsOrEnv(creds *common.Secret) DefaultGithubClientOption
- func WithFs(fs fs.Filesystem) DefaultGithubClientOption
- func WithGithubClient(client *github.Client) DefaultGithubClientOption
- func WithGithubEnv(env GithubEnv) DefaultGithubClientOption
- func WithLogger(logger *slog.Logger) DefaultGithubClientOption
- func WithSecretStore(ss *secrets.SecretStore) DefaultGithubClientOption
- type DefaultGithubClientOptions
- type DefaultGithubEnv
- func (g *DefaultGithubEnv) GetBranch() string
- func (g *DefaultGithubEnv) GetEventPayload() (any, error)
- func (g *DefaultGithubEnv) GetEventType() string
- func (g *DefaultGithubEnv) GetPRNumber() int
- func (g *DefaultGithubEnv) GetTag() string
- func (g *DefaultGithubEnv) HasEvent() bool
- func (g *DefaultGithubEnv) IsPR() bool
- type GithubClient
- type GithubEnv
- type GithubProviderCreds
- type PullRequestComment
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoGitHubToken = fmt.Errorf("no GitHub token found") ErrNoRepository = fmt.Errorf("no repository information found") ErrInvalidPR = fmt.Errorf("invalid pull request number") ErrReleaseNotFound = fmt.Errorf("release not found") )
var ( ErrNoEventFound = fmt.Errorf("no GitHub event data found") ErrTagNotFound = fmt.Errorf("tag not found") )
Functions ¶
Types ¶
type DefaultGithubClient ¶
type DefaultGithubClient struct {
Owner string
RepoName string
// contains filtered or unexported fields
}
DefaultGithubClient is the default implementation of the Github client.
func NewDefaultGithubClient ¶
func NewDefaultGithubClient(owner, repoName string, opts ...DefaultGithubClientOption) (*DefaultGithubClient, error)
NewDefaultGithubClient creates a new DefaultGithubClient with a *github.Client and repository owner and name.
func (*DefaultGithubClient) CreateRelease ¶
func (g *DefaultGithubClient) CreateRelease(opts *github.RepositoryRelease) (*github.RepositoryRelease, error)
CreateRelease creates a new release.
func (*DefaultGithubClient) Env ¶
func (g *DefaultGithubClient) Env() GithubEnv
Env returns the Github environment.
func (*DefaultGithubClient) GetReleaseByTag ¶
func (g *DefaultGithubClient) GetReleaseByTag(tag string) (*github.RepositoryRelease, error)
GetReleaseByTag gets a release by tag.
func (*DefaultGithubClient) ListBranches ¶
func (g *DefaultGithubClient) ListBranches() ([]Branch, error)
ListBranches lists all branches in the repository.
func (*DefaultGithubClient) ListPullRequestComments ¶
func (g *DefaultGithubClient) ListPullRequestComments(prNumber int) ([]PullRequestComment, error)
ListPullRequestComments lists comments for a pull request.
func (*DefaultGithubClient) PostPullRequestComment ¶
func (g *DefaultGithubClient) PostPullRequestComment(prNumber int, body string) error
PostPullRequestComment posts a comment to a pull request.
func (*DefaultGithubClient) UploadReleaseAsset ¶
func (g *DefaultGithubClient) UploadReleaseAsset(releaseID int64, path string) error
UploadReleaseAsset uploads a release asset to the given release.
type DefaultGithubClientOption ¶
type DefaultGithubClientOption func(*DefaultGithubClient)
func WithCreds ¶
func WithCreds(creds *common.Secret) DefaultGithubClientOption
WithCreds sets the credentials for the Github client.
func WithCredsOrEnv ¶
func WithCredsOrEnv(creds *common.Secret) DefaultGithubClientOption
WithCredsOrEnv sets the credentials for the Github client. If a GITHUB_TOKEN environment variable is set, it will use that token. Otherwise, it will use the given secret.
func WithFs ¶
func WithFs(fs fs.Filesystem) DefaultGithubClientOption
WithFs sets the filesystem for the Github client.
func WithGithubClient ¶
func WithGithubClient(client *github.Client) DefaultGithubClientOption
WithGithubClient sets the native Github client for the Github client.
func WithGithubEnv ¶
func WithGithubEnv(env GithubEnv) DefaultGithubClientOption
WithGithubEnv sets the Github environment for the Github client.
func WithLogger ¶
func WithLogger(logger *slog.Logger) DefaultGithubClientOption
WithLogger sets the logger for the Github client.
func WithSecretStore ¶
func WithSecretStore(ss *secrets.SecretStore) DefaultGithubClientOption
WithSecretStore sets the secret store for the Github client.
type DefaultGithubEnv ¶
type DefaultGithubEnv struct {
// contains filtered or unexported fields
}
DefaultGithubEnv provides the default implementation of the GithubEnv interface.
func (*DefaultGithubEnv) GetBranch ¶
func (g *DefaultGithubEnv) GetBranch() string
GetBranch returns the current branch from the CI environment.
func (*DefaultGithubEnv) GetEventPayload ¶
func (g *DefaultGithubEnv) GetEventPayload() (any, error)
GetEventPayload returns the GitHub event payload.
func (*DefaultGithubEnv) GetEventType ¶
func (g *DefaultGithubEnv) GetEventType() string
GetEventType returns the GitHub event type.
func (*DefaultGithubEnv) GetPRNumber ¶
func (g *DefaultGithubEnv) GetPRNumber() int
GetPRNumber returns the pull request number if the current environment is associated with a PR. Returns 0 if not in a PR context or if the PR number cannot be determined.
func (*DefaultGithubEnv) GetTag ¶
func (g *DefaultGithubEnv) GetTag() string
GetTag returns the tag from the CI environment if it exists. If the tag is not found, an empty string is returned.
func (*DefaultGithubEnv) HasEvent ¶
func (g *DefaultGithubEnv) HasEvent() bool
HasEvent returns whether a GitHub event payload exists.
func (*DefaultGithubEnv) IsPR ¶
func (g *DefaultGithubEnv) IsPR() bool
IsPR returns whether the current environment is associated with a pull request.
type GithubClient ¶
type GithubClient interface {
CreateRelease(opts *github.RepositoryRelease) (*github.RepositoryRelease, error)
Env() GithubEnv
GetReleaseByTag(tag string) (*github.RepositoryRelease, error)
ListPullRequestComments(prNumber int) ([]PullRequestComment, error)
PostPullRequestComment(prNumber int, body string) error
ListBranches() ([]Branch, error)
UploadReleaseAsset(releaseID int64, path string) error
}
GithubClient is the interface for the Github client.
type GithubEnv ¶
type GithubEnv interface {
GetBranch() string
GetEventPayload() (any, error)
GetEventType() string
GetPRNumber() int
GetTag() string
IsPR() bool
HasEvent() bool
}
GithubEnv provides GitHub environment information.
type GithubProviderCreds ¶
type GithubProviderCreds struct {
Token string
}
GithubProviderCreds is the struct that holds the credentials for the Github provider
type PullRequestComment ¶
PullRequestComment is a comment on a pull request.