Initialize sensors map with static parts when parsing config
This commit is contained in:
parent
daac0b3b9e
commit
6e1a8ac0e6
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue