From 6e1a8ac0e6074429e86270c75c902cea68fd64d2 Mon Sep 17 00:00:00 2001 From: Bennett Wetters Date: Sun, 14 Jan 2024 01:02:30 +0100 Subject: [PATCH] Initialize sensors map with static parts when parsing config --- config/config.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/config/config.go b/config/config.go index 8092560..20c0419 100644 --- a/config/config.go +++ b/config/config.go @@ -7,6 +7,8 @@ import ( "os" "path/filepath" "slices" + + "gitlab.hamburg.ccc.de/ccchh/spaceapid/types" ) const ( @@ -50,5 +52,14 @@ func ParseConfiguration() (conf SpaceapidConfig) { log.Fatalln("Provided file doesn't specify compatibility with API version 14") } + // Initialise fields for environment sensors + conf.Response.Sensors = make(map[string][]types.EnvironmentSensor) + for key, sensorConfigs := range conf.Dynamic.Sensors { + conf.Response.Sensors[key] = make([]types.EnvironmentSensor, len(sensorConfigs)) + for i, sensorConfig := range sensorConfigs { + conf.Response.Sensors[key][i] = sensorConfig.SensorData + } + } + return }