Skip to content
Merged
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
25 changes: 17 additions & 8 deletions cmd/invite.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ import (
var listCmd = &cobra.Command{
Use: "list-invites",
Short: "List all invites",
PreRun: func(cmd *cobra.Command, args []string) {
// Bind these to viper
err := viper.BindPFlags(cmd.Flags())
if err != nil {
log.WithError(err).Fatal("could not bind `list-invites` flags")
}
},
Run: func(cmd *cobra.Command, args []string) {
sigs := make(chan os.Signal, 1)

Expand Down Expand Up @@ -49,13 +56,14 @@ var listCmd = &cobra.Command{
var createCmd = &cobra.Command{
Use: "create-invite",
Short: "Create a new invite",
Run: func(cmd *cobra.Command, args []string) {
// Bind flags to viper
PreRun: func(cmd *cobra.Command, args []string) {
// Bind these to viper
err := viper.BindPFlags(cmd.Flags())
if err != nil {
log.WithError(err).Fatal("could not bind flags")
log.WithError(err).Fatal("could not bind `create-invite` flags")
}

},
Run: func(cmd *cobra.Command, args []string) {
sigs := make(chan os.Signal, 1)

signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
Expand All @@ -82,13 +90,14 @@ var createCmd = &cobra.Command{
var revokeCmd = &cobra.Command{
Use: "revoke-invites",
Short: "Revoke an existing invite",
Run: func(cmd *cobra.Command, args []string) {
// Bind flags to viper
PreRun: func(cmd *cobra.Command, args []string) {
// Bind these to viper
err := viper.BindPFlags(cmd.Flags())
if err != nil {
log.WithError(err).Fatal("could not bind flags")
log.WithError(err).Fatal("could not bind `revoke-invites` flags")
}

},
Run: func(cmd *cobra.Command, args []string) {
sigs := make(chan os.Signal, 1)

signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
Expand Down
11 changes: 3 additions & 8 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,11 @@ func ensureToken(ctx context.Context, requiredScopes []string) (context.Context,
}

// Check to see if the URL is secure
gatewayUrl := viper.GetString("gateway-url")
Copy link
Member

Choose a reason for hiding this comment

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

Does the removal of this gateway-url flag mean it's disused? If so should we remove it from the CLI flags too so it doesn't show in the help

Copy link
Contributor Author

Choose a reason for hiding this comment

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

--gateway-url is used elsewhere, so it needs to stay.

if gatewayUrl == "" {
gatewayUrl = fmt.Sprintf("%v/api/gateway", viper.GetString("url"))
viper.Set("gateway-url", gatewayUrl)
}
parsed, err := url.Parse(gatewayUrl)
appurl := viper.GetString("url")
parsed, err := url.Parse(appurl)
if err != nil {
log.WithContext(ctx).WithError(err).Error("Failed to parse --url")
return ctx, fmt.Errorf("error parsing --gateway-url: %w", err)
return ctx, fmt.Errorf("error parsing --url: %w", err)
}

if parsed.Scheme == "wss" || parsed.Scheme == "https" || parsed.Hostname() == "localhost" {
Expand Down Expand Up @@ -262,7 +258,6 @@ func ensureToken(ctx context.Context, requiredScopes []string) (context.Context,
audienceOption := oauth2.SetAuthURLParam("audience", "https://api.overmind.tech")

u := config.AuthCodeURL(oAuthStateString, oauth2.AccessTypeOnline, audienceOption)

log.WithContext(ctx).Infof("Follow this link to authenticate: %v", Underline.TextStyle(u))

// Start the webserver
Expand Down