Signed-off-by: Stefan Scherer <scherer_stefan@icloud.com>
| ... | ... |
@@ -756,7 +756,7 @@ func (p *v2Puller) pullManifestList(ctx context.Context, ref reference.Named, mf |
| 756 | 756 |
manifestMatches := filterManifests(mfstList.Manifests, platform) |
| 757 | 757 |
|
| 758 | 758 |
if len(manifestMatches) == 0 {
|
| 759 |
- errMsg := fmt.Sprintf("no matching manifest for %s in the manifest list entries", platforms.Format(platform))
|
|
| 759 |
+ errMsg := fmt.Sprintf("no matching manifest for %s in the manifest list entries", formatPlatform(platform))
|
|
| 760 | 760 |
logrus.Debugf(errMsg) |
| 761 | 761 |
return "", "", errors.New(errMsg) |
| 762 | 762 |
} |
| ... | ... |
@@ -2,8 +2,10 @@ package distribution // import "github.com/docker/docker/distribution" |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"encoding/json" |
| 5 |
+ "fmt" |
|
| 5 | 6 |
"io/ioutil" |
| 6 | 7 |
"reflect" |
| 8 |
+ "regexp" |
|
| 7 | 9 |
"runtime" |
| 8 | 10 |
"strings" |
| 9 | 11 |
"testing" |
| ... | ... |
@@ -11,6 +13,7 @@ import ( |
| 11 | 11 |
"github.com/docker/distribution/manifest/schema1" |
| 12 | 12 |
"github.com/docker/distribution/reference" |
| 13 | 13 |
"github.com/opencontainers/go-digest" |
| 14 |
+ specs "github.com/opencontainers/image-spec/specs-go/v1" |
|
| 14 | 15 |
"gotest.tools/assert" |
| 15 | 16 |
is "gotest.tools/assert/cmp" |
| 16 | 17 |
) |
| ... | ... |
@@ -182,3 +185,23 @@ func TestValidateManifest(t *testing.T) {
|
| 182 | 182 |
t.Fatal("expected validateManifest to fail with digest error")
|
| 183 | 183 |
} |
| 184 | 184 |
} |
| 185 |
+ |
|
| 186 |
+func TestFormatPlatform(t *testing.T) {
|
|
| 187 |
+ var platform specs.Platform |
|
| 188 |
+ var result = formatPlatform(platform) |
|
| 189 |
+ if strings.HasPrefix(result, "unknown") {
|
|
| 190 |
+ t.Fatal("expected formatPlatform to show a known platform")
|
|
| 191 |
+ } |
|
| 192 |
+ if !strings.HasPrefix(result, runtime.GOOS) {
|
|
| 193 |
+ t.Fatal("expected formatPlatform to show the current platform")
|
|
| 194 |
+ } |
|
| 195 |
+ if runtime.GOOS == "windows" {
|
|
| 196 |
+ if !strings.HasPrefix(result, "windows") {
|
|
| 197 |
+ t.Fatal("expected formatPlatform to show windows platform")
|
|
| 198 |
+ } |
|
| 199 |
+ matches, _ := regexp.MatchString("windows.* [0-9]", result)
|
|
| 200 |
+ if !matches {
|
|
| 201 |
+ t.Fatal(fmt.Sprintf("expected formatPlatform to show windows platform with a version, but got '%s'", result))
|
|
| 202 |
+ } |
|
| 203 |
+ } |
|
| 204 |
+} |
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"strconv" |
| 12 | 12 |
"strings" |
| 13 | 13 |
|
| 14 |
+ "github.com/containerd/containerd/platforms" |
|
| 14 | 15 |
"github.com/docker/distribution" |
| 15 | 16 |
"github.com/docker/distribution/manifest/manifestlist" |
| 16 | 17 |
"github.com/docker/distribution/manifest/schema2" |
| ... | ... |
@@ -136,3 +137,10 @@ func checkImageCompatibility(imageOS, imageOSVersion string) error {
|
| 136 | 136 |
} |
| 137 | 137 |
return nil |
| 138 | 138 |
} |
| 139 |
+ |
|
| 140 |
+func formatPlatform(platform specs.Platform) string {
|
|
| 141 |
+ if platform.OS == "" {
|
|
| 142 |
+ platform = platforms.DefaultSpec() |
|
| 143 |
+ } |
|
| 144 |
+ return fmt.Sprintf("%s %s", platforms.Format(platform), system.GetOSVersion().ToString())
|
|
| 145 |
+} |