func()

in gke-windows-builder/builder/builder/remote.go [134:159]


func (r *RemoteWindowsServer) copyViaBucket(ctx context.Context, inputPath string, copyTimeout time.Duration) error {
	object := fmt.Sprintf("windows-builder-%d", time.Now().UnixNano())

	gsURL, err := writeZipToBucket(
		ctx,
		*r.WorkspaceBucket,
		object,
		inputPath,
	)
	if err != nil {
		return err
	}

	pwrScript := fmt.Sprintf(`
$ErrorActionPreference = "Stop"
$ProgressPreference = 'SilentlyContinue'
gsutil cp %q %s.zip
Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -value 1
Add-Type -Assembly "System.IO.Compression.Filesystem";
[System.IO.Compression.ZipFile]::ExtractToDirectory("%s.zip", "%s");
Remove-Item -Path %s.zip -Force
`, gsURL, *r.WorkspaceFolder, *r.WorkspaceFolder, *r.WorkspaceFolder, *r.WorkspaceFolder)

	// Now tell the Windows VM to download it.
	return r.RunCommand(winrm.Powershell(pwrScript), *r.WorkspaceFolder, copyTimeout)
}