config

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertLegacyReference

func ConvertLegacyReference(ref *ProviderRef) string

ConvertLegacyReference converts a legacy ProviderRef to a store:// URI

Types

type Config

type Config struct {
	Path           string
	Logger         *logging.Logger
	NonInteractive bool
	Definition     *Definition // New format with separated secret stores and services
}

Config holds the runtime configuration

func (*Config) GetEnvironment

func (c *Config) GetEnvironment(name string) (Environment, error)

GetEnvironment returns the configuration for a specific environment

func (*Config) GetPolicyEnforcer

func (c *Config) GetPolicyEnforcer() *policy.PolicyEnforcer

GetPolicyEnforcer returns a policy enforcer for the configuration

func (*Config) GetProvider

func (c *Config) GetProvider(name string) (ProviderConfig, error)

GetProvider returns the configuration for a provider (works with both secret stores and services)

func (*Config) GetSecretStore

func (c *Config) GetSecretStore(name string) (SecretStoreConfig, error)

GetSecretStore returns the configuration for a specific secret store

func (*Config) GetService

func (c *Config) GetService(name string) (ServiceConfig, error)

GetService returns the configuration for a specific service

func (*Config) HasPolicies

func (c *Config) HasPolicies() bool

HasPolicies returns true if policies are configured

func (*Config) ListAllProviders

func (c *Config) ListAllProviders() map[string]ProviderConfig

ListAllProviders returns all configured providers (secret stores + services + legacy providers)

func (*Config) Load

func (c *Config) Load() error

Load reads and parses the dsops.yaml file

type Definition

type Definition struct {
	Version       int                          `yaml:"version"`
	SecretStores  map[string]SecretStoreConfig `yaml:"secretStores,omitempty"`
	Services      map[string]ServiceConfig     `yaml:"services,omitempty"`
	Providers     map[string]ProviderConfig    `yaml:"providers,omitempty"` // Legacy compatibility
	Transforms    map[string][]string          `yaml:"transforms"`
	Envs          map[string]Environment       `yaml:"envs"`
	Templates     []Template                   `yaml:"templates"`
	Policies      *policy.PolicyConfig         `yaml:"policies,omitempty"`
	Notifications *NotificationConfig          `yaml:"notifications,omitempty"` // Rotation notifications
	Metrics       *MetricsConfig               `yaml:"metrics,omitempty"`       // Prometheus metrics
}

Definition represents the dsops.yaml structure with separated secret stores and services

type EmailNotificationConfig

type EmailNotificationConfig struct {
	// SMTP server configuration.
	SMTP SMTPConfig `yaml:"smtp"`

	// From is the sender email address.
	From string `yaml:"from"`

	// To is the list of recipient email addresses.
	To []string `yaml:"to"`

	// Events specifies which rotation events trigger notifications.
	Events []string `yaml:"events,omitempty"`

	// BatchMode controls email batching: immediate, hourly, daily.
	BatchMode string `yaml:"batch_mode,omitempty"`
}

EmailNotificationConfig holds SMTP email configuration for rotation events.

type Environment

type Environment map[string]Variable

Environment represents a named environment configuration

type MetricsConfig

type MetricsConfig struct {
	Prometheus *PrometheusConfig `yaml:"prometheus,omitempty"`
}

MetricsConfig holds Prometheus metrics configuration

type NotificationConfig

type NotificationConfig struct {
	// Slack configuration for Slack webhook notifications.
	Slack *SlackNotificationConfig `yaml:"slack,omitempty"`

	// Email configuration for SMTP email notifications.
	Email *EmailNotificationConfig `yaml:"email,omitempty"`

	// PagerDuty configuration for PagerDuty incident notifications.
	PagerDuty *PagerDutyNotificationConfig `yaml:"pagerduty,omitempty"`

	// Webhooks configuration for custom webhook notifications.
	Webhooks []WebhookNotificationConfig `yaml:"webhooks,omitempty"`
}

NotificationConfig holds configuration for rotation notifications.

type PagerDutyNotificationConfig

