infrastructure

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package infrastructure holds the diagnostics adapters: the config snapshot and database probe, the routing lock gateway, the request signer, the webhook sender, the report writer, and the smoke store/Slack adapters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfigSnapshot

func NewConfigSnapshot(cfg config.Config, entries []routingdomain.Entry, hasPathRules bool) diagnosticsdomain.ConfigSnapshot

NewConfigSnapshot builds a ConfigSnapshot from a parsed Config plus the already-resolved routing facts. It probes the database with the same open+ping logic as the old doctor.CheckDatabase so the application layer never needs to import config or persistence.

func WriteLockWarning

func WriteLockWarning(stderr io.Writer, err error)

WriteLockWarning formats the warning message emitted when Plan returns a non-nil error (malformed lock). It writes to stderr and returns the formatted string so callers do not need to know the exact phrasing.

func WriteReport

func WriteReport(w io.Writer, sections []diagnosticsdomain.Section) bool

WriteReport renders sections to w in a human-readable, greppable form, and returns true iff no check failed (skipped checks do not fail the report). The format is intentionally plain text: one section header per group, then one indented line per check.

Types

type BitbucketSigner added in v0.22.0

type BitbucketSigner struct{}

BitbucketSigner implements diagnosticsdomain.Signer using the Bitbucket HMAC-SHA256 scheme from the platform security package.

func NewBitbucketSigner added in v0.22.0

func NewBitbucketSigner() *BitbucketSigner

NewBitbucketSigner returns a BitbucketSigner.

func (BitbucketSigner) Sign added in v0.22.0

func (BitbucketSigner) Sign(secret string, body []byte) (header, value string)

Sign returns (security.SignatureHeaderBitbucket, security.Sign(secret, body)).

type BitbucketWebhookBuilder added in v0.22.0

type BitbucketWebhookBuilder struct{}

BitbucketWebhookBuilder implements diagnosticsdomain.WebhookBuilder by producing Bitbucket-shaped webhook bodies. Each SmokeEvent maps to the JSON structure and X-Event-Key header value that the Bitbucket inbound parser reads.

func NewBitbucketWebhookBuilder added in v0.22.0

func NewBitbucketWebhookBuilder() *BitbucketWebhookBuilder

NewBitbucketWebhookBuilder returns a BitbucketWebhookBuilder.

func (BitbucketWebhookBuilder) Build added in v0.22.0

Build renders a ForgedWebhook for the given neutral SmokeEvent using Bitbucket webhook vocabulary. The body's field names match rawBitbucketPayload in the notification inbound adapter.

type GitHubSigner

type GitHubSigner struct{}

GitHubSigner implements diagnosticsdomain.Signer using the GitHub HMAC-SHA256 scheme from the platform security package.

func NewGitHubSigner

func NewGitHubSigner() *GitHubSigner

NewGitHubSigner returns a GitHubSigner.

func (GitHubSigner) Sign

func (GitHubSigner) Sign(secret string, body []byte) (header, value string)

Sign returns (security.SignatureHeader, security.Sign(secret, body)).

type GitHubWebhookBuilder added in v0.22.0

type GitHubWebhookBuilder struct{}

GitHubWebhookBuilder implements diagnosticsdomain.WebhookBuilder by producing GitHub-shaped webhook bodies. Each SmokeEvent maps to the exact JSON structure and X-GitHub-Event header value the notification handlers expect.

func NewGitHubWebhookBuilder added in v0.22.0

func NewGitHubWebhookBuilder() *GitHubWebhookBuilder

NewGitHubWebhookBuilder returns a GitHubWebhookBuilder.

func (GitHubWebhookBuilder) Build added in v0.22.0

Build renders a ForgedWebhook for the given neutral SmokeEvent using GitHub webhook vocabulary. It reproduces exactly the JSON fields the GitHub inbound parser and notification handlers read.

type HTTPWebhookSender

type HTTPWebhookSender struct {
	// contains filtered or unexported fields
}

HTTPWebhookSender implements diagnosticsdomain.WebhookSender over *http.Client.

func NewHTTPWebhookSender

func NewHTTPWebhookSender(client *http.Client) *HTTPWebhookSender

NewHTTPWebhookSender returns a sender that uses the given HTTP client.

func (*HTTPWebhookSender) Send

func (s *HTTPWebhookSender) Send(ctx context.Context, url string, body []byte, headers map[string]string) (int, error)

Send POSTs body to url with the provided headers and returns the HTTP status code. A transport error returns status 0 and a non-nil err.

