domain

package
v0.21.2 Latest Latest
Warning

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

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

Documentation

Overview

Package domain holds the validation domain's contracts: the ports that infrastructure adapters satisfy, the DTOs and enums that describe a validation run, and the constants that define what "valid" means. It is pure — it imports only the standard library, the shared kernel, and the routing domain (whose Entry and RepoMapping value objects it references).

Index

Constants

View Source
const WebhookURLPath = "/webhook/github"

WebhookURLPath is the path the GitHub webhook posts to. Used to identify which configured hook on a repository belongs to notifycat.

Variables

View Source
var ChannelIDPattern = regexp.MustCompile(`^[CGD][A-Z0-9]{2,}$`)

ChannelIDPattern mirrors the regex enforced when `add` writes a row, but is re-applied here so older rows (predating the regex) still get caught.

View Source
var RequiredGitHubEvents = []string{
	"pull_request",
	"pull_request_review",
	"pull_request_review_comment",
	"issue_comment",
}

RequiredGitHubEvents are the webhook event types the dispatcher consumes.

View Source
var RequiredSlackScopes = []string{"chat:write", "reactions:write"}

RequiredSlackScopes mirror what the runtime handlers actually call: chat.postMessage requires chat:write, reactions.add requires reactions:write. conversations.info itself needs channels:read or groups:read, but we surface that one via the Slack API error code, not as a separate scope check.

Functions

This section is empty.

Types

type ChannelInfo

type ChannelInfo struct {
	ID         string
	Name       string
	IsMember   bool
	IsArchived bool
}

ChannelInfo is the subset of a Slack channel's metadata the validator needs to confirm the bot can post: the channel's identity, whether the bot is a member, and whether it is archived. It mirrors the platform Slack client's own ChannelInfo; the validation infrastructure layer maps between the two so the domain stays free of the Slack SDK.

type CheckResult

type CheckResult struct {
	Name   string
	Status Status
	Detail string
}

CheckResult is one row of a Report.

type EntryResult

type EntryResult struct {
	Entry   routingdomain.Entry
	Reports []Report
}

EntryResult bundles every report produced for a single mapping entry, so callers can update the lock per-entry: an entry is "validated" only when every report it produced is OK.

func (EntryResult) OK

func (r EntryResult) OK() bool

OK reports whether every contributed report passed.

type GitHubChecker

type GitHubChecker interface {
	ListHookEvents(ctx context.Context, owner, repo, urlSuffix string) ([]string, error)
}

GitHubChecker exposes the GitHub endpoints the validator needs.

ListHookEvents returns the union of events configured across active webhooks whose target URL matches urlSuffix, or an empty slice when no such hook exists. Implementations should not error when no hook matches — "no hook" is a validation outcome, not a transport failure.

type MappingLookup

type MappingLookup interface {
	Get(ctx context.Context, repository string) (routingdomain.RepoMapping, error)
	PathChannels(repository string) []string
}

MappingLookup reads a single repository → channel mapping. The runner iterates entries explicitly, so no bulk-list method is needed here. PathChannels returns the extra channels a repo's per-path routing can post to, so the validator can confirm bot membership in each (empty for repos without `paths:`).

type OrgRepoLister

type OrgRepoLister interface {
	ListOrgRepos(ctx context.Context, org string) ([]string, error)
}

OrgRepoLister enumerates a GitHub org's repositories. Used to expand "*" at validate time. May be nil; the runner reports a skip in that case.

type RepoValidator

type RepoValidator interface {
	Validate(ctx context.Context, repository string) Report
}

RepoValidator validates one repository at a time. The application Validator satisfies it; the entry runner depends on this narrow surface so wildcard expansion can be tested without standing up real Slack/GitHub clients.

type Report

type Report struct {
	Repository string
	Checks     []CheckResult
}

Report aggregates the per-check results for a single mapping.

func (Report) OK

func (r Report) OK() bool

OK returns true when no check failed. Skipped checks do not count as failures.

type SlackAPIError

type SlackAPIError struct {
	Method string
	Code   string
}

SlackAPIError is a domain-level view of a Slack API error, carrying the method and error code the application interprets into an operator-facing remediation message. The validation infrastructure layer translates the platform Slack client's own API error into this type so the application can classify failures without importing the Slack SDK.

func (*SlackAPIError) Error

func (e *SlackAPIError) Error() string

Error renders the method and code, matching the platform client's format.

type SlackChecker

type SlackChecker interface {
	AuthTest(ctx context.Context) (userID string, scopes []string, err error)
	ConversationsInfo(ctx context.Context, channel string) (ChannelInfo, error)
}

SlackChecker exposes the Slack endpoints the validator needs. ConversationsInfo returns the domain ChannelInfo, not the Slack SDK type — the infrastructure adapter maps across that boundary.

type Status

type Status int

Status is the outcome of a single check.

const (
	// StatusOK means the check passed.
	StatusOK Status = iota
	// StatusFail means the check found a problem the operator must fix.
	StatusFail
	// StatusSkip means the check could not run (e.g., GitHub token absent).
	StatusSkip
)

func (Status) String

func (s Status) String() string

String renders Status as OK / FAIL / SKIP for greppable CLI output.

Jump to

Keyboard shortcuts

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