type PagerDutyNotificationConfig struct {
	// IntegrationKey is the PagerDuty Events API integration key.
	// Can be a secret reference like "store://vault/pagerduty/integration-key".
	IntegrationKey string `yaml:"integration_key"`

	// ServiceID is the PagerDuty service ID (optional).
	ServiceID string `yaml:"service_id,omitempty"`

	// Severity is the default incident severity: critical, error, warning, info.
	Severity string `yaml:"severity,omitempty"`

	// Events specifies which rotation events trigger notifications.
	Events []string `yaml:"events,omitempty"`

	// AutoResolve indicates whether to auto-resolve incidents on success.
	AutoResolve bool `yaml:"auto_resolve,omitempty"`
}

PagerDutyNotificationConfig holds PagerDuty configuration for rotation events.

type PrometheusConfig

type PrometheusConfig struct {
	Enabled bool              `yaml:"enabled"`
	Port    int               `yaml:"port,omitempty"`
	Path    string            `yaml:"path,omitempty"`
	Labels  map[string]string `yaml:"labels,omitempty"`
}

PrometheusConfig holds Prometheus-specific configuration

func DefaultPrometheusConfig

func DefaultPrometheusConfig() *PrometheusConfig

DefaultPrometheusConfig returns the default Prometheus configuration

type ProviderConfig

type ProviderConfig struct {
	Type      string                 `yaml:"type"`
	TimeoutMs int                    `yaml:"timeout_ms,omitempty"` // Timeout in milliseconds (default: 30000)
	Config    map[string]interface{} `yaml:",inline"`
}

ProviderConfig holds provider-specific configuration (legacy compatibility)

func (ProviderConfig) GetProviderTimeout

func (p ProviderConfig) GetProviderTimeout() int

GetProviderTimeout returns the timeout for a provider in milliseconds

type ProviderRef

type ProviderRef struct {
	Provider string `yaml:"provider"`
	Key      string `yaml:"key"`
	Version  string `yaml:"version,omitempty"`
}

ProviderRef references a provider and key (legacy compatibility)

type Reference

type Reference struct {
	// New URI format (primary)
	Store   string `yaml:"store,omitempty"`   // store:// reference
	Service string `yaml:"service,omitempty"` // svc:// reference

	// Legacy format (provider + key) - for backward compatibility
	Provider string `yaml:"provider,omitempty"`
	Key      string `yaml:"key,omitempty"`
	Version  string `yaml:"version,omitempty"`
}

Reference represents either a legacy provider reference or a new URI reference

func (*Reference) GetEffectiveProvider

func (r *Reference) GetEffectiveProvider() string

GetEffectiveProvider returns the effective provider name for this reference

func (*Reference) IsLegacyFormat

func (r *Reference) IsLegacyFormat() bool

IsLegacyFormat returns true if this reference uses the old provider+key format

func (*Reference) IsServiceReference

func (r *Reference) IsServiceReference() bool

IsServiceReference returns true if this references a service

func (*Reference) IsStoreReference

func (r *Reference) IsStoreReference() bool

IsStoreReference returns true if this references a secret store

func (*Reference) ToLegacyProviderRef

func (r *Reference) ToLegacyProviderRef() ProviderRef

ToLegacyProviderRef converts a Reference to legacy ProviderRef format

func (*Reference) ToSecretRef

func (r *Reference) ToSecretRef() (secretstore.SecretRef, error)

