Fail silently if the identity fails.

This commit is contained in:
Mariano Cano 2019-12-11 16:26:53 -08:00
parent 401fc20e96
commit 28b08ef46b

View file

@ -119,20 +119,21 @@ func (o *clientOptions) applyDefaultIdentity() error {
return nil return nil
} }
// Do not load an identity if something fails
b, err := ioutil.ReadFile(IdentityFile) b, err := ioutil.ReadFile(IdentityFile)
if err != nil { if err != nil {
return nil return nil
} }
var identity Identity var identity Identity
if err := json.Unmarshal(b, &identity); err != nil { if err := json.Unmarshal(b, &identity); err != nil {
return errors.Wrapf(err, "error unmarshaling %s", IdentityFile) return nil
} }
if err := identity.Validate(); err != nil { if err := identity.Validate(); err != nil {
return err return nil
} }
opts, err := identity.Options() opts, err := identity.Options()
if err != nil { if err != nil {
return err return nil
} }
for _, fn := range opts { for _, fn := range opts {
if err := fn(o); err != nil { if err := fn(o); err != nil {