Skip to content

Commit

Permalink
Use the browser package
Browse files Browse the repository at this point in the history
  • Loading branch information
punmechanic committed Oct 6, 2023
1 parent 6d9907f commit 7acfaa7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 220 deletions.
11 changes: 0 additions & 11 deletions cli/browser_darwin.go

This file was deleted.

11 changes: 0 additions & 11 deletions cli/browser_linux.go

This file was deleted.

18 changes: 11 additions & 7 deletions cli/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sts"
"github.com/pkg/browser"
"github.com/riotgames/key-conjurer/internal/api"
"github.com/spf13/cobra"
)

var (
FlagRegion = "region"
FlagRoleName = "role"
FlagTimeRemaining = "time-remaining"
FlagTimeToLive = "ttl"
FlagBypassCache = "bypass-cache"
FlagRegion = "region"
FlagRoleName = "role"
FlagTimeRemaining = "time-remaining"
FlagTimeToLive = "ttl"
FlagBypassCache = "bypass-cache"
FlagOutputType = "out"
FlagShellType = "shell"
FlagAWSCLIPath = "awscli"
FlagTencentCLIPath = "tencentcli"
)

var (
Expand All @@ -40,7 +45,6 @@ func init() {
getCmd.Flags().Uint(FlagTimeToLive, 1, "The key timeout in hours from 1 to 8.")
getCmd.Flags().UintP(FlagTimeRemaining, "t", DefaultTimeRemaining, "Request new keys if there are no keys in the environment or the current keys expire within <time-remaining> minutes. Defaults to 60.")
getCmd.Flags().StringP(FlagRoleName, "r", "", "The name of the role to assume.")
getCmd.Flags().String(FlagRoleSessionName, "KeyConjurer-AssumeRole", "the name of the role session name that will show up in CloudTrail logs")
getCmd.Flags().StringP(FlagOutputType, "o", outputTypeEnvironmentVariable, "Format to save new credentials in. Supported outputs: env, awscli,tencentcli")
getCmd.Flags().String(FlagShellType, shellTypeInfer, "If output type is env, determines which format to output credentials in - by default, the format is inferred based on the execution environment. WSL users may wish to overwrite this to `bash`")
getCmd.Flags().String(FlagAWSCLIPath, "~/.aws/", "Path for directory used by the aws-cli tool. Default is \"~/.aws\".")
Expand Down Expand Up @@ -302,7 +306,7 @@ func (p OktaTencentCloudSAMLProvider) FetchSAMLAssertion(ctx context.Context) ([

// TODO: We should probably wait a second before opening the browser to see if the http server is going to throw an error
// If it throws an error, we should bail
if err := OpenBrowser(p.Href); err != nil {
if err := browser.OpenURL(p.Href); err != nil {
return nil, fmt.Errorf("failed to open web browser to URL %s: %w", p.Href, err)
}

Expand Down
1 change: 0 additions & 1 deletion cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func init() {
rootCmd.AddCommand(getCmd)
rootCmd.AddCommand(setCmd)
rootCmd.AddCommand(upgradeCmd)
rootCmd.AddCommand(&switchCmd)
rootCmd.AddCommand(&aliasCmd)
rootCmd.AddCommand(&unaliasCmd)
rootCmd.AddCommand(&rolesCmd)
Expand Down
190 changes: 0 additions & 190 deletions cli/switch.go

This file was deleted.

0 comments on commit 7acfaa7

Please sign in to comment.