Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions dktest.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ const (
label = "dktest"
)

func pullImage(ctx context.Context, lgr Logger, dc client.ImageAPIClient, imgName, platform string) error {
func pullImage(ctx context.Context, lgr Logger, dc client.ImageAPIClient, registryAuth, imgName, platform string) error {
lgr.Log("Pulling image:", imgName)
// lgr.Log(dc.ImageList(ctx, types.ImageListOptions{All: true}))

resp, err := dc.ImagePull(ctx, imgName, image.PullOptions{Platform: platform})
resp, err := dc.ImagePull(ctx, imgName, image.PullOptions{
Platform: platform,
RegistryAuth: registryAuth,
})
if err != nil {
return err
}
Expand Down Expand Up @@ -202,7 +205,7 @@ func RunContext(ctx context.Context, logger Logger, imgName string, opts Options
pullCtx, pullTimeoutCancelFunc := context.WithTimeout(ctx, opts.PullTimeout)
defer pullTimeoutCancelFunc()

if err := pullImage(pullCtx, logger, dc, imgName, opts.Platform); err != nil {
if err := pullImage(pullCtx, logger, dc, opts.PullRegistryAuth, imgName, opts.Platform); err != nil {
return fmt.Errorf("error pulling image: %v error: %w", imgName, err)
}

Expand Down
2 changes: 1 addition & 1 deletion dktest_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestPullImage(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
client := tc.client
err := pullImage(ctx, t, &client, imageName, tc.platform)
err := pullImage(ctx, t, &client, "", imageName, tc.platform)
testErr(t, err, tc.expectErr)
})
}
Expand Down
2 changes: 2 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
type Options struct {
// PullTimeout is the timeout used when pulling images
PullTimeout time.Duration
// PullRegistryAuth is the base64 encoded credentials for the registry
PullRegistryAuth string
// Timeout is the timeout used when starting a container and checking if it's ready
Timeout time.Duration
// ReadyTimeout is the timeout used for each container ready check.
Expand Down