in windows-builder/builder/builder/remote.go [62:110]
func (r *Remote) Copy(inputPath string, copyTimeoutMin int) error {
defer func() {
// Flush stdout
fmt.Println()
}()
if copyTimeoutMin <= 0 {
return errors.New("copy timeout must be greater than 0")
}
hostport := fmt.Sprintf("%s:5986", *r.Hostname)
c, err := winrmcp.New(hostport, &winrmcp.Config{
Auth: winrmcp.Auth{User: *r.Username, Password: *r.Password},
Https: true,
Insecure: true,
TLSServerName: "",
CACertBytes: nil,
OperationTimeout: time.Duration(copyTimeoutMin) * time.Minute,
MaxOperationsPerShell: 15,
})
if err != nil {
log.Printf("Error creating connection to remote for copy: %+v", err)
return err
}
// First try to create a bucket and have the Windows VM download it via a
// GS URL. If that fails, use the remote copy method.
err = r.copyViaBucket(
context.Background(),
inputPath,
`C:\workspace`,
copyTimeoutMin,
)
if err == nil {
// Successfully copied via GCE bucket
log.Printf("Successfully copied data via GCE bucket")
return nil
}
log.Printf("Failed to copy data via GCE bucket: %v", err)
err = c.Copy(inputPath, `C:\workspace`)
if err != nil {
log.Printf("Error copying workspace to remote: %+v", err)
return err
}
return nil
}