Documentation
¶
Index ¶
- Variables
- func EvaluateProfile(profile *model.MergeProfile, pr *model.PullRequest, checks []model.CheckRun) (bool, string)
- func GetProfile(name string) *model.MergeProfile
- func ListProfiles() []string
- func LoadProfileFromBytes(data []byte) (*model.MergeProfile, error)
- func LoadProfileFromFile(path string) (*model.MergeProfile, error)
- func SaveProfileToFile(profile *model.MergeProfile, path string) error
- type ContextBuilder
- type Engine
- func (e *Engine) CanMerge(ctx context.Context, pr *model.PullRequest, checks []model.CheckRun) (*model.PolicyDecision, error)
- func (e *Engine) CanRelease(ctx context.Context) (*model.PolicyDecision, error)
- func (e *Engine) CanReview(ctx context.Context, pr *model.PullRequest, checks []model.CheckRun) (*model.PolicyDecision, error)
- func (e *Engine) Evaluate(ctx context.Context, action model.PolicyAction, pr *model.PullRequest, ...) (*model.PolicyDecision, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ProfileAggressive merges all passing PRs immediately. ProfileAggressive = model.MergeProfile{ Name: "aggressive", Description: "Merge all passing dependency PRs immediately", MinAgeHours: 0, MaxAgeHours: 0, AutoMergePatch: true, AutoMergeMinor: true, AutoMergeMajor: true, RequireAllChecks: true, AllowPendingChecks: false, MergeStrategy: "squash", DeleteBranch: true, RequireApproval: false, MaxPRsPerRun: 0, } // ProfileBalanced waits 24h and only merges patch/minor updates. ProfileBalanced = model.MergeProfile{ Name: "balanced", Description: "Wait 24h, auto-merge patch and minor updates only", MinAgeHours: 24, MaxAgeHours: 0, AutoMergePatch: true, AutoMergeMinor: true, AutoMergeMajor: false, RequireAllChecks: true, AllowPendingChecks: false, MergeStrategy: "squash", DeleteBranch: true, RequireApproval: false, MaxPRsPerRun: 10, } // ProfileConservative requires manual review for all but patch updates. ProfileConservative = model.MergeProfile{ Name: "conservative", Description: "Auto-merge only patch updates after 48h, manual review for others", MinAgeHours: 48, MaxAgeHours: 0, AutoMergePatch: true, AutoMergeMinor: false, AutoMergeMajor: false, RequireAllChecks: true, AllowPendingChecks: false, MergeStrategy: "squash", DeleteBranch: true, RequireApproval: true, MaxPRsPerRun: 5, } )
Predefined merge profiles.
Functions ¶
func EvaluateProfile ¶
func EvaluateProfile(profile *model.MergeProfile, pr *model.PullRequest, checks []model.CheckRun) (bool, string)
EvaluateProfile evaluates a PR against a merge profile. Returns true if the PR should be merged according to the profile.
func GetProfile ¶
func GetProfile(name string) *model.MergeProfile
GetProfile returns a merge profile by name.
func LoadProfileFromBytes ¶
func LoadProfileFromBytes(data []byte) (*model.MergeProfile, error)
LoadProfileFromBytes loads a merge profile from YAML bytes.
func LoadProfileFromFile ¶
func LoadProfileFromFile(path string) (*model.MergeProfile, error)
LoadProfileFromFile loads a merge profile from a YAML file.
func SaveProfileToFile ¶
func SaveProfileToFile(profile *model.MergeProfile, path string) error
SaveProfileToFile saves a merge profile to a YAML file.
Types ¶
type ContextBuilder ¶
type ContextBuilder struct{}
ContextBuilder builds PolicyContext from PR and check information.
func NewContextBuilder ¶
func NewContextBuilder() *ContextBuilder
NewContextBuilder creates a new context builder.
func (*ContextBuilder) Build ¶
func (b *ContextBuilder) Build(pr *model.PullRequest, repo *model.Repo, checks []model.CheckRun) *model.PolicyContext
Build creates a PolicyContext from a PR and its checks.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine evaluates policies for PR merge decisions. This is a simplified implementation that uses merge profiles. Cedar policy support can be added in a future version.
func NewEngineWithProfile ¶
func NewEngineWithProfile(profile *model.MergeProfile) *Engine
NewEngineWithProfile creates a new policy engine with the given profile.
func (*Engine) CanMerge ¶
func (e *Engine) CanMerge(ctx context.Context, pr *model.PullRequest, checks []model.CheckRun) (*model.PolicyDecision, error)
CanMerge evaluates whether a PR can be auto-merged.
func (*Engine) CanRelease ¶
CanRelease evaluates whether a release can be created.
func (*Engine) CanReview ¶
func (e *Engine) CanReview(ctx context.Context, pr *model.PullRequest, checks []model.CheckRun) (*model.PolicyDecision, error)
CanReview evaluates whether a PR can be auto-reviewed.
func (*Engine) Evaluate ¶
func (e *Engine) Evaluate(ctx context.Context, action model.PolicyAction, pr *model.PullRequest, checks []model.CheckRun) (*model.PolicyDecision, error)
Evaluate evaluates the policy for the given action and context.