mirror of
https://github.com/openshift/installer.git
synced 2026-02-06 09:47:02 +01:00
Notice that azblob also had to be upgraded to 0.4.1, otherwise we hit the following build issue: vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/zc_blob_lease_client.go:25:16: undefined: to.StringPtr vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/zc_block_blob_client.go:145:20: undefined: to.StringPtr vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/zc_container_lease_client.go:25:16: undefined: to.StringPtr vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/zc_shared_policy_shared_key_credential.go:190:17: undefined: log.EventResponse vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/zm_lease_request_options.go:63:16: undefined: to.StringPtr vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/zm_lease_request_options.go:142:16: undefined: to.StringPtr and newer versions cause pkg/gather/azure/azure.go:224:29: undefined: azblob.NewBlobClientWithSharedKey pkg/gather/azure/azure.go:235:48: unknown field 'MaxRetryRequests' in struct literal of type blob.RetryReaderOptions
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
// Package browser provides helpers to open files, readers, and urls in a browser window.
|
|
//
|
|
// The choice of which browser is started is entirely client dependant.
|
|
package browser
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"io/ioutil"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
)
|
|
|
|
// Stdout is the io.Writer to which executed commands write standard output.
|
|
var Stdout io.Writer = os.Stdout
|
|
|
|
// Stderr is the io.Writer to which executed commands write standard error.
|
|
var Stderr io.Writer = os.Stderr
|
|
|
|
// OpenFile opens new browser window for the file path.
|
|
func OpenFile(path string) error {
|
|
path, err := filepath.Abs(path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return OpenURL("file://" + path)
|
|
}
|
|
|
|
// OpenReader consumes the contents of r and presents the
|
|
// results in a new browser window.
|
|
func OpenReader(r io.Reader) error {
|
|
f, err := ioutil.TempFile("", "browser.*.html")
|
|
if err != nil {
|
|
return fmt.Errorf("browser: could not create temporary file: %v", err)
|
|
}
|
|
if _, err := io.Copy(f, r); err != nil {
|
|
f.Close()
|
|
return fmt.Errorf("browser: caching temporary file failed: %v", err)
|
|
}
|
|
if err := f.Close(); err != nil {
|
|
return fmt.Errorf("browser: caching temporary file failed: %v", err)
|
|
}
|
|
return OpenFile(f.Name())
|
|
}
|
|
|
|
// OpenURL opens a new browser window pointing to url.
|
|
func OpenURL(url string) error {
|
|
return openBrowser(url)
|
|
}
|
|
|
|
func runCmd(prog string, args ...string) error {
|
|
cmd := exec.Command(prog, args...)
|
|
cmd.Stdout = Stdout
|
|
cmd.Stderr = Stderr
|
|
return cmd.Run()
|
|
}
|