Documentation
¶
Index ¶
- Constants
- Variables
- func DryRunContext(ctx context.Context) context.Context
- func Fire(ctx context.Context, eventName string, vars map[string]string) error
- func FireSafe(ctx context.Context, eventName string, vars map[string]string)
- func GetTemplate(name string) ([]byte, error)
- func NotifySlack(ctx context.Context, webhookURL, message string) error
- func NotifyTelegram(ctx context.Context, botToken, chatID, message string, silent bool) error
- func ResetConfigCache()
- func ResolveBotToken(envVar, keychainService string) (string, error)
- func ResolveWebhookURL(envVar string) (string, error)
- type Config
- type DefaultsConfig
- type HookContext
- type HookDefinition
- type NotifierConfig
- type TemplateNotFoundError
Constants ¶
const ( // Build events (swiftship) EventBuildStart = "build.start" EventBuildAnalyzeDone = "build.analyze.done" EventBuildPlanDone = "build.plan.done" EventBuildGenerateDone = "build.generate.done" EventBuildCompileStart = "build.compile.start" EventBuildCompileSuccess = "build.compile.success" EventBuildCompileFailure = "build.compile.failure" EventBuildFixStart = "build.fix.start" EventBuildFixDone = "build.fix.done" EventBuildRunStart = "build.run.start" EventBuildRunSuccess = "build.run.success" EventBuildDone = "build.done" // Legacy aliases (kept for backward compat with existing configs) EventBuildFail = "build.fail" // Store events (appstore) EventStoreUploadStart = "store.upload.start" EventStoreUploadDone = "store.upload.done" EventStoreUploadFailure = "store.upload.failure" EventStoreProcessingStart = "store.processing.start" EventStoreProcessingDone = "store.processing.done" EventStoreTestflightDist = "store.testflight.distribute" EventStoreSubmitStart = "store.submit.start" EventStoreSubmitDone = "store.submit.done" EventStoreSubmitFailure = "store.submit.failure" EventStoreReviewStatus = "store.review.status" EventStoreReviewApproved = "store.review.approved" EventStoreReviewRejected = "store.review.rejected" EventStoreReleaseDone = "store.release.done" EventStoreValidatePass = "store.validate.pass" EventStoreValidateFail = "store.validate.fail" // Legacy aliases EventStoreUploadFail = "store.upload.fail" EventStoreSubmitFail = "store.submit.fail" EventStoreRelease = "store.release" EventStoreReviewStart = "store.review.start" EventStoreReviewDone = "store.review.done" EventStoreTestflightDone = "store.testflight.done" // Pipeline events EventPipelineStart = "pipeline.start" EventPipelineStepDone = "pipeline.step.done" EventPipelineDone = "pipeline.done" EventPipelineFailure = "pipeline.failure" // Legacy aliases EventWorkflowStart = "workflow.start" EventWorkflowDone = "workflow.done" EventWorkflowFail = "workflow.fail" EventWorkflowStep = "workflow.step" )
Hook event constants. These are the lifecycle events that can trigger hooks.
Variables ¶
var TemplateFS embed.FS
var TemplateNames = map[string]string{
"indie": "templates/indie.yaml",
"team": "templates/team.yaml",
"ci": "templates/ci.yaml",
}
TemplateNames maps template identifiers to their embedded file paths.
Functions ¶
func DryRunContext ¶
DryRunContext returns a context with dry-run mode enabled.
func Fire ¶
Fire loads the hook config, finds hooks matching the given event, and executes them. If no config exists, it returns nil silently.
func FireSafe ¶
FireSafe fires a hook event, logging any errors to stderr without returning them. Use this from embedded hook points where failures must never block the main operation.
func GetTemplate ¶
GetTemplate returns the content of an embedded template by name.
func NotifySlack ¶
NotifySlack sends a message via a Slack incoming webhook.
func NotifyTelegram ¶
NotifyTelegram sends a message via the Telegram Bot API.
func ResetConfigCache ¶
func ResetConfigCache()
ResetConfigCache clears the cached config (useful for testing or re-reading).
func ResolveBotToken ¶
ResolveBotToken resolves a Telegram bot token from: env var, macOS keychain, or error.
func ResolveWebhookURL ¶
ResolveWebhookURL resolves a Slack webhook URL from an environment variable.
Types ¶
type Config ¶
type Config struct {
Version int `yaml:"version"`
Notifiers map[string]NotifierConfig `yaml:"notifiers"`
Defaults DefaultsConfig `yaml:"defaults"`
Hooks map[string][]HookDefinition `yaml:"hooks"`
}
Config represents the top-level hooks.yaml configuration.
func LoadConfig ¶
LoadConfig loads and merges hooks configuration from global and project paths. Returns nil config (no error) if no config files exist.
func LoadConfigFromPath ¶
LoadConfigFromPath loads a single config file (used for validation).
func (*Config) ResolveLogDir ¶
ResolveLogDir returns the expanded log directory path.
type DefaultsConfig ¶
type DefaultsConfig struct {
Timeout string `yaml:"timeout"`
ContinueOnError bool `yaml:"continue_on_error"`
LogDir string `yaml:"log_dir"`
}
DefaultsConfig holds default settings for hook execution.
type HookContext ¶
HookContext carries the event name and key-value variables for template substitution.
type HookDefinition ¶
type HookDefinition struct {
Name string `yaml:"name"`
Run string `yaml:"run"`
Notify string `yaml:"notify"`
Template string `yaml:"template"`
When string `yaml:"when"` // "always", "success", "failure"
Timeout string `yaml:"timeout"`
}
HookDefinition defines a single hook action.
func (*HookDefinition) TimeoutDuration ¶
func (h *HookDefinition) TimeoutDuration(defaults DefaultsConfig) time.Duration
TimeoutDuration returns the parsed timeout for a hook, falling back to the config default.
type NotifierConfig ¶
type NotifierConfig struct {
Enabled bool `yaml:"enabled"`
BotTokenEnv string `yaml:"bot_token_env"`
BotTokenKeychain string `yaml:"bot_token_keychain"`
ChatID string `yaml:"chat_id"`
WebhookURLEnv string `yaml:"webhook_url_env"`
}
NotifierConfig represents a notifier service configuration.
type TemplateNotFoundError ¶
type TemplateNotFoundError struct {
Name string
}
TemplateNotFoundError is returned when a template name is not recognized.
func (*TemplateNotFoundError) Error ¶
func (e *TemplateNotFoundError) Error() string