infrastructure

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 10 Imported by: 0

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

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.

func (*BitbucketChecker) IsOpen added in v0.22.0

func (c *BitbucketChecker) IsOpen(ctx context.Context, repository string, number int) (bool, error)

IsOpen implements domain.PRChecker: it reports whether the PR's Bitbucket state is "OPEN" (MERGED, DECLINED, and SUPERSEDED all report closed).

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.

func (*GitHubChecker) IsOpen

func (c *GitHubChecker) IsOpen(ctx context.Context, repository string, number int) (bool, error)

IsOpen implements domain.PRChecker: it reports whether the PR's GitHub state is "open" (merged and closed PRs both report "closed").

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) Delete

func (r *PRRepository) Delete(ctx context.Context, repository string, prNumber int) error

Delete implements domain.Deleter.

func (*PRRepository) DeleteStaleBefore

func (r *PRRepository) DeleteStaleBefore(ctx context.Context, cutoff time.Time) (int64, error)

DeleteStaleBefore implements domain.StaleMessageDeleter.

func (*PRRepository) ListOpen

func (r *PRRepository) ListOpen(ctx context.Context) ([]domain.PRRow, error)

ListOpen implements domain.OpenLister, mapping store rows to domain PRRows.

func (*PRRepository) MarkClosed

func (r *PRRepository) MarkClosed(ctx context.Context, repository string, prNumber int) error

MarkClosed implements domain.Closer.

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.

Jump to

Keyboard shortcuts

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