mirror of
https://github.com/moghtech/komodo.git
synced 2026-05-04 11:32:28 -05:00
get accounts on builder
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
PORT=9001
|
||||
SECRETS_PATH=./secrets.example.toml
|
||||
PORT=9001 # optional, default is 9001
|
||||
SECRETS_PATH=./secrets.example.toml # optional, default is /secrets/secrets.json
|
||||
@@ -4,7 +4,7 @@ mod get_accounts;
|
||||
|
||||
pub fn router() -> Router {
|
||||
Router::new().route(
|
||||
"get_accounts/:account_type",
|
||||
"/accounts/:account_type",
|
||||
get(get_accounts::get_accounts),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::{net::SocketAddr, str::FromStr, sync::Arc};
|
||||
use std::sync::Arc;
|
||||
|
||||
use ::helpers::parse_config_file;
|
||||
use axum::Extension;
|
||||
use dotenv::dotenv;
|
||||
use ::helpers::parse_config_file;
|
||||
use mungos::Deserialize;
|
||||
|
||||
use crate::BuilderSecretsExtension;
|
||||
@@ -15,17 +15,14 @@ struct Env {
|
||||
secrets_path: String,
|
||||
}
|
||||
|
||||
pub fn load() -> (SocketAddr, BuilderSecretsExtension) {
|
||||
pub fn load() -> (u16, BuilderSecretsExtension) {
|
||||
dotenv().ok();
|
||||
|
||||
let env = envy::from_env::<Env>().unwrap();
|
||||
|
||||
let socket_addr = SocketAddr::from_str(&format!("0.0.0.0:{}", env.port))
|
||||
.expect("failed to parse socket addr");
|
||||
|
||||
let secrets = parse_config_file(&env.secrets_path).expect("failed to parse config");
|
||||
|
||||
(socket_addr, Extension(Arc::new(secrets)))
|
||||
(env.port, Extension(Arc::new(secrets)))
|
||||
}
|
||||
|
||||
fn default_port() -> u16 {
|
||||
|
||||
+5
-2
@@ -1,6 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::Extension;
|
||||
use helpers::get_socket_addr;
|
||||
use types::BuilderSecrets;
|
||||
|
||||
mod api;
|
||||
@@ -10,11 +11,13 @@ type BuilderSecretsExtension = Extension<Arc<BuilderSecrets>>;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let (socket_addr, secrets) = config::load();
|
||||
let (port, secrets) = config::load();
|
||||
|
||||
let app = api::router().layer(secrets);
|
||||
|
||||
axum::Server::bind(&socket_addr)
|
||||
println!("starting montior builder on port {port}");
|
||||
|
||||
axum::Server::bind(&get_socket_addr(port))
|
||||
.serve(app.into_make_service())
|
||||
.await
|
||||
.expect("server crashed");
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use ::run_command::async_run_command;
|
||||
use anyhow::anyhow;
|
||||
use async_timing_util::unix_timestamp_ms;
|
||||
use axum::Extension;
|
||||
use bollard::{container::ListContainersOptions, Docker};
|
||||
use ::run_command::async_run_command;
|
||||
use types::{
|
||||
BasicContainerInfo, Build, Conversion, Deployment, DockerRunArgs, EnvironmentVar, Log,
|
||||
RestartMode,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use async_timing_util::unix_timestamp_ms;
|
||||
use ::run_command::async_run_command;
|
||||
use async_timing_util::unix_timestamp_ms;
|
||||
use types::{Build, Deployment, Log};
|
||||
|
||||
pub async fn clone_build_repo(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{fs::File, io::Read};
|
||||
use std::{fs::File, io::Read, net::SocketAddr, str::FromStr};
|
||||
|
||||
use anyhow::Context;
|
||||
use async_timing_util::unix_timestamp_ms;
|
||||
@@ -36,3 +36,7 @@ pub fn output_into_log(stage: &str, command: String, start_ts: i64, output: Comm
|
||||
end_ts: unix_timestamp_ms() as i64,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_socket_addr(port: u16) -> SocketAddr {
|
||||
SocketAddr::from_str(&format!("0.0.0.0:{}", port)).expect("failed to parse socket addr")
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
SECRETS_PATH=./secrets.example.toml
|
||||
PORT = 8000 # optional, default is 8000
|
||||
SECRETS_PATH=./secrets.example.toml # optional, default is /secrets/secrets.json
|
||||
@@ -9,10 +9,6 @@ macro_rules! response {
|
||||
|
||||
use axum::http::StatusCode;
|
||||
|
||||
pub fn get_socket_addr(port: u16) -> SocketAddr {
|
||||
SocketAddr::from_str(&format!("0.0.0.0:{}", port)).expect("failed to parse socket addr")
|
||||
}
|
||||
|
||||
pub fn handle_anyhow_error(err: anyhow::Error) -> (StatusCode, String) {
|
||||
(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
#![allow(unused)]
|
||||
|
||||
use ::helpers::get_socket_addr;
|
||||
use axum::{extract::Path, http::StatusCode, routing::get, Extension, Json, Router};
|
||||
|
||||
mod api;
|
||||
mod config;
|
||||
mod helpers;
|
||||
|
||||
use crate::helpers::get_socket_addr;
|
||||
|
||||
use api::*;
|
||||
use crate::api::*;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
|
||||
Reference in New Issue
Block a user