in internal/core/container.go [223:257]
func pullImage(ctx context.Context, client client.APIClient, ref string) {
reader, err := client.ImagePull(ctx, ref, image.PullOptions{})
if err != nil && isDockerUnauthorizedError(err.Error()) {
cfg, err := cliconfig.Load("")
if err != nil {
log.Fatal(err)
}
registryHostname := strutil.SafeSplit(ref, "/", 0)
a, err := cfg.GetAuthConfig(registryHostname)
if err != nil {
log.Fatal("can't load the auth config", err)
}
encodedAuth, err := encodeAuthToBase64(registry.AuthConfig(a))
if err != nil {
log.Fatal("can't encode auth to base64", err)
}
reader, err = client.ImagePull(ctx, ref, image.PullOptions{RegistryAuth: encodedAuth})
if err != nil {
log.Fatal("can't pull image from the private registry", err)
}
} else if err != nil {
log.Fatal("can't pull image ", err)
}
defer func(pull io.ReadCloser) {
err := pull.Close()
if err != nil {
log.Fatal("can't pull image ", err)
}
}(reader)
if _, err = io.Copy(io.Discard, reader); err != nil {
log.Fatal("couldn't read the image pull logs ", err)
}
}