Help us shape the future of Go! Take the 2026 Go Developer Survey

forge

package
v0.2.50 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MaxLogBytes = 24 << 10
View Source
const QueueExecutionCheckName = "reforge/merge-policy"

Variables

This section is empty.

Functions

func BotBranch added in v0.2.15

func BotBranch(branch string) bool

func Closable

func Closable(change Change, in CloseChangeRequest, actor string) bool

func DeliveryRulesHash

func DeliveryRulesHash(v any) string

func LogTail

func LogTail(body []byte) string

func MissingChecks

func MissingChecks(target, head []Check, ignore func(string) bool) ([]string, bool)

func PipelineMatches

func PipelineMatches(in PipelineRequest, out DeploymentStatus) bool

func ValidArtifactDigest

func ValidArtifactDigest(value string) bool

func ValidEnvironment

func ValidEnvironment(value string) bool

func ValidPipelineRequest

func ValidPipelineRequest(in PipelineRequest) bool

func VerifyPipelineConfiguration

func VerifyPipelineConfiguration(ctx context.Context, provider ForgeInventory, in PipelineRequest) error

Types

type Advisory

type Advisory struct {
	ID         string `json:"id"`
	Package    string `json:"package"`
	Ecosystem  string `json:"ecosystem"`
	Manifest   string `json:"manifest"`
	Severity   string `json:"severity"`
	Summary    string `json:"summary"`
	Vulnerable string `json:"vulnerable"`
	Patched    string `json:"patched"`
	URL        string `json:"url"`
}

type AdvisoryReader

type AdvisoryReader interface {
	ListAdvisories(context.Context, RepoRef) ([]Advisory, error)
}

type Approval

type Approval struct {
	ID        string `json:"id"`
	ActorID   string `json:"actor_id"`
	HeadSHA   string `json:"head_sha"`
	State     string `json:"state"`
	Dismissed bool   `json:"dismissed"`
}

type Capabilities

type Capabilities struct {
	Provider      string                       `json:"provider"`
	ServerVersion string                       `json:"server_version"`
	Features      map[string]domain.Capability `json:"features"`
}

type Change

type Change struct {
	ID               string  `json:"id"`
	Repository       RepoRef `json:"repository"`
	HeadRepository   RepoRef `json:"head_repository"`
	TargetRepository RepoRef `json:"target_repository"`
	Title            string  `json:"title"`
	Body             string  `json:"body"`
	URL              string  `json:"url"`
	HeadSHA          string  `json:"head_sha"`
	TargetSHA        string  `json:"target_sha"`
	HeadBranch       string  `json:"head_branch"`
	TargetBranch     string  `json:"target_branch"`
	AuthorID         string  `json:"author_id"`
	AuthorLogin      string  `json:"author_login"`
	AuthorType       string  `json:"author_type"`
	State            string  `json:"state"`
	Draft            bool    `json:"draft"`
	MergeSHA         string  `json:"merge_sha"`
	MergeStatus      string  `json:"merge_status"`
	OperationID      string  `json:"operation_id"`
}

type Check

type Check struct {
	ID          string     `json:"id"`
	Name        string     `json:"name"`
	PublisherID string     `json:"publisher_id"`
	HeadSHA     string     `json:"head_sha"`
	Status      string     `json:"status"`
	Conclusion  string     `json:"conclusion"`
	URL         string     `json:"url"`
	CompletedAt *time.Time `json:"completed_at,omitempty"`
}

type CheckLogReader

type CheckLogReader interface {
	ReadCheckLog(context.Context, RepoRef, string) (string, error)
}

type CheckRule

type CheckRule struct {
	Name        string `json:"name"`
	PublisherID string `json:"publisher_id"`
}

type CloseChangeRequest

type CloseChangeRequest struct {
	Repository RepoRef `json:"repository"`
	ChangeID   string  `json:"change_id"`
	HeadBranch string  `json:"head_branch"`
	Comment    string  `json:"comment"`
}

func (CloseChangeRequest) Valid

func (r CloseChangeRequest) Valid() bool

type CommentChangeRequest

type CommentChangeRequest struct {
	Repository RepoRef `json:"repository"`
	ChangeID   string  `json:"change_id"`
	HeadSHA    string  `json:"head_sha"`
	Comment    string  `json:"comment"`
}

func (CommentChangeRequest) Valid

func (r CommentChangeRequest) Valid() bool

type CommitProof

type CommitProof struct {
	SHA      string   `json:"sha"`
	Parents  []string `json:"parents"`
	Message  string   `json:"message"`
	AuthorID string   `json:"author_id"`
}

type Config

type Config struct {
	OrgID         string
	ConnectionID  string
	BaseURL       string
	Token         string     `json:"-"`
	WebhookSecret string     `json:"-"`
	Client        HTTPClient `json:"-"`
	ServerVersion string
}

