Skip to content

Commit

Permalink
feat(cargo-shuttle): default beta url (#1829)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaro00 authored Jul 18, 2024
1 parent f72134c commit 880119e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cargo-shuttle/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::path::{Path, PathBuf};

use anyhow::{anyhow, Context, Result};
use serde::{Deserialize, Serialize};
use shuttle_common::constants::API_URL_BETA;
use shuttle_common::{constants::API_URL_DEFAULT, ApiKey};
use tracing::trace;

Expand Down Expand Up @@ -315,11 +316,13 @@ impl RequestContext {
self.api_url = api_url;
}

pub fn api_url(&self) -> String {
pub fn api_url(&self, beta: bool) -> String {
if let Some(api_url) = self.api_url.clone() {
api_url
} else if let Some(api_url) = self.global.as_ref().unwrap().api_url() {
api_url
} else if beta {
API_URL_BETA.to_string()
} else {
API_URL_DEFAULT.to_string()
}
Expand Down
3 changes: 2 additions & 1 deletion cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ impl Shuttle {
| Command::Clean
| Command::Project(..)
) {
let client = ShuttleApiClient::new(self.ctx.api_url(), self.ctx.api_key().ok());
let client =
ShuttleApiClient::new(self.ctx.api_url(self.beta), self.ctx.api_key().ok());
self.client = Some(client);
if !args.offline && !self.beta {
self.check_api_versions().await?;
Expand Down
1 change: 1 addition & 0 deletions common/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub const STORAGE_DIRNAME: &str = ".shuttle-storage";
// URLs
pub const API_URL_LOCAL: &str = "http://localhost:8001";
pub const API_URL_PRODUCTION: &str = "https://api.shuttle.rs";
pub const API_URL_BETA: &str = "https://api.internal.shuttle.rs";
#[cfg(debug_assertions)]
pub const API_URL_DEFAULT: &str = API_URL_LOCAL;
#[cfg(not(debug_assertions))]
Expand Down

0 comments on commit 880119e

Please sign in to comment.