Skip to content

confirm provider interactively if appropriate #1251

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
41 changes: 38 additions & 3 deletions src/cmd/cli/command/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -1220,9 +1220,44 @@ func updateProviderID(ctx context.Context, loader cliClient.Loader) error {
}
providerID = cliClient.ProviderDefang
} else {
var err error
if whence, err = determineProviderID(ctx, loader); err != nil {
return err
if awsInEnv() {
var confirm bool
if err := survey.AskOne(&survey.Confirm{
Message: "AWS environment variables detected. Do you want to use AWS as the provider?",
}, &confirm, survey.WithStdio(term.DefaultTerm.Stdio())); err != nil {
return fmt.Errorf("failed to confirm AWS provider: %w", err)
}
if confirm {
providerID = cliClient.ProviderAWS
whence = "AWS environment variables and confirmation"
}
} else if doInEnv() {
var confirm bool
if err := survey.AskOne(&survey.Confirm{
Message: "DIGITALOCEAN_TOKEN environment variable detected. Do you want to use DigitalOcean as the provider?",
}, &confirm, survey.WithStdio(term.DefaultTerm.Stdio())); err != nil {
return fmt.Errorf("failed to confirm DigitalOcean provider: %w", err)
}
if confirm {
providerID = cliClient.ProviderDO
whence = "Digital Ocean environment variable and confirmation"
}
} else if gcpInEnv() {
var confirm bool
if err := survey.AskOne(&survey.Confirm{
Message: "GCP_PROJECT_ID/CLOUDSDK_CORE_PROJECT environment variable detected. Do you want to use GCP as the provider?",
}, &confirm, survey.WithStdio(term.DefaultTerm.Stdio())); err != nil {
return fmt.Errorf("failed to confirm GCP provider: %w", err)
}
if confirm {
providerID = cliClient.ProviderGCP
whence = "GCP environment variable and confirmation"
}
} else {
var err error
if whence, err = determineProviderID(ctx, loader); err != nil {
return err
}
}
}
case cliClient.ProviderAWS:
Expand Down