config

package
v0.22.2 Latest Latest
Warning

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

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

Documentation

Overview

Package config loads runtime configuration from a single config.yaml file. Secrets are read separately from the environment (optionally via a .env file in development) and never appear in the YAML.

All secret values use the Secret type so they cannot leak through logging.

Index

Constants

View Source
const DefaultConfigFile = "./config.yaml"

DefaultConfigFile is used when NOTIFYCAT_CONFIG_FILE is unset.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ConfigFile is the path config.yaml was loaded from; the sibling
	// config.lock is derived from it.
	ConfigFile string

	// GitProvider is the required git_provider enum ("github"). It selects which
	// provider's secrets are required (see readSecrets) and hashes into every
	// lock entry (see routing Entry.Provider).
	GitProvider kernel.Provider

	Addr        string
	LogLevel    string
	LogFormat   string
	DatabaseURL string

	SlackBaseURL     string
	GitHubBaseURL    string
	BitbucketBaseURL string
	Domain           string

	MessageTTLDays   int
	IgnoreAIReviews  bool
	DependabotFormat bool

	Reactions Reactions

	Digest   *routingdomain.DigestConfig
	Mappings map[string]routingdomain.Org

	// DigestTimezone is the resolved timezone the digest scheduler and reporter
	// run in. Derived from Digest.Timezone at Load (default UTC); never nil.
	DigestTimezone *time.Location

	GitHubWebhookSecret Secret
	SlackBotToken       Secret
	GitHubToken         Secret

	// BitbucketWebhookSecret is required when git_provider is bitbucket (see
	// requireProviderSecret). BitbucketToken is the optional read credential with
	// exact GITHUB_TOKEN degradation parity (absent ⇒ path rules inert +
	// validation probes skip). BitbucketAuthEmail, when set, pairs with the token
	// to switch the Bitbucket client to HTTP Basic (the Free-plan wildcard path).
	BitbucketWebhookSecret Secret
	BitbucketToken         Secret
	BitbucketAuthEmail     string

	// SlackSigningSecret gates the inbound Slack interactivity endpoint
	// (POST /webhook/slack/interactions). Optional: when empty the endpoint is
	// not registered and notifycat behaves exactly as an outbound-only service.
	SlackSigningSecret Secret
}

Config is the parsed runtime configuration. Field names are flat so consumers read cfg.Addr, cfg.Reactions.NewPR, etc.; the nested config.yaml shape is an internal detail of Load (see fileSchema).

func Load

func Load() (Config, error)

Load reads .env (secrets only; absent is fine), decodes config.yaml over the defaults, reads secrets from the environment, and validates.

func (Config) ProviderToken added in v0.22.0

func (c Config) ProviderToken() Secret

ProviderToken returns the optional read token for the selected git provider (GitHubToken for github, BitbucketToken for bitbucket). Empty when unset; an empty token degrades path routing and validation probes identically for both providers.

func (Config) ProviderTokenVar added in v0.22.0

func (c Config) ProviderTokenVar() string

ProviderTokenVar is the environment-variable name of the selected provider's read token, used in the path-routing degradation messages.

func (Config) ProviderWebhookSecret added in v0.22.0

func (c Config) ProviderWebhookSecret() Secret

ProviderWebhookSecret returns the required webhook secret for the selected git provider (GitHubWebhookSecret or BitbucketWebhookSecret).

func (Config) ProviderWebhookSecretVar added in v0.22.0

func (c Config) ProviderWebhookSecretVar() string

ProviderWebhookSecretVar is the environment-variable name of the selected provider's webhook secret, used in doctor's config report.

type MissingVarError

type MissingVarError struct{ Var string }

MissingVarError is returned when a required secret env var is unset or empty.

func (*MissingVarError) Error

func (e *MissingVarError) Error() string

type Reactions

type Reactions struct {
	Enabled       bool
	NewPR         string
	MergedPR      string
	ClosedPR      string
	Approved      string
	Commented     string
	RequestChange string
	BotReview     string
}

Reactions configures Slack reaction emoji names per PR lifecycle event.

type Secret

type Secret string

Secret wraps a sensitive string (API token, webhook secret, password).

Its zero value is the empty string. Stringer, formatting verbs, and slog rendering all return a redaction placeholder so the raw value never reaches logs by accident. Use Reveal when handing the value to an external system.

func (Secret) Format

func (s Secret) Format(f fmtState, _ rune)

Format intercepts every Sprintf verb (%v, %s, %q, %+v, …) so we cannot leak the raw value through an unfamiliar verb.

func (Secret) GoString

func (s Secret) GoString() string

GoString satisfies fmt's %#v verb without leaking.

func (Secret) LogValue

func (s Secret) LogValue() slog.Value

LogValue ensures slog renders Secret with the same redaction placeholder.

func (Secret) Reveal

func (s Secret) Reveal() string

Reveal returns the underlying raw value. Call this only when passing the secret to an external system that needs it (HMAC, HTTP Authorization header, …). Never log the return value.

func (Secret) String

func (s Secret) String() string

String returns a placeholder so fmt and stringer-based logging never expose the underlying value. An empty Secret renders as "" to keep absence distinguishable from presence in operator output.

Jump to

Keyboard shortcuts

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