From 00459f9e3d818f0fb84160862f02898d64f98110 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Thu, 14 Jul 2022 20:53:08 +0200 Subject: create a configuration to hold docker registry url --- planetwars-server/src/routes/demo.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'planetwars-server/src/routes') diff --git a/planetwars-server/src/routes/demo.rs b/planetwars-server/src/routes/demo.rs index 5ff02c7..6f2d5e6 100644 --- a/planetwars-server/src/routes/demo.rs +++ b/planetwars-server/src/routes/demo.rs @@ -1,7 +1,9 @@ +use std::sync::Arc; + use crate::db; use crate::db::matches::{FullMatchData, FullMatchPlayerData}; use crate::modules::bots::save_code_string; -use crate::modules::matches::{MatchPlayer, RunMatch}; +use crate::modules::matches::{MatchPlayer, MatchRunnerConfig, RunMatch}; use crate::ConnectionPool; use axum::extract::Extension; use axum::Json; @@ -30,6 +32,7 @@ pub struct SubmitBotResponse { pub async fn submit_bot( Json(params): Json, Extension(pool): Extension, + Extension(runner_config): Extension>, ) -> Result, StatusCode> { let conn = pool.get().await.expect("could not get database connection"); @@ -46,16 +49,19 @@ pub async fn submit_bot( // TODO: can we recover from this? .expect("could not save bot code"); - let run_match = RunMatch::from_players(vec![ - MatchPlayer::BotVersion { - bot: None, - version: player_bot_version.clone(), - }, - MatchPlayer::BotVersion { - bot: Some(opponent_bot.clone()), - version: opponent_bot_version.clone(), - }, - ]); + let run_match = RunMatch::from_players( + runner_config, + vec![ + MatchPlayer::BotVersion { + bot: None, + version: player_bot_version.clone(), + }, + MatchPlayer::BotVersion { + bot: Some(opponent_bot.clone()), + version: opponent_bot_version.clone(), + }, + ], + ); let (match_data, _) = run_match .run(pool.clone()) .await -- cgit v1.2.3