Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
6 changes: 2 additions & 4 deletions cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"github.com/microcks/microcks-cli/pkg/config"
"github.com/microcks/microcks-cli/pkg/connectors"
"github.com/microcks/microcks-cli/pkg/errors"
"github.com/microcks/microcks-cli/pkg/util"
"github.com/microcks/microcks-cli/pkg/util/rand"
"github.com/skratchdot/open-golang/open"
"github.com/spf13/cobra"
"golang.org/x/oauth2"
"golang.org/x/term"
Expand Down Expand Up @@ -300,9 +300,7 @@ func oauth2login(

func ssoAuthFlow(url string, ssoLaunchBrowser bool) {
if ssoLaunchBrowser {
fmt.Printf("Opening system default browser for authentication\n")
err := open.Start(url)
errors.CheckError(err)
util.LaunchBrowser(url, ssoLaunchBrowser)
} else {
fmt.Printf("To authenticate, copy-and-paste the following URL into your preferred browser: %s\n", url)
}
Expand Down
19 changes: 14 additions & 5 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import (
"github.com/microcks/microcks-cli/pkg/config"
"github.com/microcks/microcks-cli/pkg/connectors"
"github.com/microcks/microcks-cli/pkg/errors"
"github.com/microcks/microcks-cli/pkg/util"
"github.com/spf13/cobra"
)

func NewStartCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command {
var (
name string
hostPort string
imageName string
autoRemove bool
driver string
name string
hostPort string
imageName string
autoRemove bool
driver string
launchBrowser bool
)
var startCmd = &cobra.Command{
Use: "start",
Expand Down Expand Up @@ -141,12 +143,19 @@ microcks start --name [name of you container/instance]`,
errors.CheckError(err)

fmt.Printf("Microcks started successfully at %s\n", server)

// Check global config if flag was not explicitly changed
if !cmd.Flags().Changed("launch-browser") {
launchBrowser = localConfig.GetLaunchBrowser()
}
util.LaunchBrowser(server, launchBrowser)
},
}
startCmd.Flags().StringVar(&name, "name", "microcks", "name for you microcks instance")
startCmd.Flags().StringVar(&hostPort, "port", "8585", "")
startCmd.Flags().StringVar(&imageName, "image", "quay.io/microcks/microcks-uber:latest-native", "image which will be used to create a container")
startCmd.Flags().BoolVar(&autoRemove, "rm", false, "mimic of '--rm' flag of dokcer to automatically remove the container when it exits")
startCmd.Flags().StringVar(&driver, "driver", "docker", "use --driver to change driver from docker to podman")
startCmd.Flags().BoolVar(&launchBrowser, "launch-browser", true, "Automatically launch the system browser to the Microcks dashboard")
return startCmd
}
12 changes: 11 additions & 1 deletion cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/microcks/microcks-cli/pkg/config"
"github.com/microcks/microcks-cli/pkg/connectors"
"github.com/microcks/microcks-cli/pkg/errors"
"github.com/microcks/microcks-cli/pkg/util"
"github.com/spf13/cobra"
)

Expand All @@ -39,6 +40,7 @@ func NewTestCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command {
filteredOperations string
operationsHeaders string
oAuth2Context string
launchBrowser bool
)
var testCmd = &cobra.Command{

Expand Down Expand Up @@ -189,7 +191,14 @@ func NewTestCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command {
time.Sleep(2 * time.Second)
}

fmt.Printf("Full TestResult details are available here: %s/#/tests/%s \n", serverAddr, testResultID)
testResultURL := fmt.Sprintf("%s/#/tests/%s", serverAddr, testResultID)
fmt.Printf("Full TestResult details are available here: %s \n", testResultURL)

// Check global config if flag was not explicitly changed
if !cmd.Flags().Changed("launch-browser") && localConfig != nil {
launchBrowser = localConfig.GetLaunchBrowser()
}
util.LaunchBrowser(testResultURL, launchBrowser)

if !success {
os.Exit(1)
Expand All @@ -202,6 +211,7 @@ func NewTestCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command {
testCmd.Flags().StringVar(&filteredOperations, "filteredOperations", "", "List of operations to launch a test for")
testCmd.Flags().StringVar(&operationsHeaders, "operationsHeaders", "", "Override of operations headers as JSON string")
testCmd.Flags().StringVar(&oAuth2Context, "oAuth2Context", "", "Spec of an OAuth2 client context as JSON string")
testCmd.Flags().BoolVar(&launchBrowser, "launch-browser", true, "Automatically launch the system browser to the Microcks test result")

return testCmd
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/config/localconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ type LocalConfig struct {
Users []User `yaml:"users"`
Instances []Instance `yaml:"instances"`
Auths []Auth `yaml:"auths"`
LaunchBrowser *bool `yaml:"launch-browser,omitempty"`
}

// GetLaunchBrowser returns the global preference for launching browser. Default is true.
func (l *LocalConfig) GetLaunchBrowser() bool {
if l.LaunchBrowser == nil {
return true
}
return *l.LaunchBrowser
}
type ContextRef struct {
Name string `yaml:"name"`
Server string `yaml:"server"`
Expand Down
Loading