Commit 4a9c1dc2 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Fix broken requestors cli flag

parent 020076ab
Pipeline #19545 failed with stages
in 2 minutes and 18 seconds
package cmd package cmd
import ( import (
"encoding/json"
"io/ioutil" "io/ioutil"
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/go-errors/errors" "github.com/go-errors/errors"
"github.com/mitchellh/mapstructure"
"github.com/privacybydesign/irmago/server" "github.com/privacybydesign/irmago/server"
"github.com/privacybydesign/irmago/server/requestorserver" "github.com/privacybydesign/irmago/server/requestorserver"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
...@@ -230,15 +230,10 @@ func configure(cmd *cobra.Command) error { ...@@ -230,15 +230,10 @@ func configure(cmd *cobra.Command) error {
} }
// Handle requestors // Handle requestors
if len(viper.GetStringMap("requestors")) > 0 { // First read config file requestors := viper.GetStringMap("requestors")
if err := viper.UnmarshalKey("requestors", &conf.Requestors); err != nil {
return errors.WrapPrefix(err, "Failed to unmarshal requestors from config file", 0)
}
}
requestors := viper.GetString("requestors") // Read flag or env var
if len(requestors) > 0 { if len(requestors) > 0 {
if err := json.Unmarshal([]byte(requestors), &conf.Requestors); err != nil { if err := mapstructure.Decode(requestors, &conf.Requestors); err != nil {
return errors.WrapPrefix(err, "Failed to unmarshal requestors from json", 0) return errors.WrapPrefix(err, "Failed to unmarshal requestors from config file", 0)
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment