[#583] Fix error when policy file cannot be read

Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
Angira Kekteeva 2022-07-07 01:28:16 +04:00 committed by Kira
parent a57b8d34d3
commit 5d52f056eb

View file

@ -440,9 +440,16 @@ func parsePolicies(val string) (authmate.ContainerPolicies, error) {
if val == "" { if val == "" {
return nil, nil return nil, nil
} }
data, err := os.ReadFile(val)
if err != nil { var (
data = []byte(val) data = []byte(val)
err error
)
if !json.Valid(data) {
if data, err = os.ReadFile(val); err != nil {
return nil, fmt.Errorf("coudln't read json file or its content is invalid")
}
} }
var policies authmate.ContainerPolicies var policies authmate.ContainerPolicies