Skip to content

Commit

Permalink
Don't set non-default copy.Options in imageService.PullImage if it is…
Browse files Browse the repository at this point in the history
… nil

None of the two callers (Server.PullImage,
runtimeService.CreateContainerOrPodSandbox) set it to nil anyway.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed Jun 25, 2019
1 parent db4fdc1 commit 5248da4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/container_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func New(ctx context.Context, systemContext *types.SystemContext, configIface li
return nil, fmt.Errorf("cannot create container server: interface is nil")
}

imageService, err := storage.GetImageService(ctx, systemContext, store, config.DefaultTransport, config.GlobalAuthFile, config.InsecureRegistries, config.Registries)
imageService, err := storage.GetImageService(ctx, systemContext, store, config.DefaultTransport, config.InsecureRegistries, config.Registries)
if err != nil {
return nil, err
}
Expand Down
10 changes: 2 additions & 8 deletions pkg/storage/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ type imageCache map[string]imageCacheItem
type imageService struct {
store storage.Store
defaultTransport string
globalAuthFile string
insecureRegistryCIDRs []*net.IPNet
indexConfigs map[string]*indexInfo
unqualifiedSearchRegistries []string
Expand Down Expand Up @@ -409,11 +408,7 @@ func (svc *imageService) PullImage(systemContext *types.SystemContext, imageName
return nil, err
}
if options == nil {
options = &copy.Options{
SourceCtx: &types.SystemContext{
AuthFilePath: svc.globalAuthFile,
},
}
options = &copy.Options{}
}

srcRef, err := svc.prepareReference(imageName, options)
Expand Down Expand Up @@ -608,7 +603,7 @@ func (svc *imageService) ResolveNames(systemContext *types.SystemContext, imageN
// which will prepend the passed-in defaultTransport value to an image name if
// a name that's passed to its PullImage() method can't be resolved to an image
// in the store and can't be resolved to a source on its own.
func GetImageService(ctx context.Context, sc *types.SystemContext, store storage.Store, defaultTransport, globalAuthFile string, insecureRegistries, registries []string) (ImageServer, error) {
func GetImageService(ctx context.Context, sc *types.SystemContext, store storage.Store, defaultTransport string, insecureRegistries, registries []string) (ImageServer, error) {
if store == nil {
var err error
storeOpts, err := storage.DefaultStoreOptions(rootless.IsRootless(), rootless.GetRootlessUID())
Expand All @@ -624,7 +619,6 @@ func GetImageService(ctx context.Context, sc *types.SystemContext, store storage
is := &imageService{
store: store,
defaultTransport: defaultTransport,
globalAuthFile: globalAuthFile,
indexConfigs: make(map[string]*indexInfo),
insecureRegistryCIDRs: make([]*net.IPNet, 0),
imageCache: make(map[string]imageCacheItem),
Expand Down
10 changes: 5 additions & 5 deletions pkg/storage/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var _ = t.Describe("Image", func() {
var err error
sut, err = storage.GetImageService(
context.Background(), nil, storeMock, "",
"", []string{}, []string{testRegistry},
[]string{}, []string{testRegistry},
)
Expect(err).To(BeNil())
Expect(sut).NotTo(BeNil())
Expand Down Expand Up @@ -78,7 +78,7 @@ var _ = t.Describe("Image", func() {
// When
imageService, err := storage.GetImageService(
context.Background(), nil, storeMock, "",
"", []string{"reg1", "reg1", "reg2"},
[]string{"reg1", "reg1", "reg2"},
[]string{"reg3", "reg3", "reg4"},
)

Expand All @@ -94,7 +94,7 @@ var _ = t.Describe("Image", func() {
context.Background(),
&types.SystemContext{
SystemRegistriesConfPath: "../../test/registries.conf"},
storeMock, "", "", []string{}, []string{},
storeMock, "", []string{}, []string{},
)

// Then
Expand All @@ -121,7 +121,7 @@ var _ = t.Describe("Image", func() {
imageService, err := storage.GetImageService(
context.Background(),
&types.SystemContext{SystemRegistriesConfPath: "/invalid"},
storeMock, "", "", []string{}, []string{},
storeMock, "", []string{}, []string{},
)

// Then
Expand Down Expand Up @@ -241,7 +241,7 @@ var _ = t.Describe("Image", func() {

sut, err := storage.GetImageService(context.Background(),
&types.SystemContext{SystemRegistriesConfPath: file.Name()},
storeMock, "", "", []string{}, []string{})
storeMock, "", []string{}, []string{})
Expect(err).To(BeNil())
Expect(sut).NotTo(BeNil())

Expand Down

0 comments on commit 5248da4

Please sign in to comment.