Validate configuration source keys and overrides
This commit is contained in:
@@ -21,6 +21,33 @@ const (
|
||||
NotifyFailureError NotifyFailurePolicy = "error"
|
||||
)
|
||||
|
||||
const (
|
||||
MissingSourceObservations = "observations"
|
||||
MissingSourceCurrent = "current"
|
||||
MissingSourceNarrative = "narrative"
|
||||
MissingSourceAlerts = "alerts"
|
||||
MissingSourceDiscussion = "discussion"
|
||||
MissingSourceWeatherStory = "weather_story"
|
||||
MissingSourceSPCConvectiveOutlooks = "spc_convective_outlooks"
|
||||
)
|
||||
|
||||
var supportedMissingSources = map[string]struct{}{
|
||||
MissingSourceObservations: {},
|
||||
MissingSourceCurrent: {},
|
||||
MissingSourceNarrative: {},
|
||||
MissingSourceAlerts: {},
|
||||
MissingSourceDiscussion: {},
|
||||
MissingSourceWeatherStory: {},
|
||||
MissingSourceSPCConvectiveOutlooks: {},
|
||||
}
|
||||
|
||||
// IsSupportedMissingSource reports whether source accepts a missing-source
|
||||
// policy override. Required sources, including hourly, are not configurable.
|
||||
func IsSupportedMissingSource(source string) bool {
|
||||
_, ok := supportedMissingSources[source]
|
||||
return ok
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
WeatherAPI WeatherAPIConfig `yaml:"weather_api"`
|
||||
Location LocationConfig `yaml:"location"`
|
||||
@@ -246,7 +273,11 @@ func (c *ReportDistributorConfig) UnmarshalYAML(value *yaml.Node) error {
|
||||
}
|
||||
|
||||
func (c ReportDistributorConfig) PathTemplatesSet() bool {
|
||||
return c.pathTemplatesSet
|
||||
return c.pathTemplatesSet || c.PathTemplates != nil
|
||||
}
|
||||
|
||||
func (c ReportConfig) deterministicModulesConfigured() bool {
|
||||
return c.deterministicModulesSet || c.DeterministicModules != nil
|
||||
}
|
||||
|
||||
func (m *ModuleConfigItem) UnmarshalYAML(value *yaml.Node) error {
|
||||
|
||||
Reference in New Issue
Block a user