diff options
Diffstat (limited to 'server/descriptor')
-rw-r--r-- | server/descriptor/descriptor.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/server/descriptor/descriptor.go b/server/descriptor/descriptor.go index 016d1cc..6e46790 100644 --- a/server/descriptor/descriptor.go +++ b/server/descriptor/descriptor.go @@ -6,6 +6,8 @@ import ( "crypto/tls" "encoding/base64" + "encoding/json" + "io/ioutil" ) const ( @@ -40,3 +42,16 @@ func FindLog(ops []Operator, logId []byte) (*Log, error) { } return nil, fmt.Errorf("no such log: %s", base64.StdEncoding.EncodeToString(logId)) } + +// LoadOperators loads a list of json-encoded log operators from a given path +func LoadOperators(path string) ([]Operator, error) { + blob, err := ioutil.ReadFile(path) + if err != nil { + return nil, fmt.Errorf("failed reading log operators: %v", err) + } + var ops []Operator + if err := json.Unmarshal(blob, &ops); err != nil { + return nil, fmt.Errorf("failed decoding log operators: %v", err) + } + return ops, nil +} |