Validate configuration source keys and overrides

This commit is contained in:
2026-08-13 00:15:26 +00:00
parent 5139c1a586
commit 26a681e0b1
7 changed files with 173 additions and 17 deletions

View File

@@ -23,7 +23,7 @@ import (
const (
convectiveOutlooksEndpoint = "/outlooks/convective"
sourceSPCConvectiveOutlooks = "spc_convective_outlooks"
sourceSPCConvectiveOutlooks = config.MissingSourceSPCConvectiveOutlooks
defaultWarmupEndpoint = "/conditions/current"
defaultWarmupAttempts = 3
@@ -168,7 +168,7 @@ type fetchedSource struct {
func (b *bundleBuilder) fetchObservation(ctx context.Context) error {
var observation weatherdata.Observation
fetched, ok, err := b.fetchDecodedSource(ctx, sourceRequest{
name: "observations",
name: config.MissingSourceObservations,
endpoint: "/observations",
query: queryOptions{precision: true},
missingMessage: "observation data is missing",
@@ -186,7 +186,7 @@ func (b *bundleBuilder) fetchObservation(ctx context.Context) error {
func (b *bundleBuilder) fetchCurrent(ctx context.Context) error {
var current weatherdata.Current
fetched, ok, err := b.fetchDecodedSource(ctx, sourceRequest{
name: "current",
name: config.MissingSourceCurrent,
endpoint: "/conditions/current",
query: queryOptions{precision: true},
missingMessage: "current conditions data is missing",
@@ -227,7 +227,7 @@ func (b *bundleBuilder) fetchHourly(ctx context.Context) error {
func (b *bundleBuilder) fetchNarrative(ctx context.Context) error {
var narrative weatherdata.ForecastRun
fetched, ok, err := b.fetchDecodedSource(ctx, sourceRequest{
name: "narrative",
name: config.MissingSourceNarrative,
endpoint: "/forecast/narrative",
query: queryOptions{precision: true, timezone: true},
missingMessage: "narrative forecast data is missing",
@@ -244,7 +244,7 @@ func (b *bundleBuilder) fetchNarrative(ctx context.Context) error {
}
func (b *bundleBuilder) fetchAlerts(ctx context.Context) error {
raw, source, err := b.client.fetch(ctx, "alerts", "/alerts/active", queryOptions{allowNull: true})
raw, source, err := b.client.fetch(ctx, config.MissingSourceAlerts, "/alerts/active", queryOptions{allowNull: true})
if err != nil {
return err
}
@@ -258,7 +258,7 @@ func (b *bundleBuilder) fetchAlerts(ctx context.Context) error {
}
var alerts weatherdata.AlertRun
if err := decodeSource(raw, &alerts); err != nil {
return b.handleMalformed(&source, err, sourceRequest{name: "alerts"})
return b.handleMalformed(&source, err, sourceRequest{name: config.MissingSourceAlerts})
}
alerts.Raw = append(json.RawMessage(nil), raw...)
if alerts.AsOf != nil {
@@ -272,7 +272,7 @@ func (b *bundleBuilder) fetchAlerts(ctx context.Context) error {
func (b *bundleBuilder) fetchDiscussion(ctx context.Context) error {
var discussion weatherdata.Discussion
fetched, ok, err := b.fetchDecodedSource(ctx, sourceRequest{
name: "discussion",
name: config.MissingSourceDiscussion,
endpoint: "/discussion",
query: queryOptions{timezone: true},
missingMessage: "forecast discussion data is missing",
@@ -291,7 +291,7 @@ func (b *bundleBuilder) fetchDiscussion(ctx context.Context) error {
func (b *bundleBuilder) fetchWeatherStory(ctx context.Context) error {
var story weatherdata.WeatherStory
fetched, ok, err := b.fetchDecodedSource(ctx, sourceRequest{
name: "weather_story",
name: config.MissingSourceWeatherStory,
endpoint: "/weatherstories/latest",
query: queryOptions{omitUnits: true},
missingMessage: "NWS weather story data is missing",