Skip to content

Commit 7ac5df6

Browse files
committed
feat: add DEFANG_TENANT environment variable support for tenant selection
1 parent a064f96 commit 7ac5df6

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

pkgs/npm/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ The Defang CLI recognizes the following environment variables:
3232
- `DEFANG_HIDE_HINTS` - If set to `true`, hides hints in the CLI output; defaults to `false`
3333
- `DEFANG_HIDE_UPDATE` - If set to `true`, hides the update notification; defaults to `false`
3434
- `DEFANG_PROVIDER` - The name of the cloud provider to use, `auto` (default), `aws`, `digitalocean`, or `defang`
35+
- `DEFANG_TENANT` - The name of the tenant to use.
3536
- `NO_COLOR` - If set to any value, disables color output; by default, color output is enabled depending on the terminal
3637
- `TZ` - The timezone to use for log timestamps: an IANA TZ name like `UTC` or `Europe/Amsterdam`; defaults to `Local`
3738
- `XDG_STATE_HOME` - The directory to use for storing state; defaults to `~/.local/state`

src/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ The Defang CLI recognizes the following environment variables:
4141
- `DEFANG_PULUMI_BACKEND` - The Pulumi backend URL or `"pulumi-cloud"`; defaults to a self-hosted backend
4242
- `DEFANG_PULUMI_DIR` - Run Pulumi from this folder, instead of spawning a cloud task; requires `--debug` (BYOC only)
4343
- `DEFANG_PULUMI_VERSION` - Override the version of the Pulumi image to use (`aws` provider only)
44+
- `DEFANG_TENANT` - The name of the tenant to use.
4445
- `NO_COLOR` - If set to any value, disables color output; by default, color output is enabled depending on the terminal
4546
- `PULUMI_ACCESS_TOKEN` - The Pulumi access token to use for authentication to Pulumi Cloud; see `DEFANG_PULUMI_BACKEND`
4647
- `PULUMI_CONFIG_PASSPHRASE` - Passphrase used to generate a unique key for your stack, and configuration and encrypted state values

src/cmd/cli/command/commands.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,11 @@ var RootCmd = &cobra.Command{
373373

374374
// Configure tenant selection based on --tenant flag
375375
if f := cmd.Root().Flag("tenant"); f != nil && f.Changed {
376+
// Highest precedence: explicit --tenant flag
376377
auth.SetSelectedTenantName(tenantFlag)
378+
} else if envTenant := os.Getenv("DEFANG_TENANT"); strings.TrimSpace(envTenant) != "" {
379+
// Next precedence: DEFANG_TENANT environment variable
380+
auth.SetSelectedTenantName(envTenant)
377381
} else {
378382
// Default behavior: auto-select tenant by JWT subject if no explicit name is provided
379383
auth.SetAutoSelectBySub(true)

0 commit comments

Comments
 (0)