type LockGateway

type LockGateway struct {
	// contains filtered or unexported fields
}

LockGateway implements diagnosticsdomain.LockGateway over the routing infrastructure lock-store functions. lockPath is the path to the .lock file that lives next to mappings.yaml; clock is used to stamp ValidatedAt on each entry that passes validation.

func NewLockGateway

func NewLockGateway(lockPath string, clock func() time.Time) *LockGateway

NewLockGateway returns a LockGateway for the given lock file path and clock.

func (*LockGateway) Commit

func (g *LockGateway) Commit(successes []validationdomain.EntryResult, stale []string) error

Commit writes the merged lock: the existing lock is read, successful validation results are merged in (keyed by entry hash + current time), and stale keys are dropped.

func (*LockGateway) CommitTargeted

func (g *LockGateway) CommitTargeted(entry routingdomain.Entry) error

CommitTargeted reads the current lock, sets the single entry's LockEntry (SHA256 + ValidatedAt), and writes it back. Used after a targeted validation pass on an explicit (non-wildcard) entry.

func (*LockGateway) Plan

func (g *LockGateway) Plan(entries []routingdomain.Entry, force bool) (diagnosticsdomain.LockPlan, error)

Plan reads the on-disk lock and diffs it against entries. When force is true the on-disk lock is ignored and every entry is returned for (re)validation. A missing lock file is not an error — it returns all entries for validation. A malformed lock file is also non-fatal; the caller should log the warning (Plan surfaces the error so the caller can do so) but all entries still validate.

type MappingsSmokeMappings

type MappingsSmokeMappings struct {
	// contains filtered or unexported fields
}

MappingsSmokeMappings implements diagnosticsdomain.SmokeMappings over a mappings provider that satisfies the routing domain's MappingProvider port.

func NewMappingsSmokeMappings

func NewMappingsSmokeMappings(provider smokeRoutingProvider) *MappingsSmokeMappings

NewMappingsSmokeMappings returns a SmokeMappings adapter for any provider that can resolve a repository to a RepoMapping.

func (*MappingsSmokeMappings) Get

Get resolves target to its RepoMapping. Returns routingdomain.ErrNotFound (which is identical to persistence.ErrNotFound) when the repository is absent.

type SlackSmokeReactions

type SlackSmokeReactions struct {
	// contains filtered or unexported fields
}

SlackSmokeReactions implements diagnosticsdomain.SmokeReactions over *slack.Client, returning only the emoji name strings.

func NewSlackSmokeReactions

func NewSlackSmokeReactions(client *slack.Client) *SlackSmokeReactions

NewSlackSmokeReactions returns a SmokeReactions backed by the given Slack client.

func (*SlackSmokeReactions) Reactions

func (s *SlackSmokeReactions) Reactions(ctx context.Context, channel, ts string) ([]string, error)

Reactions calls reactions.get and returns only the emoji names from each Reaction entry.

type StoreSmokeCleanup

type StoreSmokeCleanup struct {
	// contains filtered or unexported fields
}

StoreSmokeCleanup implements diagnosticsdomain.SmokeCleanup over *persistence.PullRequests.

func NewStoreSmokeCleanup

func NewStoreSmokeCleanup(pullRequests *persistence.PullRequests) *StoreSmokeCleanup

NewStoreSmokeCleanup returns a StoreSmokeCleanup backed by the given persistence.

func (*StoreSmokeCleanup) DeletePR

func (s *StoreSmokeCleanup) DeletePR(ctx context.Context, repository string, prNumber int) error

DeletePR deletes the synthetic pull_requests row. It is a no-op when the row is absent, so it is safe to call even if delivery failed.

type StoreSmokeMessages

type StoreSmokeMessages struct {
	// contains filtered or unexported fields
}

StoreSmokeMessages implements diagnosticsdomain.SmokeMessages over *persistence.PullRequests, converting persistence.Message to domain.SmokeMessage.

func NewStoreSmokeMessages

func NewStoreSmokeMessages(pullRequests *persistence.PullRequests) *StoreSmokeMessages

NewStoreSmokeMessages returns a StoreSmokeMessages backed by the given persistence.

func (*StoreSmokeMessages) Messages

func (s *StoreSmokeMessages) Messages(ctx context.Context, repository string, prNumber int) ([]diagnosticsdomain.SmokeMessage, error)

Messages returns the PR's stored messages as domain SmokeMessages. A persistence.ErrNotFound is propagated as-is so the application layer can detect the "no row" case.

Jump to

Keyboard shortcuts

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