Skip to content

Commit b1f4110

Browse files
authored
Make AWS provider explicit (#670)
1 parent c99e1b1 commit b1f4110

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

src/cmd/cli/command/commands.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ func Execute(ctx context.Context) error {
129129

130130
func SetupCommands(version string) {
131131
RootCmd.Version = version
132-
RootCmd.PersistentFlags().Var(&colorMode, "color", `colorize output; "auto", "always" or "never"`)
132+
RootCmd.PersistentFlags().Var(&colorMode, "color", `colorize output; one of [always never]`)
133133
RootCmd.PersistentFlags().StringVarP(&cluster, "cluster", "s", cli.DefangFabric, "Defang cluster to connect to")
134134
RootCmd.PersistentFlags().MarkHidden("cluster")
135-
RootCmd.PersistentFlags().VarP(&provider, "provider", "P", `cloud provider to use; use "aws" for bring-your-own-cloud`)
135+
RootCmd.PersistentFlags().VarP(&provider, "provider", "P", `cloud provider to use for bring-your-own-cloud; one of [defang aws]`)
136136
RootCmd.PersistentFlags().BoolVarP(&cli.DoVerbose, "verbose", "v", false, "verbose logging") // backwards compat: only used by tail
137137
RootCmd.PersistentFlags().BoolVar(&doDebug, "debug", pkg.GetenvBool("DEFANG_DEBUG"), "debug logging for troubleshooting the CLI")
138138
RootCmd.PersistentFlags().BoolVar(&cli.DoDryRun, "dry-run", false, "dry run (don't actually change anything)")
@@ -292,22 +292,21 @@ var RootCmd = &cobra.Command{
292292
switch provider {
293293
case cliClient.ProviderAuto:
294294
if awsInEnv() {
295-
provider = cliClient.ProviderAWS
296-
} else {
297-
provider = cliClient.ProviderDefang
295+
term.Warn("Using Defang playground, but AWS environment variables were detected; did you forget --provider=aws?")
296+
} else if doInEnv() {
297+
term.Warn("Using Defang playground, but DO_PAT environment variable was detected; did you forget --provider=digitalocean?")
298298
}
299+
provider = cliClient.ProviderDefang
299300
case cliClient.ProviderAWS:
300301
if !awsInEnv() {
301302
term.Warn("AWS provider was selected, but AWS environment variables are not set")
302303
}
303304
case cliClient.ProviderDO:
304305
if !doInEnv() {
305-
term.Warn("Digital Ocean provider was selected, but DO_PAT environment variable is not set")
306+
term.Warn("DigitalOcean provider was selected, but DO_PAT environment variable is not set")
306307
}
307308
case cliClient.ProviderDefang:
308-
if awsInEnv() {
309-
term.Warn("Using Defang playground, but AWS environment variables were detected; did you forget --provider?")
310-
}
309+
// Ignore any env vars when explicitly using the Defang playground provider
311310
}
312311

313312
cwd, _ := cmd.Flags().GetString("cwd")

src/pkg/cli/client/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const (
1111
ProviderAuto Provider = "auto"
1212
ProviderDefang Provider = "defang"
1313
ProviderAWS Provider = "aws"
14-
ProviderDO Provider = "do"
14+
ProviderDO Provider = "digitalocean"
1515
// ProviderAzure Provider = "azure"
1616
// ProviderGCP Provider = "gcp"
1717
)

src/pkg/cli/connect.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ func NewClient(ctx context.Context, cluster string, provider client.Provider, lo
8383

8484
switch provider {
8585
case client.ProviderAWS:
86-
term.Info("Using AWS provider") // '#' hack no logner needed as root command skips new client for competion command now
86+
term.Info("Using AWS provider")
8787
byocClient := aws.NewByoc(ctx, grpcClient, tenantId)
8888
return byocClient
8989
case client.ProviderDO:
90-
term.Info("Using DO provider")
90+
term.Info("Using DigitalOcean provider")
9191
byocClient := do.NewByoc(ctx, grpcClient, tenantId)
9292
return byocClient
9393
default:

0 commit comments

Comments
 (0)