Skip to content

Commit 68b4b06

Browse files
authored
feat: Add client capability to set replicas (#2012)
1 parent 6c6883d commit 68b4b06

File tree

6 files changed

+17
-20
lines changed

6 files changed

+17
-20
lines changed

admin/src/args.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clap::{Parser, Subcommand};
2-
use shuttle_common::{constants::SHUTTLE_API_URL, models::project::ComputeTier};
2+
use shuttle_common::constants::SHUTTLE_API_URL;
33

44
#[derive(Parser, Debug)]
55
pub struct Args {
@@ -22,13 +22,13 @@ pub enum Command {
2222
new_user_id: String,
2323
},
2424

25-
UpdateCompute {
25+
UpdateProjectConfig {
2626
/// Project to update
2727
#[arg(long, visible_alias = "id")]
2828
project_id: String,
29-
/// Compute tier to set.
30-
#[arg(long, visible_alias = "tier")]
31-
compute_tier: ComputeTier,
29+
/// Project configuration as JSON
30+
#[arg(long, visible_alias = "config")]
31+
json: String,
3232
},
3333

3434
/// Renew all old custom domain certificates

admin/src/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::Result;
22
use serde_json::{json, Value};
33
use shuttle_api_client::ShuttleApiClient;
44
use shuttle_common::models::{
5-
project::{ComputeTier, ProjectResponse, ProjectUpdateRequest},
5+
project::{ProjectResponse, ProjectUpdateRequest},
66
user::UserResponse,
77
};
88

@@ -30,16 +30,16 @@ impl Client {
3030
.await
3131
}
3232

33-
pub async fn update_project_compute_tier(
33+
pub async fn update_project_config(
3434
&self,
3535
project_id: &str,
36-
compute_tier: ComputeTier,
36+
config: serde_json::Value,
3737
) -> Result<ProjectResponse> {
3838
self.inner
3939
.put_json(
4040
format!("/projects/{project_id}"),
4141
Some(ProjectUpdateRequest {
42-
compute_tier: Some(compute_tier),
42+
config: Some(config),
4343
..Default::default()
4444
}),
4545
)

admin/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,9 @@ pub async fn run(args: Args) {
3131
tokio::time::sleep(tokio::time::Duration::from_millis(1000)).await;
3232
}
3333
}
34-
Command::UpdateCompute {
35-
project_id,
36-
compute_tier,
37-
} => {
34+
Command::UpdateProjectConfig { project_id, json } => {
3835
let res = client
39-
.update_project_compute_tier(&project_id, compute_tier)
36+
.update_project_config(&project_id, serde_json::from_str(&json).unwrap())
4037
.await
4138
.unwrap();
4239
println!("{res:?}");

common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ crossterm = { workspace = true, optional = true }
1717
http = { workspace = true }
1818
semver = { workspace = true }
1919
serde = { workspace = true, features = ["derive", "std"] }
20-
serde_json = { workspace = true }
20+
serde_json = { workspace = true, features = ["raw_value"] }
2121
strum = { workspace = true, features = ["derive"] }
2222
tracing = { workspace = true, features = ["std"], optional = true }
2323
typeshare = { workspace = true }

common/src/models/project.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub struct ProjectListResponse {
7373
}
7474

7575
/// Set wanted field(s) to Some to update those parts of the project
76-
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq)]
76+
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
7777
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7878
#[typeshare::typeshare]
7979
pub struct ProjectUpdateRequest {
@@ -85,8 +85,8 @@ pub struct ProjectUpdateRequest {
8585
pub team_id: Option<String>,
8686
/// Transfer away from current team
8787
pub remove_from_team: Option<bool>,
88-
/// Change compute tier
89-
pub compute_tier: Option<ComputeTier>,
88+
/// Project runtime configuration
89+
pub config: Option<serde_json::Value>,
9090
}
9191

9292
#[derive(

common/types.ts

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)