Documentation
¶
Index ¶
- Constants
- Variables
- func ChangeActionStrings() []string
- func NormalizeBranchName(ref string) string
- func RedactProviderError(err error, token string) error
- func SSRFProtectedDialContext() func(context.Context, string, string) (net.Conn, error)
- func SSRFProtectedDialContextWithLookup(lookup lookupIPAddrFunc, dial dialContextFunc) func(context.Context, string, string) (net.Conn, error)
- type ChangeAction
- type Config
- type Credentials
- type ProofCheck
- type ProofCheckClient
- type ProofCheckPublisher
- type ProposalClient
- type ProposalGetRequest
- type ProposalKind
- type ProposalListRequest
- type ProposalReader
- type ProposalRef
- type ProposalRequest
- type ProposalState
- type ProposalUpdateRequest
- type RepositoryBootstrapRequest
- type RepositoryBootstrapResult
- type RepositoryClient
- type RepositoryFile
- type RepositoryRef
- type VerifiedChange
- type VerifiedChangeEvent
Constants ¶
const (
MaxChangeWebhookBytes = 2 * 1024 * 1024
)
Variables ¶
var ( ErrChangeAuthentication = xerror.New(xerror.KindUnauthorized, "GIT_CHANGE_AUTHENTICATION_FAILED", "git change authentication failed") ErrChangeActionIgnored = xerror.New(xerror.KindInvalidInput, "GIT_CHANGE_ACTION_IGNORED", "git change action is not handled") ErrChangePayloadTooLarge = xerror.New(xerror.KindInvalidInput, "GIT_CHANGE_PAYLOAD_TOO_LARGE", "git change payload is too large") ErrChangeClosed = xerror.New(xerror.KindInvalidInput, "GIT_CHANGE_CLOSED", "git change is closed") ErrChangeStale = xerror.New(xerror.KindInvalidInput, "GIT_CHANGE_STALE_HEAD", "git change head is stale") ErrChangePermissionLost = xerror.New(xerror.KindForbidden, "GIT_CHANGE_PERMISSION_LOST", "git change permission was lost") ErrChangeRefDeleted = xerror.New(xerror.KindNotFound, "GIT_CHANGE_REF_DELETED", "git change ref was deleted") ErrChangePathMissing = xerror.New(xerror.KindNotFound, "GIT_CHANGE_PATH_MISSING", "git change pipeline path is missing") ErrChangeUnreachable = xerror.New(xerror.KindNotFound, "GIT_CHANGE_COMMIT_UNREACHABLE", "git change commit is unreachable") )
var ErrRepositoryCleanupFailed = xerror.New( xerror.KindUnavailable, "REPOSITORY_CLEANUP_FAILED", "repository bootstrap cleanup failed", )
Functions ¶
func ChangeActionStrings ¶
func ChangeActionStrings() []string
ChangeActionStrings returns a slice of all String values of the enum
func NormalizeBranchName ¶
NormalizeBranchName strips provider-neutral refs/heads prefixes from branch names.
func RedactProviderError ¶
RedactProviderError removes token-like values and the resolved token from provider errors.
func SSRFProtectedDialContext ¶
SSRFProtectedDialContext returns a dialer that connects only to vetted public IPs.
Types ¶
type ChangeAction ¶
type ChangeAction int
const ( ChangeActionUnknown ChangeAction = iota // unknown ChangeActionUpsert // upsert ChangeActionClose // close )
func ChangeActionString ¶
func ChangeActionString(s string) (ChangeAction, error)
ChangeActionString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func ChangeActionValues ¶
func ChangeActionValues() []ChangeAction
ChangeActionValues returns all values of the enum
func (ChangeAction) IsAChangeAction ¶
func (i ChangeAction) IsAChangeAction() bool
IsAChangeAction returns "true" if the value is listed in the enum definition. "false" otherwise
func (ChangeAction) MarshalJSON ¶
func (i ChangeAction) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for ChangeAction
func (ChangeAction) MarshalText ¶
func (i ChangeAction) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for ChangeAction
func (ChangeAction) String ¶
func (i ChangeAction) String() string
func (*ChangeAction) UnmarshalJSON ¶
func (i *ChangeAction) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for ChangeAction
func (*ChangeAction) UnmarshalText ¶
func (i *ChangeAction) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for ChangeAction
type Config ¶
type Config struct {
AllowPlaintext bool `json:"-"`
BaseURL string `json:"base_url,omitempty" validate:"omitempty,url"`
TimeoutSeconds int `json:"timeout_seconds,omitempty" validate:"omitempty,min=1,max=300"`
AllowPrivateHosts bool `json:"allow_private_hosts,omitempty"`
}
Config controls provider API client construction.
type Credentials ¶
type Credentials struct {
Token string `json:"token" validate:"required,min=1"`
GitHubContentsPermission *string `json:"-"`
}
Credentials holds provider API authentication values.
type ProofCheck ¶
type ProofCheck struct {
RepositoryID, ChangeRequestID string
HeadSHA, ExternalID, DetailsURL, Summary string
Conclusion string
// ExistingOnly invalidates historical evidence without creating checks on closed or changed candidates.
ExistingOnly bool
}
ProofCheck is the sanitized provider-visible projection of one immutable Proof receipt.
type ProofCheckClient ¶
type ProofCheckClient interface {
ProposalReader
ProofCheckPublisher
}
type ProofCheckPublisher ¶
type ProofCheckPublisher interface {
PublishProofCheck(context.Context, ProofCheck) error
}
ProofCheckPublisher creates or updates the check identified by its exact head and external ID.
type ProposalClient ¶
type ProposalClient interface {
ProposalReader
ListOpenProposals(ctx context.Context, req ProposalListRequest) ([]ProposalRef, error)
CreateProposal(ctx context.Context, req ProposalRequest) (*ProposalRef, error)
UpdateProposal(ctx context.Context, req ProposalUpdateRequest) (*ProposalRef, error)
}
ProposalClient performs provider-native proposal operations.
type ProposalGetRequest ¶
type ProposalGetRequest struct {
ProposalID string
}
ProposalGetRequest selects one provider proposal by its repository-local identifier.
type ProposalKind ¶
type ProposalKind string
ProposalKind identifies provider-native code review proposal objects.
const ( ProposalKindPullRequest ProposalKind = "pull_request" ProposalKindMergeRequest ProposalKind = "merge_request" )
type ProposalListRequest ¶
ProposalListRequest selects provider proposals for one source and target branch pair.
type ProposalReader ¶
type ProposalReader interface {
GetProposal(ctx context.Context, req ProposalGetRequest) (*ProposalRef, error)
}
ProposalReader separates read-only proposal verification from mutation so proof ingestion cannot acquire provider write authority.
type ProposalRef ¶
type ProposalRef struct {
Provider repostore.Provider
Repository RepositoryRef
RepositoryID string
ID string
URL string
SourceBranch string
TargetBranch string
State ProposalState
HeadSHA string
ProviderKind ProposalKind
Closed bool
Merged bool
}
ProposalRef contains safe provider proposal metadata used by publish, refresh, and future webhooks.
type ProposalRequest ¶
ProposalRequest creates a provider-native PR/MR proposal.
type ProposalState ¶
type ProposalState string
ProposalState is a normalized provider proposal lifecycle state.
const ( ProposalStateOpen ProposalState = "open" ProposalStateClosed ProposalState = "closed" ProposalStateMerged ProposalState = "merged" )
type ProposalUpdateRequest ¶
ProposalUpdateRequest updates an existing provider-native PR/MR proposal.
type RepositoryBootstrapRequest ¶
type RepositoryBootstrapRequest struct {
Owner string
Name string
DefaultBranch string
Files []RepositoryFile
// Marker binds resumable creation to a durable, non-secret setup identity.
Marker string
ExpectedRepositoryID string
}
RepositoryBootstrapRequest creates a private repository with an exact template.
type RepositoryBootstrapResult ¶
type RepositoryBootstrapResult struct {
Repository RepositoryRef
RepositoryID string
RemoteURL string
HeadSHA string
OwnerKind string
}
RepositoryBootstrapResult is safe provider provenance for a created repository.
type RepositoryClient ¶
type RepositoryClient interface {
ValidateRepository(ctx context.Context, branch string) error
BootstrapRepository(ctx context.Context, req RepositoryBootstrapRequest) (*RepositoryBootstrapResult, error)
DeleteRepository(ctx context.Context, repositoryID string) error
}
RepositoryClient validates, creates, and cleans up provider repositories.
type RepositoryFile ¶
RepositoryFile is one sanitized file in a provider-created repository's first commit.
type RepositoryRef ¶
type RepositoryRef struct {
Provider repostore.Provider
Owner string
Name string
ProjectPath string
FullName string
}
RepositoryRef identifies a provider repository without credentials.
func RepositoryRefFromRemoteURL ¶
func RepositoryRefFromRemoteURL(provider repostore.Provider, repoURL string) (RepositoryRef, error)
RepositoryRefFromRemoteURL parses a git remote URL into provider API repository identity.
type VerifiedChange ¶
type VerifiedChange struct {
Provider repostore.Provider
ProviderConnectionID string
RepositoryID string
ChangeRequestID string
HeadSHA string
SourceRef string
TargetRef string
PipelinePath string
Rerequest bool
}
VerifiedChange is provider-neutral identity emitted only after an adapter has authenticated its webhook, CI identity, or CLI caller.
func (VerifiedChange) Validate ¶
func (c VerifiedChange) Validate() error
Validate rejects incomplete or mutable Git identity before target lookup.
type VerifiedChangeEvent ¶
type VerifiedChangeEvent struct {
DeliveryID string
BodySHA256 string
Action ChangeAction
Provider repostore.Provider
OrganizationSlug slug.Slug
ProviderConnectionID string
RepositoryID string
ChangeRequestID string
HeadSHA string
SourceRef string
TargetRef string
Rerequest bool
}
VerifiedChangeEvent is the authenticated provider signal persisted for background processing. GitLab carries its binding organization; pipeline paths and GitHub organization ownership are resolved later.
func (VerifiedChangeEvent) Change ¶
func (e VerifiedChangeEvent) Change(pipelinePath string) VerifiedChange
func (VerifiedChangeEvent) Validate ¶
func (e VerifiedChangeEvent) Validate() error