Skip to content

Commit 3f5bbe0

Browse files
committed
containers/image registry: PR review follow-ups
Signed-off-by: Joe Lanford <[email protected]>
1 parent 7f73fa3 commit 3f5bbe0

File tree

5 files changed

+9
-12
lines changed

5 files changed

+9
-12
lines changed

cmd/opm/internal/util/util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func CreateCLIRegistry(cmd *cobra.Command) (image.Registry, error) {
5252
}
5353
return containersimageregistry.New(
5454
containersimageregistry.DefaultSystemContext,
55-
containersimageregistry.InsecureSkipTLSVerify(skipTLSVerify || useHTTP),
55+
containersimageregistry.WithInsecureSkipTLSVerify(skipTLSVerify || useHTTP),
5656
)
5757
}
5858

File renamed without changes.

pkg/image/containersimageregistry/registry.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ type Registry struct {
3434
var DefaultSystemContext = &types.SystemContext{OSChoice: "linux"}
3535

3636
func New(sourceCtx *types.SystemContext, opts ...Option) (orimage.Registry, error) {
37+
if sourceCtx == nil {
38+
sourceCtx = &types.SystemContext{}
39+
}
3740
reg := &Registry{
3841
sourceCtx: sourceCtx,
3942
}
@@ -101,7 +104,7 @@ func newCacheConfig(dir string, preserve bool) *cacheConfig {
101104
}
102105
}
103106

104-
func ForceTemporaryImageCache() Option {
107+
func WithTemporaryImageCache() Option {
105108
return func(r *Registry) error {
106109
var err error
107110
r.cache, err = getTemporaryImageCache()
@@ -112,11 +115,8 @@ func ForceTemporaryImageCache() Option {
112115
}
113116
}
114117

115-
func InsecureSkipTLSVerify(insecureSkipTLSVerify bool) Option {
118+
func WithInsecureSkipTLSVerify(insecureSkipTLSVerify bool) Option {
116119
return func(r *Registry) error {
117-
if r.sourceCtx == nil {
118-
r.sourceCtx = &types.SystemContext{}
119-
}
120120
r.sourceCtx.DockerDaemonInsecureSkipTLSVerify = insecureSkipTLSVerify
121121
r.sourceCtx.DockerInsecureSkipTLSVerify = types.NewOptionalBool(insecureSkipTLSVerify)
122122
r.sourceCtx.OCIInsecureSkipTLSVerify = insecureSkipTLSVerify
@@ -154,9 +154,6 @@ func (r *Registry) Pull(ctx context.Context, ref orimage.Reference) error {
154154
sourceCtx := r.sourceCtx
155155
authFile := getAuthFile(r.sourceCtx, namedRef.String())
156156
if authFile != "" {
157-
if sourceCtx == nil {
158-
sourceCtx = &types.SystemContext{}
159-
}
160157
sourceCtx.AuthFilePath = authFile
161158
}
162159

pkg/image/registry_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import (
2525
"github.com/stretchr/testify/require"
2626
"golang.org/x/mod/sumdb/dirhash"
2727

28+
libimage "github.com/operator-framework/operator-registry/internal/testutil/image"
2829
"github.com/operator-framework/operator-registry/pkg/image"
2930
"github.com/operator-framework/operator-registry/pkg/image/containerdregistry"
3031
"github.com/operator-framework/operator-registry/pkg/image/containersimageregistry"
31-
libimage "github.com/operator-framework/operator-registry/pkg/lib/image"
3232
)
3333

3434
// cleanupFunc is a function that cleans up after some test infra.
@@ -66,7 +66,7 @@ func TestRegistries(t *testing.T) {
6666
DockerCertPath: caDir,
6767
DockerPerHostCertDirPath: caDir,
6868
}
69-
r, err := containersimageregistry.New(sourceCtx, containersimageregistry.ForceTemporaryImageCache())
69+
r, err := containersimageregistry.New(sourceCtx, containersimageregistry.WithTemporaryImageCache())
7070
require.NoError(t, err)
7171
cleanup := func() {
7272
require.NoError(t, os.RemoveAll(caDir))

test/e2e/opm_bundle_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
"golang.org/x/mod/sumdb/dirhash"
1717

18-
libimage "github.com/operator-framework/operator-registry/pkg/lib/image"
18+
libimage "github.com/operator-framework/operator-registry/internal/testutil/image"
1919
)
2020

2121
var _ = Describe("opm alpha bundle", func() {

0 commit comments

Comments
 (0)