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

privateconnector

package
v0.2.4 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: 34 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTTL = 10 * time.Second
View Source
const MaxBatchFiles = 50
View Source
const MaxGrant = 1 << 20
View Source
const MaxMergeTTL = 2 * time.Minute
View Source
const MaxModelTTL = 5 * time.Minute
View Source
const MaxResponse = 90 << 20
View Source
const MaxTTL = 30 * time.Second

Variables

View Source
var ErrConflict = errors.New("private operation already active or consumed")
View Source
var ErrInvalid = errors.New("invalid private operation")
View Source
var ErrUnavailable = errors.New("private supervisor unavailable")
View Source
var ErrUncertain = errors.New("private operation outcome uncertain; reconcile before retry")
View Source
var ErrUnsupported = errors.New("private operation is not registered")

Functions

func BindForgeOperation

func BindForgeOperation(provider forge.Provider, operation Operation) forge.Provider

func ContainsSecret

func ContainsSecret(data []byte, secret string) bool

func GuardHTTP

func GuardHTTP(client forge.HTTPClient, check func(context.Context) error) forge.HTTPClient

func ProtectionHTTP

func ProtectionHTTP(client forge.HTTPClient) forge.HTTPClient

Types

type Authenticate

type Authenticate func(context.Context, string) (runner.Runner, error)

type Authorize

type Authorize func(context.Context, Ready, Deliver) error

type ChangeArgs

type ChangeArgs struct {
	Repository forge.RepoRef `json:"repository"`
	ChangeID   string        `json:"change_id"`
}

type ChangesArgs

type ChangesArgs struct {
	Repository forge.RepoRef `json:"repository"`
	Cursor     string        `json:"cursor,omitempty"`
}

type CheckLogArgs

type CheckLogArgs struct {
	Repository forge.RepoRef `json:"repository"`
	CheckID    string        `json:"check_id"`
}

type ChecksArgs

