diff --git a/go.mod b/go.mod index 9b310a0..0af0813 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/airbytehq/abctl go 1.21.9 require ( + github.com/cli/browser v1.3.0 github.com/docker/docker v26.1.0+incompatible github.com/google/go-cmp v0.6.0 github.com/mittwald/go-helm-client v0.12.9 diff --git a/go.sum b/go.sum index 08bf16a..d3bde60 100644 --- a/go.sum +++ b/go.sum @@ -68,6 +68,8 @@ github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNSjIRk= github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA= +github.com/cli/browser v1.3.0 h1:LejqCrpWr+1pRqmEPDGnTZOjsMe7sehifLynZJuqJpo= +github.com/cli/browser v1.3.0/go.mod h1:HH8s+fOAxjhQoBUAsKuPCbqUuxZDhQ2/aD+SzsEfBTk= github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw= github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw= diff --git a/internal/local/cmd.go b/internal/local/cmd.go index ccf4305..11cf8ad 100644 --- a/internal/local/cmd.go +++ b/internal/local/cmd.go @@ -7,6 +7,7 @@ import ( "github.com/airbytehq/abctl/internal/local/k8s" "github.com/airbytehq/abctl/internal/local/localerr" "github.com/airbytehq/abctl/internal/telemetry" + "github.com/cli/browser" helmclient "github.com/mittwald/go-helm-client" "github.com/mittwald/go-helm-client/values" "github.com/pterm/pterm" @@ -23,9 +24,7 @@ import ( "k8s.io/client-go/tools/clientcmd" "net/http" "os" - "os/exec" "path/filepath" - "runtime" "strconv" "strings" "sync" @@ -177,33 +176,7 @@ func New(provider k8s.Provider, portHTTP int, opts ...Option) (*Command, error) // set the browser launcher, if not defined if c.launcher == nil { - c.launcher = func(url string) error { - var cmd *exec.Cmd - switch runtime.GOOS { - case "darwin": - cmd = exec.Command("open", url) - case "windows": - cmd = exec.Command("cmd", "/c", "start", url) - case "linux": - if _, err := exec.LookPath("xdg-open"); err == nil { - cmd = exec.Command("xdg-open", url) - } else if _, err := exec.LookPath("sensible-browser"); err == nil { - cmd = exec.Command("sensible-browser", url) - } else if _, err := exec.LookPath("x-www-browser"); err == nil { - cmd = exec.Command("x-www-browser", url) - } else if _, err := exec.LookPath("gnome-open"); err == nil { - cmd = exec.Command("gnome-open", url) - } else if _, err := exec.LookPath("open"); err == nil { - cmd = exec.Command("open", url) - } else { - return errors.New("unable to determine executable to launch web-browser") - } - - default: - return fmt.Errorf("unsupported platform '%s'", runtime.GOOS) - } - return cmd.Run() - } + c.launcher = browser.OpenURL } // fetch k8s version information