-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ds): implement pegboard dynamic server (#1158)
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. -->
- Loading branch information
1 parent
8329433
commit 149de29
Showing
37 changed files
with
1,441 additions
and
556 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
svc/pkg/ds/db/servers/migrations/20240917192549_add_pegboard.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
CREATE TABLE servers_pegboard ( | ||
server_id UUID PRIMARY KEY REFERENCES servers, | ||
pegboard_container_id UUID NOT NULL, | ||
pegboard_client_id STRING, | ||
pegboard_client_id UUID, | ||
|
||
INDEX (pegboard_container_id) | ||
); | ||
|
||
-- Agnostify | ||
ALTER TABLE internal_ports | ||
RENAME COLUMN nomad_label TO label, | ||
RENAME COLUMN nomad_ip TO ip, | ||
RENAME COLUMN nomad_source TO source; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use std::convert::{TryFrom, TryInto}; | ||
|
||
use chirp_workflow::prelude::*; | ||
|
||
use crate::types::{GameClient, GameConfig}; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct Input { | ||
pub game_ids: Vec<Uuid>, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct Output { | ||
pub game_configs: Vec<GameConfig>, | ||
} | ||
|
||
#[derive(sqlx::FromRow)] | ||
struct GameConfigRow { | ||
game_id: Uuid, | ||
host_networking_enabled: bool, | ||
root_user_enabled: bool, | ||
client: i64, | ||
} | ||
|
||
impl TryFrom<GameConfigRow> for GameConfig { | ||
type Error = GlobalError; | ||
|
||
fn try_from(value: GameConfigRow) -> GlobalResult<GameConfig> { | ||
Ok(GameConfig { | ||
game_id: value.game_id, | ||
host_networking_enabled: value.host_networking_enabled, | ||
root_user_enabled: value.root_user_enabled, | ||
client: unwrap!(GameClient::from_repr(value.client.try_into()?)), | ||
}) | ||
} | ||
} | ||
|
||
#[operation] | ||
pub async fn ds_game_config_get(ctx: &OperationCtx, input: &Input) -> GlobalResult<Output> { | ||
let game_configs = sql_fetch_all!( | ||
[ctx, GameConfigRow] | ||
" | ||
SELECT game_id, host_networking_enabled, root_user_enabled, client | ||
FROM db_ds.game_config | ||
WHERE game_id = ANY($1) | ||
", | ||
&input.game_ids, | ||
) | ||
.await? | ||
.into_iter() | ||
.map(TryInto::try_into) | ||
.collect::<GlobalResult<_>>()?; | ||
|
||
Ok(Output { game_configs }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod get; | ||
pub mod update; |
Oops, something went wrong.