From 4360db9f6d3069cf3430d4b8b6b0e6d6343ca8ee Mon Sep 17 00:00:00 2001 From: Phil Estes Date: Thu, 6 Apr 2017 11:21:12 -0400 Subject: [PATCH] Allow inspect to work even if tag list blocked Some registries may choose to block the "list all tags" endpoint for performance or other reasons. In this case we should still allow an inspect which will not include the "tag list" in the output. Signed-off-by: Phil Estes --- cmd/skopeo/inspect.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/skopeo/inspect.go b/cmd/skopeo/inspect.go index 4f4f9c3f..46a505ef 100644 --- a/cmd/skopeo/inspect.go +++ b/cmd/skopeo/inspect.go @@ -3,8 +3,10 @@ package main import ( "encoding/json" "fmt" + "strings" "time" + "github.com/Sirupsen/logrus" "github.com/containers/image/docker" "github.com/containers/image/manifest" "github.com/opencontainers/go-digest" @@ -97,7 +99,13 @@ var inspectCmd = cli.Command{ outputData.Name = dockerImg.SourceRefFullName() outputData.RepoTags, err = dockerImg.GetRepositoryTags() if err != nil { - return fmt.Errorf("Error determining repository tags: %v", err) + // some registries may decide to block the "list all tags" endpoint + // gracefully allow the inspect to continue in this case. Currently + // the IBM Bluemix container registry has this restriction. + if !strings.Contains(err.Error(), "401") { + return fmt.Errorf("Error determining repository tags: %v", err) + } + logrus.Warnf("Registry disallows tag list retrieval; skipping") } } out, err := json.MarshalIndent(outputData, "", " ")