Documentation
¶
Overview ¶
Package cfgmodel provides the data model for the configuration of the flipper service.
Index ¶
- type Config
- type GroupConfig
- type HealthCheckConfig
- func (h HealthCheckConfig) FallOrDefault() uint64
- func (h HealthCheckConfig) IPVersionOrDefault() string
- func (h HealthCheckConfig) IntervalOrDefault() time.Duration
- func (h HealthCheckConfig) MethodOrDefault() string
- func (h HealthCheckConfig) PortOrDefault() uint
- func (h HealthCheckConfig) RiseOrDefault() uint64
- func (h HealthCheckConfig) TimeoutOrDefault() time.Duration
- func (h HealthCheckConfig) Validate() error
- type HeartbeatConfig
- type HetznerProviderConfig
- type HetznerSelector
- type LoggingConfig
- type MockFloatingIPConfig
- type MockProviderConfig
- type MockServerConfig
- type NotificationTargetConfig
- type NotificationsConfig
- type ServerConfig
- type ServiceConfig
- type TelemetryConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Version if a compatibility number for the config. It is always 1 for now.
Version int `koanf:"version"`
Groups []GroupConfig `koanf:"groups"`
Server ServerConfig `koanf:"server"`
Telemetry TelemetryConfig `koanf:"telemetry"`
Heartbeat HeartbeatConfig `koanf:"heartbeat"`
Service ServiceConfig `koanf:"service"`
Notifications NotificationsConfig `koanf:"notifications"`
}
Config is the top-level configuration for flipper.
type GroupConfig ¶
type GroupConfig struct {
// A unique ID for the group. It will be used in metrics and logs.
ID string `koanf:"id"`
DisplayName string `koanf:"display_name"`
// ReadOnly is a flag that indicates that the group should not perform any actions.
// This is useful for testing or for monitoring-only setups.
ReadOnly bool `koanf:"readonly"`
// PollInterval is the interval at which to poll the Hetzner API for changes.
// This defaults to 1 minute.
PollInterval time.Duration `koanf:"poll_interval"`
// PollTimeout is the maximum time to wait for the Hetzner API to respond.
// This defaults to 20 seconds.
PollTimeout time.Duration `koanf:"poll_timeout"`
// PlanApplyTimeout is the maximum time to wait for a plan to be applied.
// This defaults to 30 seconds.
PlanApplyTimeout time.Duration `koanf:"plan_apply_timeout"`
// PostPlanDelay is the time to wait after a plan is applied before allowing another plan.
// This is useful to prevent plans happening too quickly in succession.
// This defaults to 0 (disabled).
PostPlanDelay time.Duration `koanf:"post_plan_delay"`
// PlanApplyWithUnknownStatus is a flag that indicates that the group should apply plans
// even if the status of one or more servers is unknown.
PlanApplyWithUnkownStatus bool `koanf:"plan_apply_with_unknown_status"`
// Provider is the name of the cloud provider that the group is using.
// Supported values: "hetzner", "mock".
Provider string `koanf:"provider"`
// Hetzner is the Hetzner-specific configuration.
// nil when using a different provider.
Hetzner *HetznerProviderConfig `koanf:"hetzner"`
// Mock is the mock provider configuration.
// nil when using a different provider.
Mock *MockProviderConfig `koanf:"mock"`
// Checks is a list of health checks to perform on the servers.
Checks []HealthCheckConfig `koanf:"checks"`
}
GroupConfig is the config for a specific group of floating IPs and servers to watch. The group is independent from other groups and can have its own Hetzner API token, so you could use it to watch resources from different accounts.
func (GroupConfig) PlanApplyTimeoutOrDefault ¶
func (c GroupConfig) PlanApplyTimeoutOrDefault() time.Duration
PlanApplyTimeoutOrDefault returns the plan apply timeout or the default if not set.
func (GroupConfig) PollIntervalOrDefault ¶
func (c GroupConfig) PollIntervalOrDefault() time.Duration
PollIntervalOrDefault returns the poll interval or the default if not set.
func (GroupConfig) PollTimeoutOrDefault ¶
func (c GroupConfig) PollTimeoutOrDefault() time.Duration
PollTimeoutOrDefault returns the poll timeout or the default if not set.
func (GroupConfig) PostPlanDelayOrDefault ¶ added in v0.3.0
func (c GroupConfig) PostPlanDelayOrDefault() time.Duration
PostPlanDelayOrDefault returns the post-plan delay (default is 0, disabled).
func (GroupConfig) Validate ¶
func (c GroupConfig) Validate() error
Validate validates the group config.
type HealthCheckConfig ¶
type HealthCheckConfig struct {
ID string `koanf:"id"`
DisplayName string `koanf:"display_name"`
// Type of check, currently only "http" or "https" is supported.
Type string `koanf:"type"`
// Interval for the check. Must be a `time.Duration` string like "5s" or "1m".
// Defaults to 1 minute.
Interval time.Duration `koanf:"interval"`
// Timeout for waiting for a successful answer. Must be a `time.Duration` string like "5s" or "1m".
// Defaults to 10 seconds.
Timeout time.Duration `koanf:"timeout"`
// Fall is the number of consecutive failures required to mark the check as down.
// This is useful to avoid flapping. Defaults to 1.
Fall uint64 `koanf:"fall"`
// Rise is the number of consecutive successes required to mark the check as up.
// This is useful to avoid flapping. Defaults to 1.
Rise uint64 `koanf:"rise"`
// Method is the HTTP method to use for the check. Defaults to "GET".
Method string `koanf:"method"`
// Host is the value of the host header to set. If empty, IP address is used.
// For HTTPS checks, this is used for SNI: the host must match the certificate.
Host string `koanf:"host"`
// Port is the port to check. Must be between 1 and 65535.
// Defaults to 80 for HTTP and 443 for HTTPS.
Port int `koanf:"port"`
// Path is the URL path to check. Should start with a forward slash "/".
Path string `koanf:"path"`
// IPVersion is the IP version to use for the check. Must be either "ipv4", "ipv6" or "both".
// Defaults to "both".
IPVersion string `koanf:"ip_version"`
}
HealthCheckConfig describes a single health check.
func (HealthCheckConfig) FallOrDefault ¶
func (h HealthCheckConfig) FallOrDefault() uint64
FallOrDefault returns the fall value or the default if not set.
func (HealthCheckConfig) IPVersionOrDefault ¶
func (h HealthCheckConfig) IPVersionOrDefault() string
IPVersionOrDefault returns the IP version or the default ("both") if not set.
func (HealthCheckConfig) IntervalOrDefault ¶
func (h HealthCheckConfig) IntervalOrDefault() time.Duration
IntervalOrDefault returns the interval for the health check or the default if not set.
func (HealthCheckConfig) MethodOrDefault ¶
func (h HealthCheckConfig) MethodOrDefault() string
MethodOrDefault returns the method or the default method if not set.
func (HealthCheckConfig) PortOrDefault ¶
func (h HealthCheckConfig) PortOrDefault() uint
PortOrDefault returns the port or the default port if not set.
func (HealthCheckConfig) RiseOrDefault ¶
func (h HealthCheckConfig) RiseOrDefault() uint64
RiseOrDefault returns the rise value or the default if not set.
func (HealthCheckConfig) TimeoutOrDefault ¶
func (h HealthCheckConfig) TimeoutOrDefault() time.Duration
TimeoutOrDefault returns the timeout or the default if not set.
func (HealthCheckConfig) Validate ¶
func (h HealthCheckConfig) Validate() error
Validate validates the health check config.
type HeartbeatConfig ¶
type HeartbeatConfig struct {
// Enabled is a flag that enables or disables the heartbeat.
Enabled bool `koanf:"enabled"`
// URL is the URL to send the heartbeat to.
URL string `koanf:"url"`
// Interval is the interval at which the heartbeat should be sent.
Interval time.Duration `koanf:"interval"`
// Timeout is the maximum time to wait for the heartbeat to be sent.
Timeout time.Duration `koanf:"timeout"`
}
HeartbeatConfig is the configuration for a heartbeat signal to be sent to a remote service.
func (HeartbeatConfig) Validate ¶
func (c HeartbeatConfig) Validate() error
Validate validates the heartbeat config.
type HetznerProviderConfig ¶
type HetznerProviderConfig struct {
// API token to use to authenticate with Hetzner
APIToken string `koanf:"api_token"`
// ProjectID is the ID of the project to use, you can find this in the URL of the Hetzner Cloud Console.
// For example, if the URL is https://console.hetzner.cloud/projects/123456, the project ID is 123456.
//
// Hetzner does not provide a way to list projects or check the ID, so you will need to know this in advance,
// see https://github.com/hetznercloud/hcloud-go/issues/451.
ProjectID string `koanf:"project_id"`
FloatingIPs HetznerSelector `koanf:"floating_ips"`
Servers HetznerSelector `koanf:"servers"`
}
HetznerProviderConfig is the config for authenticating with Hetzner.
func (HetznerProviderConfig) Validate ¶
func (c HetznerProviderConfig) Validate() error
Validate validates the Hetzner config.
type HetznerSelector ¶
type HetznerSelector struct {
LabelSelector string `koanf:"label_selector"`
}
HetznerSelector is a selector for a group of resources on Hetzner.
func (HetznerSelector) Validate ¶
func (c HetznerSelector) Validate() error
Validate validates the Hetzner selector.
type LoggingConfig ¶
type LoggingConfig struct {
// Level is the log level to use. Valid values are: "debug", "info", "warn", "error".
// Default is "info".
Level string `koanf:"level"`
// Format is the log format to use. Valid values are: "json", "text". Default is "json".
Format string `koanf:"format"`
}
LoggingConfig is the logging configuration.
func (LoggingConfig) Validate ¶
func (c LoggingConfig) Validate() error
Validate validates the logging config.
type MockFloatingIPConfig ¶ added in v0.3.0
type MockFloatingIPConfig struct {
ID int64 `koanf:"id"`
Name string `koanf:"name"`
Location string `koanf:"location"`
NetworkZone string `koanf:"network_zone"`
ResourceIndex int `koanf:"resource_index"`
IP string `koanf:"ip"`
// CurrentTarget is the ID of the server this floating IP is assigned to.
// Use 0 or omit for unassigned.
CurrentTarget int64 `koanf:"current_target"`
}
MockFloatingIPConfig is the config for a mock floating IP.
func (MockFloatingIPConfig) Validate ¶ added in v0.3.0
func (c MockFloatingIPConfig) Validate() error
Validate validates the mock floating IP config.
type MockProviderConfig ¶ added in v0.3.0
type MockProviderConfig struct {
// Servers is a list of mock servers to create.
Servers []MockServerConfig `koanf:"servers"`
// FloatingIPs is a list of mock floating IPs to create.
FloatingIPs []MockFloatingIPConfig `koanf:"floating_ips"`
}
MockProviderConfig is the config for the mock provider used for testing.
func (MockProviderConfig) Validate ¶ added in v0.3.0
func (c MockProviderConfig) Validate() error
Validate validates the mock provider config.
type MockServerConfig ¶ added in v0.3.0
type MockServerConfig struct {
ID int64 `koanf:"id"`
Name string `koanf:"name"`
Location string `koanf:"location"`
NetworkZone string `koanf:"network_zone"`
ResourceIndex int `koanf:"resource_index"`
PublicIPv4 string `koanf:"public_ipv4"`
PublicIPv6 string `koanf:"public_ipv6"`
}
MockServerConfig is the config for a mock server.
func (MockServerConfig) Validate ¶ added in v0.3.0
func (c MockServerConfig) Validate() error
Validate validates the mock server config.
type NotificationTargetConfig ¶
type NotificationTargetConfig struct {
// Type of notification target, currently only "mattermost" is supported (which may be compatible with Slack).
Type string `json:"type"`
// URL of the Mattermost webhook.
URL string `json:"url"`
// Username to use when sending the notification.
Username string `json:"username"`
// Channel to send the notification to.
// Note that in Mattermost this should be the channel slug, not the display name.
Channel string `json:"channel"`
// IconEmoji to use when sending the notification.
// Defaults to ":dolphin:".
IconEmoji string `json:"icon_url"`
}
NotificationTargetConfig is used for configuring a single target of notifications sent by flipper.
func (NotificationTargetConfig) IconEmojiOrDefault ¶
func (c NotificationTargetConfig) IconEmojiOrDefault() string
IconEmojiOrDefault returns the icon emoji or the default value.
func (NotificationTargetConfig) Validate ¶
func (c NotificationTargetConfig) Validate() error
Validate validates the notification config.
type NotificationsConfig ¶
type NotificationsConfig struct {
Enabled bool `json:"enabled"`
Targets []NotificationTargetConfig `json:"targets"`
}
NotificationsConfig is the config for notifications sent by flipper to external services..
func (NotificationsConfig) Validate ¶
func (c NotificationsConfig) Validate() error
Validate validates the notification config.
type ServerConfig ¶
type ServerConfig struct {
Enabled bool `koanf:"enabled"`
// Host to bind to.
Host string `koanf:"host"`
// Port to bind to.
Port int `koanf:"port"`
// Timeout for graceful shutdown.
ShutdownTimeout time.Duration `koanf:"shutdown_timeout"`
// Assets is the path to serve assets from. If empty, the server will use the embedded files.
// Generally you will only need to specify this during development for quick iteration.
Assets string `koanf:"assets"`
// Templates is the path to serve templates from. If empty, the server will use the embedded files.
// Generally you will only need to specify this during development for quick iteration.
Templates string `koanf:"templates"`
}
ServerConfig is the config for the built-in HTTP server.
func (ServerConfig) Validate ¶
func (c ServerConfig) Validate() error
Validate validates the server config.
type ServiceConfig ¶
type ServiceConfig struct {
Name string `koanf:"name"`
}
ServiceConfig describes the service. The name is used in metrics and logs.
type TelemetryConfig ¶
type TelemetryConfig struct {
Logging LoggingConfig `koanf:"logging"`
}
TelemetryConfig is the telemetry configuration.
func (TelemetryConfig) Validate ¶
func (c TelemetryConfig) Validate() error
Validate validates the telemetry config.