Skip to content

Commit

Permalink
Merge pull request #7174 from afbjorklund/xdg-open
Browse files Browse the repository at this point in the history
Centralize the handling of browser.OpenURL
  • Loading branch information
medyagh authored Mar 24, 2020
2 parents 1d94084 + 54bbdde commit 93021fb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
3 changes: 1 addition & 2 deletions cmd/minikube/cmd/config/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ import (
"os"
"text/template"

"github.com/pkg/browser"

"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/browser"
"k8s.io/minikube/pkg/minikube/config"
pkg_config "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/driver"
Expand Down
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import (

"github.com/docker/machine/libmachine/mcnerror"
"github.com/golang/glog"
"github.com/pkg/browser"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
pkgaddons "k8s.io/minikube/pkg/addons"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/browser"
"k8s.io/minikube/pkg/minikube/config"
pkg_config "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/driver"
Expand Down
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import (
"time"

"github.com/golang/glog"
"github.com/pkg/browser"
"github.com/spf13/cobra"
"github.com/spf13/viper"

"k8s.io/minikube/pkg/drivers/kic/oci"
"k8s.io/minikube/pkg/minikube/browser"
"k8s.io/minikube/pkg/minikube/config"
pkg_config "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/driver"
Expand Down
37 changes: 37 additions & 0 deletions pkg/minikube/browser/browser.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright 2020 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package browser

import (
"os/exec"
"runtime"

"github.com/pkg/browser"
"k8s.io/minikube/pkg/minikube/out"
)

// OpenURL opens a new browser window pointing to URL.
func OpenURL(url string) error {
if runtime.GOOS == "linux" {
_, err := exec.LookPath("xdg-open")
if err != nil {
out.T(out.URL, url)
return nil
}
}
return browser.OpenURL(url)
}

0 comments on commit 93021fb

Please sign in to comment.