From 84e493beba725ffc828fe53070c0702fe3907e74 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 19 Dec 2017 21:12:38 +0100 Subject: [PATCH] b2: Warn when account ID or key is empty Closes #1490 --- cmd/restic/global.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/restic/global.go b/cmd/restic/global.go index d472d8a34..4138c222a 100644 --- a/cmd/restic/global.go +++ b/cmd/restic/global.go @@ -500,10 +500,18 @@ func parseConfig(loc location.Location, opts options.Options) (interface{}, erro cfg.AccountID = os.Getenv("B2_ACCOUNT_ID") } + if cfg.AccountID == "" { + return nil, errors.Fatalf("unable to open B2 backend: Account ID ($B2_ACCOUNT_ID) is empty") + } + if cfg.Key == "" { cfg.Key = os.Getenv("B2_ACCOUNT_KEY") } + if cfg.Key == "" { + return nil, errors.Fatalf("unable to open B2 backend: Key ($B2_ACCOUNT_KEY) is empty") + } + if err := opts.Apply(loc.Scheme, &cfg); err != nil { return nil, err }