Skip to content

Commit 6e502a2

Browse files
Merge pull request #390 from njhale/fix-validate
Bug 1857502: fix(validate): pull bundle images before unpacking
2 parents 798b442 + b0f00f1 commit 6e502a2

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pkg/image/containerdregistry/options.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/containerd/containerd/metadata"
1111
"github.com/containerd/containerd/platforms"
1212
"github.com/containerd/containerd/remotes"
13+
specs "github.com/opencontainers/image-spec/specs-go/v1"
1314
"github.com/sirupsen/logrus"
1415
bolt "go.etcd.io/bbolt"
1516
)
@@ -99,7 +100,10 @@ func NewRegistry(options ...RegistryOption) (registry *Registry, err error) {
99100
destroy: destroy,
100101
log: config.Log,
101102
resolver: resolver,
102-
platform: platforms.Only(platforms.DefaultSpec()),
103+
platform: platforms.Ordered(platforms.DefaultSpec(), specs.Platform{
104+
OS: "linux",
105+
Architecture: "amd64",
106+
}),
103107
}
104108
return
105109
}

pkg/lib/bundle/validate.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,15 @@ type imageValidator struct {
4848
func (i imageValidator) PullBundleImage(imageTag, directory string) error {
4949
i.logger.Debug("Pulling and unpacking container image")
5050

51-
return i.registry.Unpack(context.Background(), image.SimpleReference(imageTag), directory)
51+
var (
52+
ctx = context.TODO()
53+
ref = image.SimpleReference(imageTag)
54+
)
55+
if err := i.registry.Pull(ctx, ref); err != nil {
56+
return err
57+
}
58+
59+
return i.registry.Unpack(ctx, ref, directory)
5260
}
5361

5462
// ValidateBundle takes a directory containing the contents of a bundle and validates

0 commit comments

Comments
 (0)