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 ¶
const WebhookURLPathBitbucket = "/webhook/bitbucket"
WebhookURLPathBitbucket is the path the Bitbucket webhook posts to. Used to identify which configured hook on a repository belongs to notifycat.
const WebhookURLPathGitHub = "/webhook/github"
WebhookURLPathGitHub is the path the GitHub webhook posts to. Used to identify which configured hook on a repository belongs to notifycat.
Variables ¶
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.
var RequiredBitbucketEvents = []string{
"pullrequest:created", "pullrequest:updated", "pullrequest:fulfilled",
"pullrequest:rejected", "pullrequest:approved",
"pullrequest:changes_request_created", "pullrequest:comment_created",
}
RequiredBitbucketEvents are the Bitbucket webhook event types the dispatcher consumes.
var RequiredGitHubEvents = []string{
"pull_request",
"pull_request_review",
"pull_request_review_comment",
"issue_comment",
}
RequiredGitHubEvents are the webhook event types the dispatcher consumes.
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 ¶
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 ¶
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 HookChecker ¶ added in v0.22.0
type HookChecker interface {
ListHookEvents(ctx context.Context, owner, repo, urlSuffix string) ([]string, error)
}
HookChecker exposes the provider-neutral endpoint the validator needs to confirm a repo's webhook coverage.
ListHookEvents lists the event types configured on the repo's webhooks whose target URL matches urlSuffix, returning the union across them 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 HookProbe ¶ added in v0.22.0
type HookProbe struct {
Checker HookChecker
URLSuffix string
RequiredEvents []string
}
HookProbe is the provider-neutral webhook-coverage check: the client that lists a repo's configured hook events, plus the URL suffix and required event set to check them against. Checker is nil when no API token is configured, in which case the check reports a skip.
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 RepoLister ¶ added in v0.22.0
RepoLister enumerates the repositories owned by an org (GitHub) or workspace (Bitbucket); either fills the same owner slot. Used to expand "*" at validate time. May be nil; the runner reports a skip in that case.
type RepoValidator ¶
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.
type SlackAPIError ¶
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.