[#583] Fix error when policy file cannot be read
Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
a57b8d34d3
commit
5d52f056eb
1 changed files with 9 additions and 2 deletions
|
@ -440,9 +440,16 @@ func parsePolicies(val string) (authmate.ContainerPolicies, error) {
|
|||
if val == "" {
|
||||
return nil, nil
|
||||
}
|
||||
data, err := os.ReadFile(val)
|
||||
if err != nil {
|
||||
|
||||
var (
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue