Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implemented open default browser in local mode #2122

Merged
merged 18 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 22 additions & 9 deletions cmd/argo/commands/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import (
"fmt"
"os"
"time"


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File is not goimports-ed with -local github.com/argoproj/argo (from goimports)

"github.com/skratchdot/open-golang/open"
"github.com/argoproj/pkg/cli"
"github.com/argoproj/pkg/stats"
log "github.com/sirupsen/logrus"
Expand All @@ -21,13 +22,14 @@ import (

func NewServerCommand() *cobra.Command {
var (
logLevel string // --loglevel
authMode string
configMap string
port int
baseHRef string
namespaced bool // --namespaced
managedNamespace string // --managed-namespace
logLevel string // --loglevel
authMode string
configMap string
port int
baseHRef string
namespaced bool // --namespaced
managedNamespace string // --managed-namespace
disableOpenBrowser bool
alexec marked this conversation as resolved.
Show resolved Hide resolved
)

var command = cobra.Command{
Expand Down Expand Up @@ -87,7 +89,17 @@ See %s`, help.ArgoSever),
if err != nil {
return err
}
apiserver.NewArgoServer(opts).Run(ctx, port)
browserOpenFunc := func(url string) {}
sarabala1979 marked this conversation as resolved.
Show resolved Hide resolved
if !disableOpenBrowser {
browserOpenFunc = func(url string) {
log.Infof("Argo UI is available at %s", url)
err := open.Run(url)
if err != nil {
log.Warnf("Unable to open the browser. %v", err)
}
}
}
apiserver.NewArgoServer(opts).Run(ctx, port, browserOpenFunc)
return nil
},
}
Expand All @@ -103,5 +115,6 @@ See %s`, help.ArgoSever),
command.Flags().StringVar(&logLevel, "loglevel", "info", "Set the logging level. One of: debug|info|warn|error")
command.Flags().BoolVar(&namespaced, "namespaced", false, "run as namespaced mode")
command.Flags().StringVar(&managedNamespace, "managed-namespace", "", "namespace that watches, default to the installation namespace")
command.Flags().BoolVar(&disableOpenBrowser, "disable-open-browser", false, "disable automatic launching of the browser [Hosted mode]")
sarabala1979 marked this conversation as resolved.
Show resolved Hide resolved
return &command
}
2 changes: 1 addition & 1 deletion manifests/base/argo-server/argo-server-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
containers:
- name: argo-server
image: argoproj/argocli:latest
args: [server]
args: ["server","--disable-open-browser"]
sarabala1979 marked this conversation as resolved.
Show resolved Hide resolved
ports:
- containerPort: 2746
readinessProbe:
Expand Down
1 change: 1 addition & 0 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ spec:
containers:
- args:
- server
- --disable-open-browser
sarabala1979 marked this conversation as resolved.
Show resolved Hide resolved
image: argoproj/argocli:latest
name: argo-server
ports:
Expand Down
1 change: 1 addition & 0 deletions manifests/namespace-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ spec:
containers:
- args:
- server
- --disable-open-browser
sarabala1979 marked this conversation as resolved.
Show resolved Hide resolved
- --namespaced
image: argoproj/argocli:latest
name: argo-server
Expand Down
1 change: 1 addition & 0 deletions manifests/quick-start-mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ spec:
containers:
- args:
- server
- --disable-open-browser
sarabala1979 marked this conversation as resolved.
Show resolved Hide resolved
- --namespaced
image: argoproj/argocli:latest
name: argo-server
Expand Down
1 change: 1 addition & 0 deletions manifests/quick-start-no-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ spec:
containers:
- args:
- server
- --disable-open-browser
sarabala1979 marked this conversation as resolved.
Show resolved Hide resolved
- --namespaced
image: argoproj/argocli:latest
name: argo-server
Expand Down
1 change: 1 addition & 0 deletions manifests/quick-start-postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ spec:
containers:
- args:
- server
- --disable-open-browser
- --namespaced
image: argoproj/argocli:latest
name: argo-server
Expand Down
7 changes: 5 additions & 2 deletions server/apiserver/argoserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type argoServer struct {
}

type ArgoServerOpts struct {
BaseHRef string
BaseHRef string
Namespace string
KubeClientset *kubernetes.Clientset
WfClientSet *versioned.Clientset
Expand Down Expand Up @@ -105,7 +105,7 @@ func (ao ArgoServerOpts) ValidateOpts() error {
return nil
}

func (as *argoServer) Run(ctx context.Context, port int) {
func (as *argoServer) Run(ctx context.Context, port int, browserOpenFunc func(string)) {

configMap, err := as.rsyncConfig()
if err != nil {
Expand Down Expand Up @@ -159,6 +159,9 @@ func (as *argoServer) Run(ctx context.Context, port int) {
go func() { as.checkServeErr("httpServer", httpServer.Serve(httpL)) }()
go func() { as.checkServeErr("tcpm", tcpm.Serve()) }()
log.Infof("Argo Server started successfully on address %s", address)

browserOpenFunc("http://localhost" + address)
sarabala1979 marked this conversation as resolved.
Show resolved Hide resolved

as.stopCh = make(chan struct{})
<-as.stopCh
}
Expand Down
1 change: 1 addition & 0 deletions test/e2e/manifests/mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ spec:
containers:
- args:
- server
- --disable-open-browser
- --namespaced
- --auth-mode
- client
Expand Down
1 change: 1 addition & 0 deletions test/e2e/manifests/no-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ spec:
containers:
- args:
- server
- --disable-open-browser
- --namespaced
- --auth-mode
- client
Expand Down
1 change: 1 addition & 0 deletions test/e2e/manifests/postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ spec:
containers:
- args:
- server
- --disable-open-browser
- --namespaced
- --auth-mode
- client
Expand Down