From 46682b71eb9a423b130b5bde464be527527328df Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Fri, 15 Jan 2016 17:28:26 -0800 Subject: [PATCH] if we can't connect to the server when setting up, return a nil roundtripper. Check roundtripper when initializing HTTPStore and substitute an OfflineStore if it is nil. Signed-off-by: David Lawrence (github: endophage) --- cmd/notary/tuf.go | 4 +++- tuf/store/httpstore.go | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/notary/tuf.go b/cmd/notary/tuf.go index 9bafb8c565..3c68dc0bc5 100644 --- a/cmd/notary/tuf.go +++ b/cmd/notary/tuf.go @@ -426,7 +426,9 @@ func tokenAuth(config *viper.Viper, baseTransport *http.Transport, gun string, } resp, err := pingClient.Do(req) if err != nil { - fatalf(err.Error()) + logrus.Errorf("could not reach %s: %s", trustServerURL, err.Error()) + logrus.Info("continuing in offline mode") + return nil } defer resp.Body.Close() diff --git a/tuf/store/httpstore.go b/tuf/store/httpstore.go index 63f9a57f16..2c4e67b875 100644 --- a/tuf/store/httpstore.go +++ b/tuf/store/httpstore.go @@ -85,6 +85,9 @@ func NewHTTPStore(baseURL, metaPrefix, metaExtension, targetsPrefix, keyExtensio if !base.IsAbs() { return nil, errors.New("HTTPStore requires an absolute baseURL") } + if roundTrip == nil { + return &OfflineStore{}, nil + } return &HTTPStore{ baseURL: *base, metaPrefix: metaPrefix,