ToSecretRef converts a Reference to a SecretRef (if it's a store reference)

func (*Reference) ToServiceRef

func (r *Reference) ToServiceRef() (service.ServiceRef, error)

ToServiceRef converts a Reference to a ServiceRef (if it's a service reference)

type RollbackConfig

type RollbackConfig struct {
	// Automatic enables automatic rollback on verification failure.
	Automatic bool `yaml:"automatic,omitempty"`

	// OnVerificationFailure triggers rollback when verification fails.
	OnVerificationFailure bool `yaml:"on_verification_failure,omitempty"`

	// OnHealthCheckFailure triggers rollback when health checks fail.
	OnHealthCheckFailure bool `yaml:"on_health_check_failure,omitempty"`

	// TimeoutSeconds is the maximum time for rollback operation (default: 30).
	TimeoutSeconds int `yaml:"timeout,omitempty"`

	// MaxRetries is the number of times to retry rollback if it fails (default: 2).
	MaxRetries int `yaml:"max_retries,omitempty"`

	// Notifications lists notification channels for rollback events.
	Notifications []string `yaml:"notifications,omitempty"`
}

RollbackConfig holds configuration for automatic rollback behavior.

type SMTPConfig

type SMTPConfig struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Username string `yaml:"username,omitempty"`
	Password string `yaml:"password,omitempty"`
	TLS      bool   `yaml:"tls,omitempty"`
}

SMTPConfig holds SMTP server configuration.

type SecretStoreConfig

type SecretStoreConfig struct {
	Type      string                 `yaml:"type"`
	TimeoutMs int                    `yaml:"timeout_ms,omitempty"`
	Config    map[string]interface{} `yaml:",inline"`
}

SecretStoreConfig holds secret store-specific configuration

type ServiceConfig

type ServiceConfig struct {
	Type      string                 `yaml:"type"`
	TimeoutMs int                    `yaml:"timeout_ms,omitempty"`
	Config    map[string]interface{} `yaml:",inline"`
}

ServiceConfig holds service-specific configuration for rotation targets

type SlackMentions

type SlackMentions struct {
	// OnFailure lists Slack handles to mention when rotation fails.
	// Examples: ["@oncall", "@platform-team"]
	OnFailure []string `yaml:"on_failure,omitempty"`

	// OnRollback lists Slack handles to mention when rollback occurs.
	OnRollback []string `yaml:"on_rollback,omitempty"`
}

SlackMentions defines who to mention for specific event types.

type SlackNotificationConfig

type SlackNotificationConfig struct {
	// WebhookURL is the Slack incoming webhook URL.
	// Can be a secret reference like "store://vault/slack/webhook".
	WebhookURL string `yaml:"webhook_url"`

	// Channel is the Slack channel to post to (optional, uses webhook default).
	Channel string `yaml:"channel,omitempty"`

	// Events specifies which rotation events trigger notifications.
	// Valid values: started, completed, failed, rollback.
	// If empty, all events are sent.
	Events []string `yaml:"events,omitempty"`

	// Mentions specifies who to mention for specific events.
	Mentions *SlackMentions `yaml:"mentions,omitempty"`
}

SlackNotificationConfig holds Slack webhook configuration for rotation events.

type Template

type Template struct {
	Name         string `yaml:"name"`
	Format       string `yaml:"format"`
	Env          string `yaml:"env"`
	Out          string `yaml:"out"`
	TemplatePath string `yaml:"template_path,omitempty"`
}

Template represents an output template configuration

type Variable

type Variable struct {
	From      *Reference        `yaml:"from"`
	Literal   string            `yaml:"literal"`
	Transform string            `yaml:"transform"`
	Optional  bool              `yaml:"optional"`
	Metadata  map[string]string `yaml:"metadata,omitempty"`
}

Variable represents a single environment variable configuration with new reference types

type WebhookNotificationConfig

type WebhookNotificationConfig struct {
	// Name is a human-readable name for this webhook.
	Name string `yaml:"name"`

	// URL is the webhook endpoint URL.
	URL string `yaml:"url"`

	// Method is the HTTP method to use (default: POST).
	Method string `yaml:"method,omitempty"`

	// Headers are additional HTTP headers to include.
	Headers map[string]string `yaml:"headers,omitempty"`

	// Events specifies which rotation events trigger notifications.
	Events []string `yaml:"events,omitempty"`

	// PayloadTemplate is a Go template for the request body.
	// If empty, a default JSON payload is used.
	PayloadTemplate string `yaml:"payload_template,omitempty"`

	// Retry configuration.
	Retry *WebhookRetryConfig `yaml:"retry,omitempty"`

	// Timeout in seconds (default: 10).
	TimeoutSeconds int `yaml:"timeout,omitempty"`
}

WebhookNotificationConfig holds configuration for custom webhook notifications.

type WebhookRetryConfig

type WebhookRetryConfig struct {
	// MaxAttempts is the maximum number of retry attempts (default: 3).
	MaxAttempts int `yaml:"max_attempts,omitempty"`

	// Backoff strategy: linear, exponential (default: exponential).
	Backoff string `yaml:"backoff,omitempty"`
}

WebhookRetryConfig holds retry configuration for webhooks.

Jump to

Keyboard shortcuts

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