Documentation
¶
Overview ¶
Package gitea provides constructs for Gitea repositories and branch protection, synthesized for registry.yawn.dev/john/gitea (john/tofu-provider-gitea).
Every setting is written explicitly. The provider's optional attributes have upstream defaults (for example private = true) that would silently change a repository whenever a setting is left out, so no setting here is left to them.
Index ¶
Constants ¶
const ProviderVersion = "0.9.0-dev.1"
ProviderVersion is the pinned john/tofu-provider-gitea release.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Features ¶
type Features struct {
Issues, Wiki, PullRequests, Projects bool
}
Features are the repository units that can be switched off.
type MergeOptions ¶
type MergeOptions struct {
MergeCommits, Rebase, RebaseExplicit, Squash bool
// ManualMerge lets maintainers mark a PR merged after merging outside Gitea.
ManualMerge, AutodetectManualMerge bool
IgnoreWhitespaceConflicts bool
Default MergeStyle
// DeleteBranchAfterMerge pre-ticks "delete branch" on the merge form.
DeleteBranchAfterMerge bool
}
MergeOptions are the allowed merge methods and their defaults.
type MergeStyle ¶
type MergeStyle string
MergeStyle is a pull request merge style.
const ( Merge MergeStyle = "merge" Rebase MergeStyle = "rebase" RebaseMerge MergeStyle = "rebase-merge" Squash MergeStyle = "squash" FastForwardOnly MergeStyle = "fast-forward-only" )
Merge styles Gitea accepts as the default.
type Protection ¶
type Protection struct {
Props ProtectionProps
Resource *core.Resource
}
Protection is a managed branch protection rule.
type ProtectionProps ¶
type ProtectionProps struct {
// Rule is the branch name or glob, e.g. "main".
Rule string
// RequiredChecks are status-check globs that must pass before merging. At
// least one is required: a protected branch without CI is refused.
RequiredChecks []string
// AllowPush allows direct pushes (not through a pull request).
AllowPush bool
// AllowForcePush allows force pushes.
AllowForcePush bool
// AllowAdminOverride lets admins merge without passing checks.
AllowAdminOverride bool
// BypassAllowlist enables Gitea's bypass allowlist.
BypassAllowlist bool
// RequiredApprovals is the number of approving reviews needed.
RequiredApprovals int
// RequireSignedCommits rejects unsigned commits.
RequireSignedCommits bool
// Import adopts an existing rule with the same name.
Import bool
}
ProtectionProps configures a branch protection rule. Every field is written.
type Repository ¶
type Repository struct {
Props RepositoryProps
Resource *core.Resource
}
Repository is a managed Gitea repository.
func NewRepository ¶
func NewRepository(stack *core.Stack, id string, p RepositoryProps) *Repository
NewRepository adds a repository to a stack. The repository is never deleted by OpenTofu: destroy is refused, and a forced destroy archives it.
func (*Repository) Protect ¶
func (r *Repository) Protect(stack *core.Stack, p ProtectionProps) *Protection
Protect adds a branch protection rule to a repository.
type RepositoryProps ¶
type RepositoryProps struct {
Owner, Name string
Description string
Website string
Visibility Visibility
DefaultBranch string
Features Features
Merge MergeOptions
Archived bool
// ID is the existing repository's numeric ID. When set, the repository is
// imported instead of created.
ID int64
}
RepositoryProps configures a repository. Every field is written.
type StateBackend ¶
type StateBackend struct {
// BaseURL is the Gitea URL, e.g. "https://code.yawn.dev".
BaseURL string
// Owner is the package owner, e.g. "john".
Owner string
// Prefix is prepended to each stack's state name, e.g. "arch-".
Prefix string
}
StateBackend stores state in Gitea's built-in OpenTofu state registry (/api/packages/<owner>/terraform/state/<name>), with locking. The username and password (a token) come from TF_HTTP_USERNAME and TF_HTTP_PASSWORD.
type Visibility ¶
type Visibility int
Visibility of a repository.
const ( Public Visibility Private )
Visibilities. The zero value is invalid on purpose: it must be chosen.