Documentation
¶
Overview ¶
Package forgejo provides constructs for Forgejo repositories and branch protection, synthesized for the community OpenTofu provider svalabs/forgejo (registry.opentofu.org/svalabs/forgejo).
Every setting is written explicitly so nothing is left to provider defaults. Two limits of the pinned provider are tracked in code, not hidden:
- UnreadSettings: repository settings the provider sends but never reads back, so a change made in the Forgejo UI does not show in plans. john/arch checks them against the live API instead.
- Admin enforcement (apply_to_admins) is not supported by the provider yet (upstream PR svalabs/terraform-provider-forgejo#220).
Index ¶
- Constants
- Variables
- func LeftToProvider(resourceType string) []string
- func Provider(host string) core.Provider
- type DeployKey
- type DeployKeyProps
- type Features
- type MergeOptions
- type MergeStyle
- type Protection
- type ProtectionProps
- type Repository
- type RepositoryProps
- type UpdateStyle
- type Visibility
- type WikiOptions
Constants ¶
const ProviderVersion = "1.7.0"
ProviderVersion is the pinned svalabs/forgejo release.
Variables ¶
var UnreadSettings = []string{
"allow_fast_forward_only_merge",
"allow_rebase_update",
"default_allow_maintainer_edit",
"default_delete_branch_after_merge",
"default_update_style",
"globally_editable_wiki",
"wiki_branch",
}
UnreadSettings are repository settings that svalabs/forgejo 1.7.0 writes but never reads back from Forgejo (see its repositoryResourceModel.from). A UI change to one of them is invisible to `tofu plan`; consumers that need drift detection must compare them against GET /repos/{owner}/{repo} themselves. The schema test keeps this list in step with the pinned provider.
Functions ¶
func LeftToProvider ¶
LeftToProvider lists the settable attributes of a resource type that the constructs deliberately do not write, so a test can prove that every attribute of the pinned provider was decided.
Types ¶
type DeployKey ¶
type DeployKey struct {
Props DeployKeyProps
Resource *core.Resource
}
DeployKey is a deploy key on a repository.
type DeployKeyProps ¶
type DeployKeyProps struct {
// Title names the key in the repository settings.
Title string
// PublicKey is the OpenSSH public key ("ssh-ed25519 AAAA..."), without a
// comment. Only the public half is ever declared.
PublicKey string
// Write grants push access. Off by default: deploy jobs only read.
Write bool
}
DeployKeyProps declares an SSH deploy key on a repository.
type Features ¶
type Features struct {
Issues, Wiki, PullRequests, Projects, Releases, Packages, Actions bool
}
Features are the repository units.
type MergeOptions ¶
type MergeOptions struct {
MergeCommits, Rebase, RebaseExplicit, Squash, FastForwardOnly bool
// RebaseUpdate allows "update branch by rebase".
RebaseUpdate bool
IgnoreWhitespaceConflicts bool
Default MergeStyle
DefaultUpdate UpdateStyle
// DeleteBranchAfterMerge pre-ticks "delete branch" on the merge form.
DeleteBranchAfterMerge bool
// MaintainerEdit pre-ticks "allow edits from maintainers" on new PRs.
MaintainerEdit 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 Forgejo 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 {
// Branch is the branch name or glob, e.g. "main".
Branch 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
// RequiredApprovals is the number of approving reviews needed.
RequiredApprovals int
// RequireSignedCommits rejects unsigned commits.
RequireSignedCommits bool
// Import adopts an existing rule for the same branch.
Import bool
}
ProtectionProps configures a branch protection rule. Every field is written. Forgejo always refuses force pushes and deletion of a protected branch.
type Repository ¶
type Repository struct {
Props RepositoryProps
Resource *core.Resource
}
Repository is a managed Forgejo repository.
func NewRepository ¶
func NewRepository(stack *core.Stack, id string, p RepositoryProps) *Repository
NewRepository adds a repository to a stack. OpenTofu refuses to destroy it, and a forced destroy archives it instead of deleting it.
func (*Repository) DeployKey ¶
func (r *Repository) DeployKey(stack *core.Stack, id string, p DeployKeyProps) *DeployKey
DeployKey adds an SSH deploy key, read-only unless Write is set. Only ed25519 public keys are accepted; private keys never pass through cdk.
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
Wiki WikiOptions
Archived bool
// Import adopts the existing repository owner/name instead of creating it.
Import bool
}
RepositoryProps configures a repository. Every field is written.
type UpdateStyle ¶
type UpdateStyle string
UpdateStyle is how "update branch" brings a PR up to date.
const ( UpdateMerge UpdateStyle = "merge" UpdateRebase UpdateStyle = "rebase" )
Update styles.
type Visibility ¶
type Visibility int
Visibility of a repository. The zero value is invalid: it must be chosen.
const ( Public Visibility Private )
Visibilities.
type WikiOptions ¶
type WikiOptions struct {
// Branch is the wiki's branch, e.g. "main".
Branch string
// GloballyEditable lets any signed-in user edit the wiki.
GloballyEditable bool
}
WikiOptions apply when Features.Wiki is on.