Documentation
¶
Overview ¶
Package infrastructure holds the maintenance adapters: the store-backed PR repository and the GitHub PR-state checker, each implementing a maintenance domain port.
Index ¶
- type BitbucketChecker
- type BitbucketPRStateGetter
- type GitHubChecker
- type PRRepository
- func (r *PRRepository) Delete(ctx context.Context, repository string, prNumber int) error
- func (r *PRRepository) DeleteStaleBefore(ctx context.Context, cutoff time.Time) (int64, error)
- func (r *PRRepository) ListOpen(ctx context.Context) ([]domain.PRRow, error)
- func (r *PRRepository) ListOpenWithMessages(ctx context.Context) ([]domain.TrackedPR, error)
- func (r *PRRepository) MarkClosed(ctx context.Context, repository string, prNumber int) error
- func (r *PRRepository) MoveMessage(ctx context.Context, repository string, prNumber int, ...) error
- func (r *PRRepository) RemoveMessage(ctx context.Context, repository string, prNumber int, channel string) error
- type PRStateGetter
- type RoutingPolicy
- type SlackCourier
- func (c *SlackCourier) CopyReactions(ctx context.Context, from, to domain.TrackedMessage, allowed []string) error
- func (c *SlackCourier) MarkMoved(ctx context.Context, from domain.TrackedMessage, toChannel string) error
- func (c *SlackCourier) Repost(ctx context.Context, from domain.TrackedMessage, toChannel string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitbucketChecker ¶ added in v0.22.0
type BitbucketChecker struct {
// contains filtered or unexported fields
}
BitbucketChecker adapts the Bitbucket client to domain.PRChecker: it splits "workspace/repo_slug" and reports whether the PR's state is "OPEN" (note: Bitbucket's state is uppercase). A 404 maps to domain.ErrPRNotFound and a draft PR (any state) to domain.ErrPRDraft, so the reconciler can drop either from the digest; any other API error is propagated verbatim, so the reconciler leaves the row untouched rather than wrongly acting on a PR it could not read (e.g. a transient 5xx). MERGED, DECLINED, and SUPERSEDED all report closed.
func NewBitbucketChecker ¶ added in v0.22.0
func NewBitbucketChecker(bb BitbucketPRStateGetter) *BitbucketChecker
NewBitbucketChecker wraps a Bitbucket client.
type BitbucketPRStateGetter ¶ added in v0.22.0
type BitbucketPRStateGetter interface {
GetPullRequest(ctx context.Context, workspace, repoSlug string, id int) (bitbucket.PullRequestState, error)
}
BitbucketPRStateGetter is the slice of the Bitbucket client the checker needs.
type GitHubChecker ¶
type GitHubChecker struct {
// contains filtered or unexported fields
}
GitHubChecker adapts the GitHub client to domain.PRChecker: it splits "owner/repo" and reports whether the PR's state is "open". A 404 maps to domain.ErrPRNotFound and a draft PR (any state) to domain.ErrPRDraft, so the reconciler can drop either from the digest; any other API error is propagated verbatim, so the reconciler leaves the row untouched rather than wrongly acting on a PR it could not read (e.g. a transient 5xx).
func NewGitHubChecker ¶
func NewGitHubChecker(gh PRStateGetter) *GitHubChecker
NewGitHubChecker wraps a GitHub client.
type PRRepository ¶
type PRRepository struct {
// contains filtered or unexported fields
}
PRRepository adapts the store's PullRequests repository to the maintenance domain ports (StaleMessageDeleter, OpenLister, Closer, Deleter). It maps store persistence models to maintenance domain DTOs at the boundary, so no gorm-tagged type ever crosses a port.
func NewPRRepository ¶
func NewPRRepository(pullRequests *persistence.PullRequests) *PRRepository
NewPRRepository wraps the store's PullRequests repository.
func (*PRRepository) DeleteStaleBefore ¶
DeleteStaleBefore implements domain.StaleMessageDeleter.
func (*PRRepository) ListOpen ¶
ListOpen implements domain.OpenLister, mapping store rows to domain PRRows.
func (*PRRepository) ListOpenWithMessages ¶ added in v0.25.0
ListOpenWithMessages implements domain.TrackedLister, mapping store rows and their messages to maintenance domain DTOs.
func (*PRRepository) MarkClosed ¶
MarkClosed implements domain.Closer.
func (*PRRepository) MoveMessage ¶ added in v0.25.0
func (r *PRRepository) MoveMessage(ctx context.Context, repository string, prNumber int, fromChannel, toChannel, messageID string) error
MoveMessage implements domain.MessageRows.
func (*PRRepository) RemoveMessage ¶ added in v0.25.0
func (r *PRRepository) RemoveMessage(ctx context.Context, repository string, prNumber int, channel string) error
RemoveMessage implements domain.MessageRows.
type PRStateGetter ¶
type PRStateGetter interface {
GetPullRequest(ctx context.Context, owner, repo string, number int) (github.PullRequestState, error)
}
PRStateGetter is the slice of the GitHub client the checker needs.
type RoutingPolicy ¶ added in v0.25.0
type RoutingPolicy struct {
// contains filtered or unexported fields
}
RoutingPolicy adapts the routing provider to the relocate use case's config ports: which reaction emoji a repository's notifications use, and which channels it is currently configured to post to.
func NewRoutingPolicy ¶ added in v0.25.0
func NewRoutingPolicy(provider *routingapp.Provider) *RoutingPolicy
NewRoutingPolicy wraps the routing provider.
func (*RoutingPolicy) AllowedReactions ¶ added in v0.25.0
AllowedReactions implements domain.ReactionPolicy. The new-PR emoji is always in the set; the close and review emoji only when the repo enables reactions, mirroring the handlers that add them.
func (*RoutingPolicy) ConfiguredChannels ¶ added in v0.25.0
func (p *RoutingPolicy) ConfiguredChannels(repository string) []string
ConfiguredChannels implements domain.ChannelConfig: the repository's base fan-out plus every extra base-list and `paths:` channel.
type SlackCourier ¶ added in v0.25.0
type SlackCourier struct {
// contains filtered or unexported fields
}
SlackCourier implements domain.MessageCourier over the Slack Web API: it reads a posted message's blocks, reposts them in another channel as a mention-free "moved" message, carries the reactions over, and edits the original into a pointer at its new home.
func NewSlackCourier ¶ added in v0.25.0
func NewSlackCourier(client *slack.Client) *SlackCourier
NewSlackCourier wraps a Slack client as the relocate courier.
func (*SlackCourier) CopyReactions ¶ added in v0.25.0
func (c *SlackCourier) CopyReactions(ctx context.Context, from, to domain.TrackedMessage, allowed []string) error
CopyReactions implements domain.MessageCourier. Only emoji in allowed are carried over: the rest are ad-hoc human reactions the bot cannot attribute, and re-adding them would credit the bot for other people's reactions.
func (*SlackCourier) MarkMoved ¶ added in v0.25.0
func (c *SlackCourier) MarkMoved(ctx context.Context, from domain.TrackedMessage, toChannel string) error
MarkMoved implements domain.MessageCourier: it edits the original in place into a pointer at its new channel. The message is never deleted, so the thread hanging off it stays readable in the old channel. A message that is already gone is success — the state the caller wanted is the state of the world.
func (*SlackCourier) Repost ¶ added in v0.25.0
func (c *SlackCourier) Repost(ctx context.Context, from domain.TrackedMessage, toChannel string) (string, error)
Repost implements domain.MessageCourier.