type ChecksArgs struct {
	Repository forge.RepoRef `json:"repository"`
	CommitSHA  string        `json:"commit_sha"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg ClientConfig) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Complete

func (c *Client) Complete(ctx context.Context, grant Grant, result Result) error

func (*Client) GoString

func (c *Client) GoString() string

func (*Client) LogValue

func (c *Client) LogValue() slog.Value

func (*Client) Poll

func (c *Client) Poll(ctx context.Context) (Grant, error)

func (*Client) RunOnce

func (c *Client) RunOnce(ctx context.Context) error

func (*Client) String

func (c *Client) String() string

type ClientConfig

type ClientConfig struct {
	Endpoint    string
	Credential  string `json:"-"`
	Target      Target
	Development bool
	CAPEM       []byte
}

func (ClientConfig) GoString

func (c ClientConfig) GoString() string

func (ClientConfig) LogValue

func (c ClientConfig) LogValue() slog.Value

func (ClientConfig) String

func (c ClientConfig) String() string

type CompareArgs

type CompareArgs struct {
	Repository forge.RepoRef `json:"repository"`
	Base       string        `json:"base"`
	Head       string        `json:"head"`
}

type Completion

type Completion struct {
	GrantID string `json:"grant_id"`
	Result  Result `json:"result"`
}

type Config

type Config struct {
	Authenticate  Authenticate
	TTL           time.Duration
	MaxConcurrent int
	Development   bool
}

type Connection

type Connection struct {
	Protection        *ProtectionCredential `json:"protection,omitempty"`
	CheckPublishers   map[string]string     `json:"check_publishers,omitempty"`
	Kind              string                `json:"kind,omitempty"`
	AuthKind          string                `json:"auth_kind,omitempty"`
	AppID             string                `json:"app_id,omitempty"`
	InstallationID    string                `json:"installation_id,omitempty"`
	Model             string                `json:"model,omitempty"`
	Profile           string                `json:"profile,omitempty"`
	OrgID             string                `json:"org_id"`
	ID                string                `json:"id"`
	Version           int64                 `json:"version"`
	CredentialVersion int64                 `json:"credential_version"`
	Provider          string                `json:"provider"`
	Endpoint          string                `json:"endpoint"`
	Route             network.PrivateRoute  `json:"route"`
	CAPEM             []byte                `json:"ca_pem,omitempty"`
	Secret            string                `json:"-"`
}

func (Connection) GoString

func (c Connection) GoString() string

func (Connection) LogValue

func (c Connection) LogValue() slog.Value

func (Connection) String

func (c Connection) String() string

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config) (*Connector, error)

func (*Connector) Active

func (c *Connector) Active(ctx context.Context, credential, grantID, capability string) error

func (*Connector) Close

func (c *Connector) Close()

func (*Connector) Complete

func (c *Connector) Complete(ctx context.Context, credential, grantID, capability string, result Result) error

func (*Connector) Dispatch

func (c *Connector) Dispatch(ctx context.Context, target Target, operation Operation, authorize Authorize) (Result, error)

func (*Connector) Poll

func (c *Connector) Poll(ctx context.Context, credential string) (Grant, error)

type Deliver

type Deliver func(GrantSpec) (Result, error)

type DeliveryArgs

type DeliveryArgs struct {
	Repository  forge.RepoRef `json:"repository"`
	Environment string        `json:"environment"`
	RunID       string        `json:"run_id"`
}

type Executor

type Executor struct {
	Authorize   func(context.Context) error
	Target      Target
	Development bool
}

func (Executor) Execute

func (e Executor) Execute(ctx context.Context, grant Grant) Result

type Failure

type Failure struct {
	RetryAfterMS int64  `json:"retry_after_ms,omitempty"`
	Code         string `json:"code"`
	Uncertain    bool   `json:"uncertain"`
}

type FileArgs

type FileArgs struct {
	Repository forge.RepoRef `json:"repository"`
	CommitSHA  string        `json:"commit_sha"`
	Path       string        `json:"path"`
}

type FilesArgs

type FilesArgs struct {
	Repository forge.RepoRef `json:"repository"`
	CommitSHA  string        `json:"commit_sha"`
	Paths      []string      `json:"paths"`
}

type FindChangeArgs

type FindChangeArgs struct {
	Repository   forge.RepoRef `json:"repository"`
	OperationID  string        `json:"operation_id"`
	HeadBranch   string        `json:"head_branch"`
	TargetBranch string        `json:"target_branch"`
}

type Grant

type Grant struct {
	ID            string     `json:"id"`
	RunnerVersion int64      `json:"runner_version"`
	Target        Target     `json:"target"`
	Operation     Operation  `json:"operation"`
	AuthorityID   string     `json:"authority_id"`
	Connection    Connection `json:"connection"`
	TimeoutMS     int64      `json:"timeout_ms"`

	ExpiresAt        time.Time `json:"expires_at"`
	ResultCapability string    `json:"-"`
	// contains filtered or unexported fields
}

func DecodeGrant

func DecodeGrant(b []byte) (Grant, error)

func (Grant) GoString

func (g Grant) GoString() string

func (Grant) LogValue

func (g Grant) LogValue() slog.Value

func (Grant) MarshalWire

func (g Grant) MarshalWire() ([]byte, error)

func (Grant) String

func (g Grant) String() string

type GrantSpec

type GrantSpec struct {
	Check          func(context.Context) error `json:"-"`
	RunnerVersion  int64
	CredentialHash string `json:"-"`
	OperationID    string
	AuthorityID    string
	Connection     Connection
}

func (GrantSpec) GoString

func (g GrantSpec) GoString() string

func (GrantSpec) LogValue

func (g GrantSpec) LogValue() slog.Value

func (GrantSpec) String

func (g GrantSpec) String() string

type InventoryArgs

type InventoryArgs struct {
	Namespace string `json:"namespace,omitempty"`
	Cursor    string `json:"cursor,omitempty"`
	Limit     int    `json:"limit"`
}

type Kind

type Kind string
const (
	ForgePipelineCancel      Kind = "forge.pipeline_cancel"
	ForgePipelineInspect     Kind = "forge.pipeline_inspect"
	ForgeDeliveryWorkflows   Kind = "forge.delivery_workflows"
	ForgeDeliveryGates       Kind = "forge.delivery_gates"
	ForgeDeliveryStatus      Kind = "forge.delivery_status"
	ForgePipelineObserve     Kind = "forge.pipeline_observe"
	ForgePipelineTrigger     Kind = "forge.pipeline_trigger"
	ForgePipelineRecover     Kind = "forge.pipeline_recover"
	ForgeMergeInspect        Kind = "forge.merge_inspect"
	ForgeReadTrainGate       Kind = "forge.read_train_gate"
	ForgeReleaseTrainGate    Kind = "forge.release_train_gate"
	ForgeQueueInspect        Kind = "forge.queue_inspect"
	ForgeMerge               Kind = "forge.merge"
	ForgeMergeResult         Kind = "forge.merge_result"
	ForgeQueueState          Kind = "forge.queue_state"
	ForgeCancelQueue         Kind = "forge.cancel_queue"
	ForgeCloseChange         Kind = "forge.close_change"
	ForgeReadExecutionCheck  Kind = "forge.read_execution_check"
	ForgeWriteExecutionCheck Kind = "forge.write_execution_check"
	ForgeCommitProof         Kind = "forge.commit_proof"
	ForgeRefreshBranch       Kind = "forge.refresh_branch"
	ForgeUpdateBranch        Kind = "forge.update_branch"
	ForgeCreateChange        Kind = "forge.create_change"
	ForgeFindChange          Kind = "forge.find_change"
	ForgeProbe               Kind = "forge.probe"
	ForgeInventory           Kind = "forge.inventory"
	ForgeRepository          Kind = "forge.repository"
	ForgeResolveRef          Kind = "forge.resolve_ref"
	ForgeReadFile            Kind = "forge.read_file"
	ForgeReadFiles           Kind = "forge.read_files"
	ForgeCheckLog            Kind = "forge.check_log"
	ForgeBehind              Kind = "forge.behind"
	ForgeCommentChange       Kind = "forge.comment_change"
	ForgeSourceManifest      Kind = "forge.source_manifest"
	ForgeReadChange          Kind = "forge.read_change"
	ForgeChecks              Kind = "forge.checks"
	ForgeIssues              Kind = "forge.issues"
	ForgeAdvisories          Kind = "forge.advisories"
	ForgePermissionsURL      Kind = "forge.permissions_url"
	ForgeApprovals           Kind = "forge.approvals"
	ForgeReconcileChanges    Kind = "forge.reconcile_changes"
	ModelProbe               Kind = "model.probe"
	ModelList                Kind = "model.list"
	ModelTurn                Kind = "model.turn"
	GiteaProbe                    = ForgeProbe
	GiteaInventory                = ForgeInventory
	GiteaRepository               = ForgeRepository
	GiteaResolveRef               = ForgeResolveRef
	GiteaReadFile                 = ForgeReadFile
	GiteaReadChange               = ForgeReadChange
	GiteaChecks                   = ForgeChecks
	GiteaApprovals                = ForgeApprovals
)

type Operation

type Operation struct {
	Delivery       *DeliveryArgs                `json:"delivery,omitempty"`
	Pipeline       *forge.PipelineRequest       `json:"pipeline,omitempty"`
	TrainGate      *forge.TrainGateRequest      `json:"train_gate,omitempty"`
	ExecutionCheck *forge.ExecutionCheckRequest `json:"execution_check,omitempty"`
	CancelQueue    *forge.QueueCancelRequest    `json:"cancel_queue,omitempty"`
	Close          *forge.CloseChangeRequest    `json:"close,omitempty"`
	Comment        *forge.CommentChangeRequest  `json:"comment,omitempty"`
	Merge          *forge.MergeRequest          `json:"merge,omitempty"`
	Commit         *ChecksArgs                  `json:"commit,omitempty"`
	Refresh        *forge.RefreshBranchRequest  `json:"refresh,omitempty"`
	Branch         *forge.UpdateBranchRequest   `json:"branch,omitempty"`
	Create         *forge.CreateChangeRequest   `json:"create,omitempty"`
	Find           *FindChangeArgs              `json:"find,omitempty"`
	Turn           *model.Turn                  `json:"turn,omitempty"`
	Source         *ChecksArgs                  `json:"source,omitempty"`
	Changes        *ChangesArgs                 `json:"changes,omitempty"`
	ID             string                       `json:"id"`
	Kind           Kind                         `json:"kind"`
	Inventory      *InventoryArgs               `json:"inventory,omitempty"`
	Repository     *RepositoryArgs              `json:"repository,omitempty"`
	Ref            *RefArgs                     `json:"ref,omitempty"`
	File           *FileArgs                    `json:"file,omitempty"`
	Files          *FilesArgs                   `json:"files,omitempty"`
	CheckLog       *CheckLogArgs                `json:"check_log,omitempty"`
	Compare        *CompareArgs                 `json:"compare,omitempty"`
	Change         *ChangeArgs                  `json:"change,omitempty"`
	Checks         *ChecksArgs                  `json:"checks,omitempty"`
}

func (Operation) MaximumTTL

func (o Operation) MaximumTTL() time.Duration

func (Operation) Mutation

func (o Operation) Mutation() bool

func (Operation) Validate

func (o Operation) Validate() error

type ProtectionCredential

type ProtectionCredential struct {
	ID                string `json:"id"`
	Version           int64  `json:"version"`
	CredentialVersion int64  `json:"credential_version"`
	Secret            string `json:"-"`
}

func (ProtectionCredential) GoString

func (p ProtectionCredential) GoString() string

func (ProtectionCredential) LogValue

func (p ProtectionCredential) LogValue() slog.Value

func (ProtectionCredential) String

func (p ProtectionCredential) String() string

type Ready

type Ready struct {
	runner.Runner
	CredentialHash string `json:"-"`
}

func (Ready) GoString

func (r Ready) GoString() string

func (Ready) LogValue

func (r Ready) LogValue() slog.Value

func (Ready) String

func (r Ready) String() string

type RefArgs

type RefArgs struct {
	Repository forge.RepoRef `json:"repository"`
	Ref        string        `json:"ref"`
}

type RepositoryArgs

type RepositoryArgs struct {
	Repository forge.RepoRef `json:"repository"`
}

type Result

type Result struct {
	Workflows         []forge.Workflow               `json:"workflows,omitempty"`
	DeploymentGates   *forge.DeploymentGates         `json:"deployment_gates,omitempty"`
	Deployment        *forge.DeploymentStatus        `json:"deployment,omitempty"`
	TrainGate         *forge.TrainGate               `json:"train_gate,omitempty"`
	ExecutionCheck    *forge.ExecutionCheck          `json:"execution_check,omitempty"`
	Queue             *forge.QueueState              `json:"queue,omitempty"`
	MergeEvidence     *forge.MergeEvidence           `json:"merge_evidence,omitempty"`
	Merge             *forge.MergeResult             `json:"merge,omitempty"`
	Commit            *forge.CommitProof             `json:"commit,omitempty"`
	Turn              *model.TurnResult              `json:"turn,omitempty"`
	Manifest          *forge.SourceManifest          `json:"manifest,omitempty"`
	Changes           *domain.Page[forge.Change]     `json:"changes,omitempty"`
	ModelCapabilities *model.Capabilities            `json:"model_capabilities,omitempty"`
	Models            []model.Model                  `json:"models,omitempty"`
	OperationID       string                         `json:"operation_id"`
	Failure           *Failure                       `json:"failure,omitempty"`
	Capabilities      *forge.Capabilities            `json:"capabilities,omitempty"`
	Inventory         *domain.Page[forge.Repository] `json:"inventory,omitempty"`
	Repository        *forge.Repository              `json:"repository,omitempty"`
	SHA               string                         `json:"sha,omitempty"`
	File              *forge.File                    `json:"file,omitempty"`
	Files             []forge.File                   `json:"files,omitempty"`
	Log               string                         `json:"log,omitempty"`
	Behind            *int                           `json:"behind,omitempty"`
	Change            *forge.Change                  `json:"change,omitempty"`
	Checks            []forge.Check                  `json:"checks,omitempty"`
	Approvals         []forge.Approval               `json:"approvals,omitempty"`
	Issues            []forge.Issue                  `json:"issues,omitempty"`
	Advisories        []forge.Advisory               `json:"advisories,omitempty"`
	Link              string                         `json:"link,omitempty"`
}

func ReadForge

func ReadForge(ctx context.Context, provider forge.Provider, op Operation) (Result, error)

type Target

type Target struct {
	OrgID    string `json:"org_id"`
	RunnerID string `json:"runner_id"`
}

Jump to

Keyboard shortcuts

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