Skip to content

Commit 571fe66

Browse files
committed
chore(core): expand datacenters schema (#3155)
1 parent e7fecd5 commit 571fe66

File tree

5 files changed

+52
-35
lines changed

5 files changed

+52
-35
lines changed

out/openapi.json

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

packages/core/api-public/src/runner_configs.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ use crate::ctx::ApiCtx;
2222
#[serde(deny_unknown_fields)]
2323
#[schema(as = RunnerConfigsListResponse)]
2424
pub struct ListResponse {
25-
pub runner_configs: HashMap<String, HashMap<String, rivet_types::runner_configs::RunnerConfig>>,
25+
pub runner_configs: HashMap<String, RunnerConfigDatacenters>,
2626
pub pagination: Pagination,
2727
}
2828

29+
#[derive(Deserialize, Serialize, ToSchema)]
30+
#[schema(as = RunnerConfigsListResponseRunnerConfigsValue)]
31+
pub struct RunnerConfigDatacenters {
32+
pub datacenters: HashMap<String, rivet_types::runner_configs::RunnerConfig>,
33+
}
34+
2935
#[utoipa::path(
3036
get,
3137
operation_id = "runner_configs_list",
@@ -64,7 +70,7 @@ async fn list_inner(
6470
_,
6571
_,
6672
_,
67-
HashMap<String, HashMap<String, rivet_types::runner_configs::RunnerConfig>>,
73+
HashMap<String, RunnerConfigDatacenters>,
6874
>(
6975
ctx.clone().into(),
7076
headers,
@@ -76,9 +82,13 @@ async fn list_inner(
7682
},
7783
|dc_label, res, agg| {
7884
for (runner_name, runner_config) in res.runner_configs {
79-
let entry = agg.entry(runner_name).or_insert_with(HashMap::new);
85+
let entry = agg
86+
.entry(runner_name)
87+
.or_insert_with(|| RunnerConfigDatacenters {
88+
datacenters: HashMap::new(),
89+
});
8090

81-
entry.insert(
91+
entry.datacenters.insert(
8292
ctx.config()
8393
.dc_for_label(dc_label)
8494
.expect("dc should exist")
@@ -100,9 +110,9 @@ async fn list_inner(
100110
#[derive(Deserialize, Serialize, ToSchema)]
101111
#[serde(deny_unknown_fields)]
102112
#[schema(as = RunnerConfigsUpsertRequestBody)]
103-
pub struct UpsertRequest(
104-
#[schema(inline)] HashMap<String, rivet_api_types::namespaces::runner_configs::RunnerConfig>,
105-
);
113+
pub struct UpsertRequest {
114+
pub datacenters: HashMap<String, rivet_api_types::namespaces::runner_configs::RunnerConfig>,
115+
}
106116

107117
#[utoipa::path(
108118
put,
@@ -141,7 +151,7 @@ async fn upsert_inner(
141151
ctx.auth().await?;
142152

143153
for dc in &ctx.config().topology().datacenters {
144-
if let Some(runner_config) = body.0.remove(&dc.name) {
154+
if let Some(runner_config) = body.datacenters.remove(&dc.name) {
145155
if ctx.config().dc_label() == dc.datacenter_label {
146156
rivet_api_peer::runner_configs::upsert(
147157
ctx.clone().into(),

packages/services/namespace/src/ops/runner_config/upsert.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ pub async fn namespace_runner_config_upsert(ctx: &OperationCtx, input: &Input) -
2020
let runner_config_key =
2121
keys::runner_config::DataKey::new(input.namespace_id, input.name.clone());
2222

23-
// Delete previous config
23+
// Delete previous index
2424
if let Some(existing_config) = tx.read_opt(&runner_config_key, Serializable).await? {
25-
tx.delete(&runner_config_key);
2625
tx.delete(&keys::runner_config::ByVariantKey::new(
2726
input.namespace_id,
2827
runner_config_variant(&existing_config),

scripts/api/runner-configs/upsert.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ const response = await fetch(
133133
"Content-Type": "application/json",
134134
},
135135
body: JSON.stringify({
136-
[datacenter]: dcRunnerConfig,
136+
datacenters: {
137+
[datacenter]: dcRunnerConfig,
138+
},
137139
}),
138140
},
139141
);

sdks/rust/data/src/versioned/namespace_runner_config.rs

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

0 commit comments

Comments
 (0)