commitstatus

package
v0.96.0 Latest Latest
Warning

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

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

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

func ParseProvider(s string) (Provider, error)

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 State

type State string

State represents the commit status state sent to the Git provider.

const (
	StatePending State = "pending"
	StateSuccess State = "success"
	StateFailure State = "failure"
	StateError   State = "error"

	DefaultContext = "doco-cd/deploy"
)

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.

Jump to

Keyboard shortcuts

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