From ff255e81f7fb45dc640c24dc7c465a018c1dadc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N/P=E7=A1=85?= Date: Mon, 16 Aug 2021 11:08:12 +0800 Subject: [PATCH] Update utils.go --- utils.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/utils.go b/utils.go index 1ca21fa..d86bc48 100644 --- a/utils.go +++ b/utils.go @@ -82,18 +82,19 @@ func newStorager(pairs ...types.Pair) (store *Storage, err error) { store.workDir = opt.WorkDir } - cp, err := credential.Parse(opt.Credential) - if err != nil { - return nil, err - } - switch cp.Protocol() { - case credential.ProtocolBasic: - user, pass := cp.Basic() - store.password = pass - store.user = user - default: - return nil, services.PairUnsupportedError{Pair: ps.WithCredential(opt.Credential)} - + if opt.HasCredential { + cp, err := credential.Parse(opt.Credential) + if err != nil { + return nil, err + } + switch cp.Protocol() { + case credential.ProtocolBasic: + user, pass := cp.Basic() + store.password = pass + store.user = user + default: + return nil, services.PairUnsupportedError{Pair: ps.WithCredential(opt.Credential)} + } } err = store.connect()