func (Config) GoString

func (c Config) GoString() string

func (Config) LogValue

func (c Config) LogValue() slog.Value

func (Config) String

func (c Config) String() string

type CreateChangeRequest

type CreateChangeRequest struct {
	Repository      RepoRef
	Title           string
	Body            string
	HeadBranch      string
	TargetBranch    string
	ExpectedHeadSHA string
	OperationID     string
	Draft           bool
}

type DeploymentGates

type DeploymentGates struct {
	State          string                 `json:"state"`
	NativeEnforced domain.CapabilityState `json:"native_enforced"`
	Blockers       []string               `json:"blockers"`
	ApprovalURL    string                 `json:"approval_url"`
	Environment    string                 `json:"environment"`
	RulesHash      string                 `json:"rules_hash"`
}

func InspectPipeline

func InspectPipeline(ctx context.Context, provider Provider, in PipelineRequest) (DeploymentGates, error)

type DeploymentStatus

type DeploymentStatus struct {
	WorkflowSHA    string    `json:"workflow_sha"`
	CreatedAt      time.Time `json:"created_at"`
	ID             string    `json:"id"`
	State          string    `json:"state"`
	SourceSHA      string    `json:"source_sha"`
	ArtifactDigest string    `json:"artifact_digest"`
	Environment    string    `json:"environment"`
	CorrelationID  string    `json:"correlation_id"`
	WorkflowID     string    `json:"workflow_id"`
	WorkflowPath   string    `json:"workflow_path"`
	Ref            string    `json:"ref"`
	Event          string    `json:"event"`
	RunAttempt     int64     `json:"run_attempt"`
	URL            string    `json:"url"`
	Health         string    `json:"health"`
	ObservedAt     time.Time `json:"observed_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

type Event

type Event struct {
	DeliveryID string
	Kind       string
	Repository RepoRef
	ChangeID   string
	HeadSHA    string
}

type ExecutionCheck

type ExecutionCheck struct {
	ID          string `json:"id"`
	SHA         string `json:"sha"`
	Name        string `json:"name"`
	State       string `json:"state"`
	PublisherID string `json:"publisher_id"`
	OperationID string `json:"operation_id"`
}

type ExecutionCheckRequest

type ExecutionCheckRequest struct {
	Repository  RepoRef
	SHA         string
	Name        string
	State       string
	OperationID string
	CheckID     string
}

type File

type File struct {
	Path    string
	SHA     string
	Content []byte
}

type FileEdit

type FileEdit struct {
	Path    string
	Content []byte
	Delete  bool
}

type ForgeBranchRefresher

type ForgeBranchRefresher interface {
	RefreshAppBranch(context.Context, RefreshBranchRequest) error
}

type ForgeChangeCloser

type ForgeChangeCloser interface {
	CloseChange(context.Context, CloseChangeRequest) (Change, error)
}

type ForgeChangeCommenter

type ForgeChangeCommenter interface {
	CommentChange(context.Context, CommentChangeRequest) (Change, error)
}

type ForgeChanges

type ForgeChanges interface {
	CreateChange(context.Context, CreateChangeRequest) (Change, error)
	FindChangeByOperation(ctx context.Context, repository RepoRef, operationID, headBranch, targetBranch string) (*Change, error)
	UpdateAppBranch(context.Context, UpdateBranchRequest) (string, error)
	ReadChange(context.Context, RepoRef, string) (Change, error)
	RequestReview(context.Context, RepoRef, string, []string) error
}

type ForgeCommits

type ForgeCommits interface {
	ReadCommitProof(context.Context, RepoRef, string) (CommitProof, error)
}

type ForgeDelivery

type ForgeDelivery interface {
	ListAllowedWorkflows(context.Context, RepoRef) ([]Workflow, error)
	TriggerOrObservePipeline(context.Context, PipelineRequest) (DeploymentStatus, error)
	ReadDeploymentGates(context.Context, RepoRef, string) (DeploymentGates, error)
	ReadDeploymentStatus(context.Context, RepoRef, string) (DeploymentStatus, error)
	RequestAllowedRecovery(context.Context, PipelineRequest) (DeploymentStatus, error)
}

type ForgeEvents

type ForgeEvents interface {
	VerifyWebhook(http.Header, []byte) error
	DecodeEvent(http.Header, []byte) (Event, error)
	ReconcileChanges(context.Context, RepoRef, string) (domain.Page[Change], error)
	ListChecks(context.Context, RepoRef, string) ([]Check, error)
	ListBotWork(context.Context, RepoRef) ([]Change, error)
}

type ForgeExecutionChecks

type ForgeExecutionChecks interface {
	WriteExecutionCheck(context.Context, ExecutionCheckRequest) (ExecutionCheck, error)
	ReadExecutionCheck(context.Context, RepoRef, string) (ExecutionCheck, error)
}

type ForgeFreshness

type ForgeFreshness interface {
	Behind(context.Context, RepoRef, string, string) (int, error)
}

type ForgeInventory

type ForgeInventory interface {
	ProbeCapabilities(context.Context) (Capabilities, error)
	ListRepositories(context.Context, InventoryRequest) (domain.Page[Repository], error)
	GetRepository(context.Context, RepoRef) (Repository, error)
	ReadFileAtRef(context.Context, RepoRef, string, string) (File, error)
	ResolveRef(context.Context, RepoRef, string) (string, error)
}

type ForgeMerge

type ForgeMerge interface {
	RequestNativeMergeOrQueue(context.Context, MergeRequest) (MergeResult, error)
	ReadMergeResult(context.Context, RepoRef, string) (MergeResult, error)
}

type ForgePipelineControl

type ForgePipelineControl interface {
	CancelPipeline(context.Context, PipelineRequest) (DeploymentStatus, error)
}

type ForgeProtection

type ForgeProtection interface {
	ReadEffectiveRules(context.Context, RepoRef, string) (Rules, error)
	EvaluateNativeEligibility(context.Context, RepoRef, string) (NativeEligibility, error)
	ReadApprovals(context.Context, RepoRef, string) ([]Approval, error)
	ReadQueueState(context.Context, RepoRef, string) (QueueState, error)
}

type ForgeQueueControl

type ForgeQueueControl interface {
	CancelNativeQueue(context.Context, QueueCancelRequest) (QueueState, error)
}

type ForgeQueuePrerequisites

type ForgeQueuePrerequisites interface {
	EvaluateQueuePrerequisites(context.Context, RepoRef, string) (NativeEligibility, CheckRule, error)
}

type ForgeSource

type ForgeSource interface {
	ReadSourceManifest(context.Context, RepoRef, string) (SourceManifest, error)
}

type ForgeTrainGate

type ForgeTrainGate interface {
	ReadTrainGate(context.Context, RepoRef, string) (TrainGate, error)
	ReleaseTrainGate(context.Context, TrainGateRequest) (TrainGate, error)
}

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

type InventoryRequest

type InventoryRequest struct {
	Namespace string
	Cursor    string
	Limit     int
}

type Issue

type Issue struct {
	Number string   `json:"number"`
	Title  string   `json:"title"`
	Body   string   `json:"body"`
	URL    string   `json:"url"`
	Labels []string `json:"labels"`
}

type IssueReader

type IssueReader interface {
	ListIssues(context.Context, RepoRef) ([]Issue, error)
}

type MergeEvidence

type MergeEvidence struct {
	TrainGate      *TrainGate        `json:"train_gate,omitempty"`
	ExecutionCheck CheckRule         `json:"execution_check"`
	Change         Change            `json:"change"`
	Rules          Rules             `json:"rules"`
	Checks         []Check           `json:"checks"`
	Approvals      []Approval        `json:"approvals"`
	Native         NativeEligibility `json:"native"`
	Queue          QueueState        `json:"queue"`
	Capabilities   Capabilities      `json:"capabilities"`
	ObservedAt     time.Time         `json:"observed_at"`
	TargetChecks   []Check           `json:"target_checks,omitempty"`
	UpToDate       bool              `json:"up_to_date,omitempty"`
}

type MergeRequest

type MergeRequest struct {
	Repository        RepoRef
	ChangeID          string
	ExpectedHeadSHA   string
	ExpectedTargetSHA string
	RulesHash         string
	GateID            string
	Method            string
	OperationID       string
	Queue             bool
	ReforgeEnforced   bool
}

type MergeResult

type MergeResult struct {
	State    string `json:"state"`
	NativeID string `json:"native_id"`
	MergeSHA string `json:"merge_sha"`
	HeadSHA  string `json:"head_sha"`
	URL      string `json:"url"`
}

type NativeEligibility

type NativeEligibility struct {
	State      string   `json:"state"`
	Blockers   []string `json:"blockers"`
	Protection []string `json:"protection,omitempty"`
	HeadSHA    string   `json:"head_sha"`
	TargetSHA  string   `json:"target_sha"`
}

func (NativeEligibility) OnlyProtection

func (e NativeEligibility) OnlyProtection() bool

type PermissionLinker

type PermissionLinker interface {
	PermissionsURL(context.Context) (string, error)
}

type PipelineRequest

type PipelineRequest struct {
	WorkflowSHA    string            `json:"workflow_sha"`
	RulesHash      string            `json:"rules_hash"`
	Repository     RepoRef           `json:"repository"`
	WorkflowID     string            `json:"workflow_id"`
	WorkflowPath   string            `json:"workflow_path"`
	ConfigSHA256   string            `json:"config_sha256"`
	Ref            string            `json:"ref"`
	SourceSHA      string            `json:"source_sha"`
	ArtifactDigest string            `json:"artifact_digest"`
	Environment    string            `json:"environment"`
	CorrelationID  string            `json:"correlation_id"`
	Inputs         map[string]string `json:"inputs"`
	ObserveOnly    bool              `json:"observe_only"`
	RunID          string            `json:"run_id"`
	RequestedAt    time.Time         `json:"requested_at"`
}

type QueueCancelRequest

type QueueCancelRequest struct {
	Repository      RepoRef
	ChangeID        string
	QueueID         string
	ExpectedHeadSHA string
	OperationID     string
}

type QueueState

type QueueState struct {
	ID        string `json:"id"`
	State     string `json:"state"`
	HeadSHA   string `json:"head_sha"`
	TestedSHA string `json:"tested_sha"`
	TargetSHA string `json:"target_sha"`
}

type RefreshBranchRequest

type RefreshBranchRequest struct {
	Repository        RepoRef
	ChangeID          string
	HeadBranch        string
	TargetBranch      string
	ExpectedHeadSHA   string
	ExpectedTargetSHA string
	OperationID       string
}

func (RefreshBranchRequest) Valid

func (r RefreshBranchRequest) Valid() bool

type RepoRef

type RepoRef struct {
	NativeID string `json:"native_id"`
	FullName string `json:"full_name"`
}

type Repository

type Repository struct {
	RepoRef
	URL           string   `json:"url"`
	CloneURL      string   `json:"clone_url"`
	DefaultBranch string   `json:"default_branch"`
	Archived      bool     `json:"archived"`
	Private       bool     `json:"private"`
	Permissions   []string `json:"permissions"`
}

type Rules

type Rules struct {
	State                domain.CapabilityState `json:"state"`
	Reason               string                 `json:"reason"`
	Hash                 string                 `json:"hash"`
	ObservedAt           time.Time              `json:"observed_at"`
	RequiredChecks       []CheckRule            `json:"required_checks"`
	RequiredApprovals    int                    `json:"required_approvals"`
	DismissStaleReviews  bool                   `json:"dismiss_stale_reviews"`
	RequireCodeOwners    bool                   `json:"require_code_owners"`
	CodeOwnersEnforced   domain.CapabilityState `json:"code_owners_enforced"`
	RequireStrictTarget  bool                   `json:"require_strict_target"`
	StrictTargetEnforced domain.CapabilityState `json:"strict_target_enforced"`
	RequireQueue         bool                   `json:"require_queue"`
	AllowedMergeMethods  []string               `json:"allowed_merge_methods"`
	ActorCanBypass       bool                   `json:"actor_can_bypass"`
	Unprotected          bool                   `json:"unprotected,omitempty"`
}

type SourceEntry

type SourceEntry struct {
	Path string `json:"path"`
	SHA  string `json:"sha"`
	Mode string `json:"mode"`
	Type string `json:"type"`
	Size int64  `json:"size,omitempty"`
}

type SourceManifest

type SourceManifest struct {
	Repository   RepoRef       `json:"repository"`
	CommitSHA    string        `json:"commit_sha"`
	TreeSHA      string        `json:"tree_sha"`
	ObjectFormat string        `json:"object_format"`
	Proof        string        `json:"proof"`
	Entries      []SourceEntry `json:"entries"`
	Complete     bool          `json:"complete"`
}

type TrainGate

type TrainGate struct {
	QueueID        string `json:"queue_id"`
	PipelineID     string `json:"pipeline_id"`
	JobID          string `json:"job_id"`
	HeadSHA        string `json:"head_sha"`
	TargetSHA      string `json:"target_sha"`
	SHA            string `json:"sha"`
	CIConfigSHA256 string `json:"ci_config_sha256"`
	Name           string `json:"name"`
	PublisherID    string `json:"publisher_id"`
	State          string `json:"state"`
	ChecksReady    bool   `json:"checks_ready"`
}

type TrainGateRequest

type TrainGateRequest struct {
	RulesHash   string    `json:"rules_hash"`
	Repository  RepoRef   `json:"repository"`
	ChangeID    string    `json:"change_id"`
	Gate        TrainGate `json:"gate"`
	OperationID string    `json:"operation_id"`
}

type UpdateBranchRequest

type UpdateBranchRequest struct {
	Repository     RepoRef
	Branch         string
	ExpectedOldSHA string
	BaseSHA        string
	Message        string
	Edits          []FileEdit
	OperationID    string
}

type Workflow

type Workflow struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Ref  string `json:"ref"`
	Path string `json:"path"`
	URL  string `json:"url"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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