Documentation
¶
Index ¶
- type CIContext
- type CheckRun
- type CreatedRelease
- type DecisionEvidence
- type DecisionOutcome
- type DeniedPR
- type DependBot
- type Dependency
- type DependencyContext
- type FailedPR
- type FailedRelease
- type GoModContext
- type MergeProfile
- type MergeResult
- type MergedPR
- type PRContext
- type PRFilter
- type PolicyAction
- type PolicyContext
- type PolicyDecision
- type ProfileContext
- type PullRequest
- type Release
- type ReleaseCandidate
- type ReleaseRequest
- type ReleaseResult
- type Repo
- type RepoContext
- type RepoFilter
- type RepoRef
- type RequiredAction
- type ReviewResult
- type ScanError
- type ScanResult
- type SkippedPR
- type SkippedRelease
- type Tag
- type UpdateType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CIContext ¶
type CIContext struct {
AllPassed bool `json:"allPassed"`
AnyFailed bool `json:"anyFailed"`
AnyPending bool `json:"anyPending"`
PassedChecks []string `json:"passedChecks"`
FailedChecks []string `json:"failedChecks"`
PendingChecks []string `json:"pendingChecks"`
RequiredPassed bool `json:"requiredPassed"`
}
CIContext contains CI/test status for policy evaluation.
type CheckRun ¶
type CheckRun struct {
Name string `json:"name"`
Status string `json:"status"` // queued, in_progress, completed
Conclusion string `json:"conclusion"` // success, failure, neutral, cancelled, skipped, timed_out, action_required
}
CheckRun represents a CI check run status.
type CreatedRelease ¶
type CreatedRelease struct {
Repo RepoRef `json:"repo"`
Version string `json:"version"`
PreviousVersion string `json:"previousVersion"`
ReleaseURL string `json:"releaseUrl"`
PRsMerged int `json:"prsMerged"`
}
CreatedRelease represents a successfully created release.
type DecisionEvidence ¶ added in v0.4.0
type DecisionEvidence struct {
Author string `json:"author"`
IsBot bool `json:"isBot"`
PRAge string `json:"prAge"`
UpdateType string `json:"updateType"`
Ecosystem string `json:"ecosystem"`
FilesChanged string `json:"filesChanged"`
CIStatus string `json:"ciStatus"`
Directives string `json:"directives"`
}
DecisionEvidence captures the key facts used in the decision.
type DecisionOutcome ¶ added in v0.4.0
type DecisionOutcome string
DecisionOutcome represents the type of action to take based on policy evaluation.
const ( // DecisionAutoApprove indicates the PR should be approved but not merged. DecisionAutoApprove DecisionOutcome = "AUTO_APPROVE" // DecisionAutoMerge indicates the PR should be approved and auto-merge enabled. DecisionAutoMerge DecisionOutcome = "AUTO_MERGE" // DecisionQueueForMerge indicates the PR should be added to merge queue. DecisionQueueForMerge DecisionOutcome = "QUEUE_FOR_MERGE" // DecisionManualReview indicates the PR needs human review. DecisionManualReview DecisionOutcome = "MANUAL_REVIEW" // DecisionSecurityReview indicates the PR needs security team review. DecisionSecurityReview DecisionOutcome = "SECURITY_TEAM_REVIEW" // DecisionReject indicates the PR should not be merged. DecisionReject DecisionOutcome = "REJECT" )
type DeniedPR ¶
type DeniedPR struct {
PR PullRequest `json:"pr"`
Reason string `json:"reason"`
}
DeniedPR represents a PR that was denied review approval.
type DependBot ¶
type DependBot string
DependBot identifies the dependency management bot.
func DetectDependBot ¶
DetectDependBot determines which dependency bot created a PR based on author.
type Dependency ¶
type Dependency struct {
Name string `json:"name"`
Ecosystem string `json:"ecosystem"` // go, npm, pip, maven, etc.
FromVersion string `json:"fromVersion"`
ToVersion string `json:"toVersion"`
UpdateType UpdateType `json:"updateType"` // major, minor, patch
}
Dependency represents a dependency update in a PR.
type DependencyContext ¶
type DependencyContext struct {
Name string `json:"name"`
Ecosystem string `json:"ecosystem"`
FromVersion string `json:"fromVersion"`
ToVersion string `json:"toVersion"`
UpdateType string `json:"updateType"`
IsMajor bool `json:"isMajor"`
IsMinor bool `json:"isMinor"`
IsPatch bool `json:"isPatch"`
}
DependencyContext contains dependency update information for policy evaluation.
type FailedPR ¶
type FailedPR struct {
PR PullRequest `json:"pr"`
Error string `json:"error"`
}
FailedPR represents a PR that failed to merge.
type FailedRelease ¶
FailedRelease represents a failed release attempt.
type GoModContext ¶ added in v0.4.0
type GoModContext struct {
// Directive changes
HasReplaceChange bool `json:"hasReplaceChange"`
HasExcludeChange bool `json:"hasExcludeChange"`
HasRetractChange bool `json:"hasRetractChange"`
HasToolchainChange bool `json:"hasToolchainChange"`
HasGoVersionChange bool `json:"hasGoVersionChange"`
HasDirectiveChanges bool `json:"hasDirectiveChanges"` // any of the above
// Dependency changes
HasNewDirectDependency bool `json:"hasNewDirectDependency"`
NewDirectDependencies []string `json:"newDirectDependencies,omitempty"`
RemovedDependencies []string `json:"removedDependencies,omitempty"`
// Version info
OldGoVersion string `json:"oldGoVersion,omitempty"`
NewGoVersion string `json:"newGoVersion,omitempty"`
}
GoModContext contains go.mod-specific analysis for policy evaluation. This is used to detect potentially dangerous changes beyond version bumps.
type MergeProfile ¶
type MergeProfile struct {
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
// Timing controls
MinAgeHours int `json:"minAgeHours" yaml:"minAgeHours"`
MinAgeDays int `json:"minAgeDays" yaml:"minAgeDays"` // N+5 quarantine period
MaxAgeHours int `json:"maxAgeHours" yaml:"maxAgeHours"`
// Update type controls
AutoMergePatch bool `json:"autoMergePatch" yaml:"autoMergePatch"`
AutoMergeMinor bool `json:"autoMergeMinor" yaml:"autoMergeMinor"`
AutoMergeMajor bool `json:"autoMergeMajor" yaml:"autoMergeMajor"`
// CI requirements
RequireAllChecks bool `json:"requireAllChecks" yaml:"requireAllChecks"`
RequiredChecks []string `json:"requiredChecks,omitempty" yaml:"requiredChecks,omitempty"`
AllowPendingChecks bool `json:"allowPendingChecks" yaml:"allowPendingChecks"`
// Merge settings
MergeStrategy string `json:"mergeStrategy" yaml:"mergeStrategy"` // merge, squash, rebase
DeleteBranch bool `json:"deleteBranch" yaml:"deleteBranch"`
// Safety
RequireApproval bool `json:"requireApproval" yaml:"requireApproval"`
MaxPRsPerRun int `json:"maxPRsPerRun" yaml:"maxPRsPerRun"`
}
MergeProfile defines a set of merge policies and behaviors.
type MergeResult ¶
type MergeResult struct {
Timestamp time.Time `json:"timestamp"`
DryRun bool `json:"dryRun"`
Merged []MergedPR `json:"merged,omitempty"`
Skipped []SkippedPR `json:"skipped,omitempty"`
Failed []FailedPR `json:"failed,omitempty"`
MergedCount int `json:"mergedCount"`
SkippedCount int `json:"skippedCount"`
FailedCount int `json:"failedCount"`
}
MergeResult contains the results of a merge operation.
type MergedPR ¶
type MergedPR struct {
PR PullRequest `json:"pr"`
MergedBy string `json:"mergedBy"`
SHA string `json:"sha"`
}
MergedPR represents a successfully merged PR.
type PRContext ¶
type PRContext struct {
Number int `json:"number"`
Title string `json:"title"`
Author string `json:"author"`
IsDependency bool `json:"isDependency"`
DependBot string `json:"dependBot"`
AgeHours int `json:"ageHours"`
AgeDays int `json:"ageDays"`
Mergeable bool `json:"mergeable"`
Draft bool `json:"draft"`
Labels []string `json:"labels"`
HasConflicts bool `json:"hasConflicts"`
// File gate fields
ChangedFiles []string `json:"changedFiles"`
OnlyGoModFiles bool `json:"onlyGoModFiles"`
ChangedFileExts []string `json:"changedFileExts"`
}
PRContext contains pull request information for policy evaluation.
type PRFilter ¶
type PRFilter struct {
State string `json:"state,omitempty"` // open, closed, all
DependBot DependBot `json:"dependBot,omitempty"` // renovate, dependabot, or empty for all
UpdateTypes []UpdateType `json:"updateTypes,omitempty"` // major, minor, patch
MinAgeHours int `json:"minAgeHours,omitempty"`
MaxAgeHours int `json:"maxAgeHours,omitempty"`
TestsPassed *bool `json:"testsPassed,omitempty"`
Mergeable *bool `json:"mergeable,omitempty"`
}
PRFilter defines criteria for filtering pull requests.
type PolicyAction ¶
type PolicyAction string
PolicyAction represents an action that can be evaluated against policies.
const ( PolicyActionReview PolicyAction = "review" PolicyActionMerge PolicyAction = "merge" PolicyActionRelease PolicyAction = "release" )
type PolicyContext ¶
type PolicyContext struct {
Repo RepoContext `json:"repo"`
PR PRContext `json:"pr"`
Dependency DependencyContext `json:"dependency"`
CI CIContext `json:"ci"`
GoMod GoModContext `json:"goMod"`
Profile ProfileContext `json:"profile"`
}
PolicyContext provides context for Cedar policy evaluation. This struct is serialized to JSON for Cedar entity evaluation.
type PolicyDecision ¶
type PolicyDecision struct {
// Allowed indicates whether the action is permitted.
Allowed bool `json:"allowed"`
// Action is the evaluated action (merge, review, release).
Action string `json:"action"`
// Outcome specifies what action to take (AUTO_MERGE, MANUAL_REVIEW, etc.).
Outcome DecisionOutcome `json:"outcome"`
// RequiredActions lists the specific actions to perform.
RequiredActions []RequiredAction `json:"requiredActions,omitempty"`
// Reasons explains why the decision was made.
Reasons []string `json:"reasons,omitempty"`
// Policies lists the policy IDs that contributed to the decision.
Policies []string `json:"policies,omitempty"`
// Evidence summarizes the context used for the decision.
Evidence *DecisionEvidence `json:"evidence,omitempty"`
}
PolicyDecision represents the result of policy evaluation.
func (*PolicyDecision) Summary ¶ added in v0.4.0
func (d *PolicyDecision) Summary() string
Summary returns a human-readable summary of the decision.
type ProfileContext ¶ added in v0.4.0
type ProfileContext struct {
Name string `json:"name"`
MinAgeHours int `json:"minAgeHours"`
MinAgeDays int `json:"minAgeDays"`
MaxPRsPerRun int `json:"maxPRsPerRun"`
}
ProfileContext contains merge profile settings for policy evaluation. This allows Cedar policies to reference profile-configured thresholds.
type PullRequest ¶
type PullRequest struct {
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body,omitempty"`
State string `json:"state"` // open, closed
Author string `json:"author"`
HTMLURL string `json:"htmlUrl"`
IsDependency bool `json:"isDependency"`
DependBot DependBot `json:"dependBot,omitempty"`
Dependency Dependency `json:"dependency,omitempty"`
TestsPassed bool `json:"testsPassed"`
Mergeable bool `json:"mergeable"`
MergeableStr string `json:"mergeableState,omitempty"`
Draft bool `json:"draft"`
Labels []string `json:"labels,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
MergedAt *time.Time `json:"mergedAt,omitempty"`
Repo RepoRef `json:"repo"`
}
PullRequest represents a GitHub pull request, with dependency-specific metadata.
func (*PullRequest) AgeHours ¶
func (pr *PullRequest) AgeHours() int
AgeHours returns the age of the PR in hours.
func (*PullRequest) IsMerged ¶
func (pr *PullRequest) IsMerged() bool
IsMerged returns true if the PR has been merged.
type Release ¶
type Release struct {
ID int64 `json:"id"`
TagName string `json:"tagName"`
Name string `json:"name"`
Body string `json:"body,omitempty"`
Draft bool `json:"draft"`
Prerelease bool `json:"prerelease"`
CreatedAt time.Time `json:"createdAt"`
PublishedAt time.Time `json:"publishedAt"`
HTMLURL string `json:"htmlUrl"`
Repo RepoRef `json:"repo"`
}
Release represents a GitHub release.
type ReleaseCandidate ¶
type ReleaseCandidate struct {
Repo Repo `json:"repo"`
CurrentVersion string `json:"currentVersion"`
ProposedVersion string `json:"proposedVersion"`
MergedPRs []PullRequest `json:"mergedPRs"`
MergedPRCount int `json:"mergedPRCount"`
LastReleaseAt *time.Time `json:"lastReleaseAt,omitempty"`
DaysSinceRelease int `json:"daysSinceRelease,omitempty"`
ShouldRelease bool `json:"shouldRelease"`
ReleaseReason string `json:"releaseReason,omitempty"`
}
ReleaseCandidate represents a repository that may need a new release.
type ReleaseRequest ¶
type ReleaseRequest struct {
Repo RepoRef `json:"repo"`
TagName string `json:"tagName"`
TargetCommitish string `json:"targetCommitish,omitempty"` // Branch or commit SHA
Name string `json:"name"`
Body string `json:"body"`
Draft bool `json:"draft"`
Prerelease bool `json:"prerelease"`
GenerateNotes bool `json:"generateNotes"`
}
ReleaseRequest contains the information needed to create a new release.
type ReleaseResult ¶
type ReleaseResult struct {
Timestamp time.Time `json:"timestamp"`
DryRun bool `json:"dryRun"`
Created []CreatedRelease `json:"created,omitempty"`
Skipped []SkippedRelease `json:"skipped,omitempty"`
Failed []FailedRelease `json:"failed,omitempty"`
CreatedCount int `json:"createdCount"`
SkippedCount int `json:"skippedCount"`
FailedCount int `json:"failedCount"`
}
ReleaseResult contains the results of creating releases.
type Repo ¶
type Repo struct {
Owner string `json:"owner"`
Name string `json:"name"`
FullName string `json:"fullName"`
Description string `json:"description,omitempty"`
DefaultBranch string `json:"defaultBranch"`
Private bool `json:"private"`
Archived bool `json:"archived"`
Language string `json:"language,omitempty"`
Topics []string `json:"topics,omitempty"`
UpdatedAt time.Time `json:"updatedAt"`
HTMLURL string `json:"htmlUrl"`
}
Repo represents a GitHub repository.
type RepoContext ¶
type RepoContext struct {
Owner string `json:"owner"`
Name string `json:"name"`
FullName string `json:"fullName"`
Private bool `json:"private"`
Archived bool `json:"archived"`
Language string `json:"language"`
Topics []string `json:"topics"`
IsMonorepo bool `json:"isMonorepo"`
}
RepoContext contains repository information for policy evaluation.
type RepoFilter ¶
type RepoFilter struct {
IncludeArchived bool `json:"includeArchived"`
IncludePrivate bool `json:"includePrivate"`
IncludeForks bool `json:"includeForks"`
Languages []string `json:"languages,omitempty"`
Topics []string `json:"topics,omitempty"`
ExcludeRepos []string `json:"excludeRepos,omitempty"`
MinStars int `json:"minStars,omitempty"`
HasOpenDependPRs bool `json:"hasOpenDependPRs"`
}
RepoFilter defines criteria for filtering repositories.
type RepoRef ¶
RepoRef is a lightweight reference to a repository.
func ParseRepoRef ¶
ParseRepoRef parses a full name like "owner/repo" into a RepoRef.
type RequiredAction ¶ added in v0.4.0
type RequiredAction string
RequiredAction represents an action that should be taken on the PR.
const ( ActionApprove RequiredAction = "approve" ActionEnableAutoMerge RequiredAction = "enable_auto_merge" ActionAddToQueue RequiredAction = "add_to_queue" ActionAddLabel RequiredAction = "add_label" ActionComment RequiredAction = "comment" ActionRequestReview RequiredAction = "request_review" )
type ReviewResult ¶
type ReviewResult struct {
Timestamp time.Time `json:"timestamp"`
DryRun bool `json:"dryRun"`
Approved []PullRequest `json:"approved,omitempty"`
Denied []DeniedPR `json:"denied,omitempty"`
ApprovedCount int `json:"approvedCount"`
DeniedCount int `json:"deniedCount"`
}
ReviewResult contains the results of reviewing PRs.
type ScanResult ¶
type ScanResult struct {
Timestamp time.Time `json:"timestamp"`
Orgs []string `json:"orgs"`
ReposScanned int `json:"reposScanned"`
PRsFound int `json:"prsFound"`
PRs []PullRequest `json:"prs"`
Errors []ScanError `json:"errors,omitempty"`
}
ScanResult contains the results of scanning for dependency PRs.
type SkippedPR ¶
type SkippedPR struct {
PR PullRequest `json:"pr"`
Reason string `json:"reason"`
}
SkippedPR represents a PR that was skipped during merge.
type SkippedRelease ¶
SkippedRelease represents a repository that was skipped for release.
type UpdateType ¶
type UpdateType string
UpdateType represents the semantic version update type.
const ( UpdateTypeMajor UpdateType = "major" UpdateTypeMinor UpdateType = "minor" UpdateTypePatch UpdateType = "patch" UpdateTypeUnknown UpdateType = "unknown" )