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

add UrlAction to auto-config #146

Merged
merged 1 commit into from
Nov 18, 2021
Merged
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
22 changes: 18 additions & 4 deletions cmd/setup_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ func (cc *SetupCmd) Run(ctx *RunContext) error {

func setupWizard(ctx *RunContext) error {
var err error
var instanceName, startURL, ssoRegion, awsRegion string
var instanceName, startURL, ssoRegion, awsRegion, urlAction string

// Name our SSO instance
prompt := promptui.Prompt{
Label: "SSO Instance Name",
Validate: validateSSOName,
Expand All @@ -73,28 +74,31 @@ func setupWizard(ctx *RunContext) error {
return err
}

// Get the full AWS SSO start URL
prompt = promptui.Prompt{
Label: "SSO Start URL",
Label: "SSO Start URL (StartUrl)",
Validate: validateSSOUrl,
}
if startURL, err = prompt.Run(); err != nil {
return err
}

// Pick our AWS SSO region
sel := promptui.Select{
Label: "SSO Region",
Label: "AWS SSO Region (SSORegion)",
Items: AvailableAwsSSORegions,
HideSelected: false,
}
if _, ssoRegion, err = sel.Run(); err != nil {
return err
}

// Pick the AWS region to use
defaultRegions := []string{"None"}
defaultRegions = append(defaultRegions, AvailableAwsSSORegions...)

sel = promptui.Select{
Label: "[Optional] Default AWS Region for IAM Sessions",
Label: "Default region for connecting to AWS (DefaultRegion)",
Items: defaultRegions,
HideSelected: false,
}
Expand All @@ -106,9 +110,19 @@ func setupWizard(ctx *RunContext) error {
awsRegion = ""
}

// How should we deal with URLs?
sel = promptui.Select{
Label: "Default action to take with URLs (UrlAction)",
Items: []string{"open", "print", "clip"},
}
if _, urlAction, err = sel.Run(); err != nil {
return err
}

s := sso.Settings{
DefaultSSO: instanceName,
SSO: map[string]*sso.SSOConfig{},
UrlAction: urlAction,
}
s.SSO[ctx.Cli.SSO] = &sso.SSOConfig{
SSORegion: ssoRegion,
Expand Down