@@ -1,6 +1,6 @@
|
|||||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
||||||
|
|
||||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-empty-plan.git"
|
base: "git@git.kjuulh.io:kjuulh/cuddle-empty-plan.git"
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
service: "%%name%%"
|
service: "%%name%%"
|
||||||
@@ -12,5 +12,5 @@ please:
|
|||||||
repository: "%%name%%"
|
repository: "%%name%%"
|
||||||
branch: main
|
branch: main
|
||||||
settings:
|
settings:
|
||||||
api_url: https://git.front.kjuulh.io
|
api_url: https://git.kjuulh.io
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
||||||
|
|
||||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-infrastructure-plan.git"
|
base: "git@git.kjuulh.io:kjuulh/cuddle-infrastructure-plan.git"
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
service: "%%name%%"
|
service: "%%name%%"
|
||||||
@@ -13,7 +13,7 @@ vars:
|
|||||||
|
|
||||||
|
|
||||||
deployment:
|
deployment:
|
||||||
registry: git@git.front.kjuulh.io:kjuulh/clank-clusters
|
registry: git@git.kjuulh.io:kjuulh/clank-clusters
|
||||||
env:
|
env:
|
||||||
prod:
|
prod:
|
||||||
clusters:
|
clusters:
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
||||||
|
|
||||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-rust-leptos-plan.git"
|
base: "git@git.kjuulh.io:kjuulh/cuddle-rust-leptos-plan.git"
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
service: "%%name%%"
|
service: "%%name%%"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
||||||
|
|
||||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-node-service-plan.git"
|
base: "git@git.kjuulh.io:kjuulh/cuddle-node-service-plan.git"
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
service: "%%name%%"
|
service: "%%name%%"
|
||||||
@@ -13,7 +13,7 @@ vars:
|
|||||||
|
|
||||||
|
|
||||||
deployment:
|
deployment:
|
||||||
registry: git@git.front.kjuulh.io:kjuulh/clank-clusters
|
registry: git@git.kjuulh.io:kjuulh/clank-clusters
|
||||||
env:
|
env:
|
||||||
prod:
|
prod:
|
||||||
clusters:
|
clusters:
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
||||||
|
|
||||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-rust-cli-plan.git"
|
base: "git@git.kjuulh.io:kjuulh/cuddle-rust-cli-plan.git"
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
service: "%%name%%"
|
service: "%%name%%"
|
||||||
@@ -12,6 +12,6 @@ please:
|
|||||||
repository: "%%name%%"
|
repository: "%%name%%"
|
||||||
branch: "main"
|
branch: "main"
|
||||||
settings:
|
settings:
|
||||||
api_url: "https://git.front.kjuulh.io"
|
api_url: "https://git.kjuulh.io"
|
||||||
actions:
|
actions:
|
||||||
rust:
|
rust:
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
||||||
|
|
||||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-rust-lib-plan.git"
|
base: "git@git.kjuulh.io:kjuulh/cuddle-rust-lib-plan.git"
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
service: "%%name%%"
|
service: "%%name%%"
|
||||||
@@ -12,6 +12,6 @@ please:
|
|||||||
repository: "%%name%%"
|
repository: "%%name%%"
|
||||||
branch: main
|
branch: main
|
||||||
settings:
|
settings:
|
||||||
api_url: "https://git.front.kjuulh.io"
|
api_url: "https://git.kjuulh.io"
|
||||||
actions:
|
actions:
|
||||||
rust:
|
rust:
|
||||||
|
@@ -1,40 +1,36 @@
|
|||||||
use std::{net::SocketAddr, ops::Deref, sync::Arc};
|
mod state {
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct State {}
|
||||||
|
|
||||||
use anyhow::Context;
|
impl State {
|
||||||
use axum::extract::MatchedPath;
|
pub async fn new() -> anyhow::Result<Self> {
|
||||||
use axum::http::Request;
|
Ok(Self {})
|
||||||
use axum::Router;
|
}
|
||||||
use axum::routing::get;
|
}
|
||||||
|
}
|
||||||
|
pub use state::*;
|
||||||
|
|
||||||
|
pub mod cli {
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
|
use crate::{State, cli::serve::ServeCommand};
|
||||||
|
|
||||||
|
mod serve {
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
|
use axum::{Router, extract::MatchedPath, http::Request, routing::get};
|
||||||
use tower_http::trace::TraceLayer;
|
use tower_http::trace::TraceLayer;
|
||||||
|
|
||||||
#[derive(Parser)]
|
use crate::State;
|
||||||
#[command(author, version, about, long_about = None, subcommand_required = true)]
|
|
||||||
struct Command {
|
|
||||||
#[command(subcommand)]
|
|
||||||
command: Option<Commands>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(clap::Parser)]
|
||||||
enum Commands {
|
pub struct ServeCommand {
|
||||||
Serve {
|
|
||||||
#[arg(env = "SERVICE_HOST", long, default_value = "127.0.0.1:3000")]
|
#[arg(env = "SERVICE_HOST", long, default_value = "127.0.0.1:3000")]
|
||||||
host: SocketAddr,
|
host: SocketAddr,
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
impl ServeCommand {
|
||||||
async fn main() -> anyhow::Result<()> {
|
pub async fn execute(&self, state: &State) -> anyhow::Result<()> {
|
||||||
dotenv::dotenv().ok();
|
|
||||||
tracing_subscriber::fmt::init();
|
|
||||||
|
|
||||||
let cli = Command::parse();
|
|
||||||
|
|
||||||
if let Some(Commands::Serve { host }) = cli.command {
|
|
||||||
tracing::info!("Starting service");
|
|
||||||
|
|
||||||
let state = SharedState(Arc::new(State::new().await?));
|
|
||||||
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/", get(root))
|
.route("/", get(root))
|
||||||
.with_state(state.clone())
|
.with_state(state.clone())
|
||||||
@@ -56,36 +52,50 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
}), // ...
|
}), // ...
|
||||||
);
|
);
|
||||||
|
|
||||||
tracing::info!("listening on {}", host);
|
tracing::info!("listening on {}", self.host);
|
||||||
let listener = tokio::net::TcpListener::bind(host).await.unwrap();
|
let listener = tokio::net::TcpListener::bind(self.host).await.unwrap();
|
||||||
axum::serve(listener, app.into_make_service())
|
axum::serve(listener, app.into_make_service())
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fn root() -> &'static str {
|
async fn root() -> &'static str {
|
||||||
"Hello, %%name%%!"
|
"Hello, nostore!"
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct SharedState(Arc<State>);
|
|
||||||
|
|
||||||
impl Deref for SharedState {
|
|
||||||
type Target = Arc<State>;
|
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
|
||||||
&self.0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct State {}
|
#[derive(Parser)]
|
||||||
|
#[command(author, version, about, long_about = None, subcommand_required = true)]
|
||||||
|
struct Command {
|
||||||
|
#[command(subcommand)]
|
||||||
|
command: Option<Commands>,
|
||||||
|
}
|
||||||
|
|
||||||
impl State {
|
#[derive(Subcommand)]
|
||||||
pub async fn new() -> anyhow::Result<Self> {
|
enum Commands {
|
||||||
Ok(Self {})
|
Serve(ServeCommand),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn execute() -> anyhow::Result<()> {
|
||||||
|
let cli = Command::parse();
|
||||||
|
|
||||||
|
let state = State::new().await?;
|
||||||
|
|
||||||
|
match cli.command.expect("a subcommand") {
|
||||||
|
Commands::Serve(cmd) => cmd.execute(&state).await,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> anyhow::Result<()> {
|
||||||
|
dotenv::dotenv().ok();
|
||||||
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
|
cli::execute().await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
||||||
|
|
||||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-rust-service-plan.git"
|
base: "git@git.kjuulh.io:kjuulh/cuddle-rust-service-plan.git"
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
service: "%%name%%"
|
service: "%%name%%"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
||||||
|
|
||||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-base.git"
|
base: "git@git.kjuulh.io:kjuulh/cuddle-base.git"
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
service: "%%name%%"
|
service: "%%name%%"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
||||||
|
|
||||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-base.git"
|
base: "git@git.kjuulh.io:kjuulh/cuddle-base.git"
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
service: "%%name%%"
|
service: "%%name%%"
|
||||||
@@ -12,4 +12,4 @@ please:
|
|||||||
repository: "%%name%%"
|
repository: "%%name%%"
|
||||||
branch: "main"
|
branch: "main"
|
||||||
settings:
|
settings:
|
||||||
api_url: "https://git.front.kjuulh.io"
|
api_url: "https://git.kjuulh.io"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
||||||
|
|
||||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-base.git"
|
base: "git@git.kjuulh.io:kjuulh/cuddle-base.git"
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
service: "%%name%%"
|
service: "%%name%%"
|
||||||
@@ -12,4 +12,4 @@ please:
|
|||||||
repository: "%%name%%"
|
repository: "%%name%%"
|
||||||
branch: main
|
branch: main
|
||||||
settings:
|
settings:
|
||||||
api_url: "https://git.front.kjuulh.io"
|
api_url: "https://git.kjuulh.io"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
# yaml-language-server: $schema=https://git.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
||||||
|
|
||||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-base.git"
|
base: "git@git.kjuulh.io:kjuulh/cuddle-base.git"
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
service: "%%name%%"
|
service: "%%name%%"
|
||||||
|
Reference in New Issue
Block a user