Skip to content

Default login api-url to prod#146

Merged
richardpringle merged 1 commit into
mainfrom
richard/sys-96-default-tvc-cli-url-selection-to-prod
May 29, 2026
Merged

Default login api-url to prod#146
richardpringle merged 1 commit into
mainfrom
richard/sys-96-default-tvc-cli-url-selection-to-prod

Conversation

@richardpringle
Copy link
Copy Markdown
Contributor

Linear: SYS-96

Summary:

  • Default new tvc login orgs to prod without prompting for API URL.
  • Add --api-base-url / TVC_API_BASE_URL as explicit override paths.
  • Preserve existing org URLs unless an override is provided.

Tests:

  • cargo test -p tvc login

Remove the interactive API URL selection from `tvc login` and add
`--api-base-url` / `TVC_API_BASE_URL` as explicit override paths for
internal environments.
@richardpringle richardpringle marked this pull request as draft May 27, 2026 23:44
@richardpringle richardpringle marked this pull request as ready for review May 27, 2026 23:45
Copy link
Copy Markdown
Contributor

@daniilrrr daniilrrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion to do the Config resolution / override up front for clarity

in general, since we now do Clap flag > env > file overrides throughout the SDK, I think we should follow the pattern of

  1. load config
  2. resolve config overrides + flags
  3. pass around now-immutable config to functions

I will also check my #132 to make sure I'm following this pattern

Comment thread tvc/src/commands/login.rs
Comment on lines +24 to +25
#[arg(long, env = "TVC_API_BASE_URL", value_name = "URL")]
pub api_base_url: Option<String>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "BASE_URL" seems redundant to customers?

Suggested change
#[arg(long, env = "TVC_API_BASE_URL", value_name = "URL")]
pub api_base_url: Option<String>,
#[arg(long, env = "TVC_API_URL", value_name = "URL")]
pub api_url: Option<String>,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URL on its own can include paths, query-params, etc. BASE_URL implies that this is a full scheme + host.

Comment thread tvc/src/commands/login.rs
Comment on lines 36 to +45
// Load existing config
let mut config = Config::load().await?;

// Select or create org
let (alias, org_config) = select_or_create_org(&mut config, args.org.as_deref()).await?;
let (alias, org_config) = select_or_create_org(
&mut config,
args.org.as_deref(),
args.api_base_url.as_deref(),
)
.await?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think code and logic would be much clearer if we resolve the base_url here before going into the select_or_create_org() and nested logic.

Some ideas:

  • we could add a field/enum to tvc::config::turnkey::Config that defaults to API_BASE_URL_PROD, or the actual URL is fine too. Then, pass the config into select_or_create_org(). That seems clean
  • if you dont want to do that, call update_api_base_url_from_override() here instead of within the func, and then you don't have to do it later

either approach reads cleaner to me than the nested if let Some() in current logic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% agree. I poked around and tried to make a small change, but a larger refactor in order:

https://linear.app/turnkey/issue/SYS-100/flatten-tvc-login-org-selection-and-api-base-url-override-flow

@richardpringle richardpringle merged commit 1bf2d49 into main May 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants