in container/go/cmd/puller/puller.go [110:162]
func main() {
flag.Parse()
log.Println("Running the Image Puller to pull images from a Docker Registry...")
if *imgName == "" {
log.Fatalln("Required option -name was not specified.")
}
if *directory == "" {
log.Fatalln("Required option -directory was not specified.")
}
// If the user provided a client config directory, instruct the keychain resolver
// to use it to look for the docker client config.
if *clientConfigDir != "" {
ospkg.Setenv("DOCKER_CONFIG", *clientConfigDir)
}
// Create a Platform struct with given arguments.
platform := v1.Platform{
Architecture: *arch,
OS: *os,
OSVersion: *osVersion,
OSFeatures: strings.Fields(*osFeatures),
Variant: *variant,
Features: strings.Fields(*features),
}
dur := time.Duration(*timeout) * time.Second
t := &http.Transport{
Dial: func(network, addr string) (net.Conn, error) {
d := net.Dialer{Timeout: dur, KeepAlive: dur}
conn, err := d.Dial(network, addr)
if err != nil {
return nil, err
}
if err := conn.SetDeadline(time.Now().Add(dur)); err != nil {
return nil, errors.Wrap(err, "unable to set deadline for HTTP connections")
}
return conn, nil
},
TLSHandshakeTimeout: dur,
IdleConnTimeout: dur,
ResponseHeaderTimeout: dur,
ExpectContinueTimeout: dur,
Proxy: http.ProxyFromEnvironment,
}
if err := pull(*imgName, *directory, *cachePath, platform, t); err != nil {
log.Fatalf("Image pull was unsuccessful: %v", err)
}
log.Printf("Successfully pulled image %q into %q", *imgName, *directory)
}