Skip to content

Commit

Permalink
Add a test to check that providing the insecure registry settings it
Browse files Browse the repository at this point in the history
pulls the remote image from the insecure registry as well

Signed-off-by: Domenico Luciani <dluciani@vmware.com>
  • Loading branch information
Domenico Luciani committed Jul 26, 2023
1 parent 67bf47b commit e9805cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions remote/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func WithPreviousImage(imageName string) ImageOption {
// the image. The referenced images could include the base image, a previous image, or the image itself.
func WithRegistrySetting(repository string, insecure, insecureSkipVerify bool) ImageOption {
return func(opts *options) error {
opts.registrySettings = make(map[string]registrySetting)
opts.registrySettings[repository] = registrySetting{
insecure: insecure,
insecureSkipVerify: insecureSkipVerify,
Expand Down
9 changes: 9 additions & 0 deletions remote/remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ func testImage(t *testing.T, when spec.G, it spec.S) {
h.AssertNil(t, err)
defer readCloser.Close()
})
it("try to pull the image from an insecure registry if WithRegistrySettings insecure has been set", func() {
_, err := remote.NewImage(
repoName,
authn.DefaultKeychain,
remote.FromBaseImage("host.docker.internal/bar"),
remote.WithRegistrySetting("host.docker.internal", true, true))

h.AssertError(t, err, "http://")
})

it("sets the initial state from a windows/amd64 base image", func() {
baseImageName := "mcr.microsoft.com/windows/nanoserver@sha256:06281772b6a561411d4b338820d94ab1028fdeb076c85350bbc01e80c4bfa2b4"
Expand Down

0 comments on commit e9805cc

Please sign in to comment.