Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Post ¶
func Post(ctx context.Context, provider Provider, repoURL, repoFullName, commitSHA, token string, status Status) error
Post posts a commit status to the appropriate Git provider. When provider is ProviderAuto ("") the provider is detected from repoURL. Returns nil (silently no-op) when token or commitSHA is empty.
Types ¶
type Provider ¶
type Provider string
Provider identifies which SCM API to use when posting a commit status. The zero value ("") means auto-detect from the repository URL.
const ( // ProviderAuto detects the provider from the repository URL (default). ProviderAuto Provider = "" // ProviderGitHub targets the GitHub REST API. // For github.com the public API is used; for any other host the GitHub // Enterprise Server endpoint (/api/v3) is used instead. ProviderGitHub Provider = "github" // ProviderGitLab targets the GitLab API v4. ProviderGitLab Provider = "gitlab" // ProviderGitea targets the Gitea/Forgejo API v1. ProviderGitea Provider = "gitea" // ProviderAzureDevOps targets the Azure DevOps Git statuses API. ProviderAzureDevOps Provider = "azuredevops" )
func ParseProvider ¶
ParseProvider converts a string (e.g. from an env var) to a Provider. Returns an error when the value is non-empty, not "auto", and not a known provider.
type Status ¶
type Status struct {
State State
Description string
// Context is the label shown in the Git UI (e.g. "doco-cd/deploy").
// Defaults to DefaultContext when empty.
Context string
TargetURL string // optional link to deployment logs
}
Status holds the information to post as a commit status.
func Get ¶
func Get(ctx context.Context, provider Provider, repoURL, repoFullName, commitSHA, token, contextName string) (Status, bool, error)
Get returns the latest commit status for the requested context. When provider is ProviderAuto ("") the provider is detected from repoURL. Returns found=false when token, commitSHA, or matching status is missing.