99 lines
3.2 KiB
Go
99 lines
3.2 KiB
Go
// Package config owns application configuration structures, defaults, loading,
|
|
// precedence, and validation.
|
|
package config
|
|
|
|
import "time"
|
|
|
|
type MissingSourcePolicy string
|
|
type NotifyFailurePolicy string
|
|
|
|
const (
|
|
MissingSourceError MissingSourcePolicy = "error"
|
|
MissingSourceWarn MissingSourcePolicy = "warn"
|
|
MissingSourceNone MissingSourcePolicy = "none"
|
|
|
|
NotifyFailureError NotifyFailurePolicy = "error"
|
|
)
|
|
|
|
type Config struct {
|
|
WeatherAPI WeatherAPIConfig `yaml:"weather_api"`
|
|
Location LocationConfig `yaml:"location"`
|
|
Secrets SecretsConfig `yaml:"secrets"`
|
|
Notify NotifyConfig `yaml:"notify"`
|
|
MissingSource MissingSourceConfig `yaml:"missing_source"`
|
|
Scriptorium ScriptoriumConfig `yaml:"scriptorium"`
|
|
Workspace WorkspaceConfig `yaml:"workspace"`
|
|
Dayparts []DaypartConfig `yaml:"dayparts"`
|
|
RecentChange RecentChangeConfig `yaml:"recent_change"`
|
|
}
|
|
|
|
type WeatherAPIConfig struct {
|
|
BaseURL string `yaml:"base_url"`
|
|
Timeout time.Duration `yaml:"timeout"`
|
|
Precision int `yaml:"precision"`
|
|
Units string `yaml:"units"`
|
|
Timezone string `yaml:"timezone"`
|
|
Format string `yaml:"format"`
|
|
}
|
|
|
|
type LocationConfig struct {
|
|
ID string `yaml:"id"`
|
|
Name string `yaml:"name"`
|
|
Region string `yaml:"region"`
|
|
}
|
|
|
|
type SecretsConfig struct {
|
|
Directory string `yaml:"directory"`
|
|
}
|
|
|
|
type NotifyConfig struct {
|
|
Distributor DistributorNotifyConfig `yaml:"distributor"`
|
|
}
|
|
|
|
type DistributorNotifyConfig struct {
|
|
Enabled bool `yaml:"enabled"`
|
|
Endpoint string `yaml:"endpoint"`
|
|
TokenEnv string `yaml:"token_env"`
|
|
Timeout time.Duration `yaml:"timeout"`
|
|
FailurePolicy NotifyFailurePolicy `yaml:"failure_policy"`
|
|
PipelineIDTemplate string `yaml:"pipeline_id_template"`
|
|
BundleIDTemplate string `yaml:"bundle_id_template"`
|
|
IdempotencyKeyTemplate string `yaml:"idempotency_key_template"`
|
|
ReportPathTemplates []string `yaml:"report_path_templates"`
|
|
}
|
|
|
|
type MissingSourceConfig struct {
|
|
Default MissingSourcePolicy `yaml:"default"`
|
|
Sources map[string]MissingSourcePolicy `yaml:"sources"`
|
|
}
|
|
|
|
type ScriptoriumConfig struct {
|
|
Binary string `yaml:"binary"`
|
|
ConfigPath string `yaml:"config_path"`
|
|
Profile string `yaml:"profile"`
|
|
Timeout time.Duration `yaml:"timeout"`
|
|
ExtraArgs []string `yaml:"extra_args"`
|
|
}
|
|
|
|
type WorkspaceConfig struct {
|
|
Root string `yaml:"root"`
|
|
SnapshotsDir string `yaml:"snapshots_dir"`
|
|
ReportsDir string `yaml:"reports_dir"`
|
|
DataPackagesDir string `yaml:"data_packages_dir"`
|
|
PreflightDir string `yaml:"preflight_dir"`
|
|
NotificationsDir string `yaml:"notifications_dir"`
|
|
}
|
|
|
|
type DaypartConfig struct {
|
|
Name string `yaml:"name"`
|
|
Start string `yaml:"start"`
|
|
End string `yaml:"end"`
|
|
}
|
|
|
|
type RecentChangeConfig struct {
|
|
TemperatureDegrees float64 `yaml:"temperature_degrees"`
|
|
PrecipProbabilityPoints int `yaml:"precip_probability_points"`
|
|
WindGustMilesPerHour int `yaml:"wind_gust_miles_per_hour"`
|
|
PrecipTimingShiftMinutes int `yaml:"precip_timing_shift_minutes"`
|
|
}
|