refactoring

This commit is contained in:
Livio Amstutz 2021-02-11 17:38:58 +01:00
parent 138da8a208
commit 0ca2370d48
25 changed files with 698 additions and 511 deletions

View file

@ -1,36 +0,0 @@
package rp
import (
"encoding/json"
"io/ioutil"
)
const (
serviceAccountKey = "serviceaccount"
applicationKey = "application"
)
type keyFile struct {
Type string `json:"type"` // serviceaccount or application
KeyID string `json:"keyId"`
Key string `json:"key"`
Issuer string `json:"issuer"`
//serviceaccount
UserID string `json:"userId"`
//application
ClientID string `json:"clientId"`
}
func ConfigFromKeyFile(path string) (*keyFile, error) {
data, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
var f keyFile
if err := json.Unmarshal(data, &f); err != nil {
return nil, err
}
return &f, nil
}