diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 1481234d..2352e5b2 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -38,7 +38,7 @@ jobs: - name: E2E tests run: | cd backend - RUST_BACKTRACE=1 cargo run -p sync_server config-e2e.yml & + RUST_BACKTRACE=1 cargo run -p sync_server & cd .. scripts/update-api-types.sh diff --git a/backend/.dockerignore b/backend/.dockerignore index 985e2cd4..dd62faf4 100644 --- a/backend/.dockerignore +++ b/backend/.dockerignore @@ -3,4 +3,4 @@ Dockerfile .dockerignore databases sync_lib/pkg -*.yml +config.yml diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 4ea73d94..6292ef06 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -96,56 +96,6 @@ dependencies = [ "libc", ] -[[package]] -name = "anstream" -version = "0.6.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" - -[[package]] -name = "anstyle-parse" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" -dependencies = [ - "windows-sys 0.59.0", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" -dependencies = [ - "anstyle", - "once_cell", - "windows-sys 0.59.0", -] - [[package]] name = "anyhow" version = "1.0.94" @@ -449,52 +399,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "clap" -version = "4.5.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.5.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.5.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 2.0.90", -] - -[[package]] -name = "clap_lex" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" - -[[package]] -name = "colorchoice" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" - [[package]] name = "concurrent-queue" version = "2.5.0" @@ -1292,12 +1196,6 @@ dependencies = [ "similar", ] -[[package]] -name = "is_terminal_polyfill" -version = "1.70.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" - [[package]] name = "iso8601" version = "0.6.1" @@ -2505,7 +2403,6 @@ dependencies = [ "axum-jsonschema", "axum_typed_multipart", "chrono", - "clap", "log", "rand", "reconcile", @@ -2929,12 +2826,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" -[[package]] -name = "utf8parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" - [[package]] name = "uuid" version = "1.11.0" diff --git a/backend/Dockerfile b/backend/Dockerfile index ac0cee79..ced27dfb 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -13,7 +13,7 @@ RUN sqlx migrate run --source sync_server/src/database/migrations --database-url RUN cargo build --package sync_server --release --target x86_64-unknown-linux-musl # Runtime image -FROM alpine:3.21.0 +FROM alpine:3.21.3 LABEL org.opencontainers.image.authors="andras@schmelczer.dev" diff --git a/backend/config-e2e.yml b/backend/config.yml similarity index 76% rename from backend/config-e2e.yml rename to backend/config.yml index 2345c8b3..d8ccf20d 100644 --- a/backend/config-e2e.yml +++ b/backend/config.yml @@ -9,11 +9,5 @@ users: user_tokens: - name: admin token: test-token-change-me - vaults: - all: true - - name: test token: other-test-token - vaults: - allowed: - - default diff --git a/backend/sync_server/Cargo.toml b/backend/sync_server/Cargo.toml index 4b31cc1c..8b14c450 100644 --- a/backend/sync_server/Cargo.toml +++ b/backend/sync_server/Cargo.toml @@ -33,7 +33,6 @@ rand = "0.8.5" sanitize-filename = "0.6.0" axum-jsonschema = { version = "0.8.0", features = ["aide"] } regex = "1.11.1" -clap = { version = "4.5.32", features = ["derive"] } [lints] workspace = true diff --git a/backend/sync_server/src/cli.rs b/backend/sync_server/src/cli.rs deleted file mode 100644 index 6e10f4ad..00000000 --- a/backend/sync_server/src/cli.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod args; diff --git a/backend/sync_server/src/cli/args.rs b/backend/sync_server/src/cli/args.rs deleted file mode 100644 index 88ff1718..00000000 --- a/backend/sync_server/src/cli/args.rs +++ /dev/null @@ -1,38 +0,0 @@ -use std::ffi::OsString; - -use clap::{Parser, ValueEnum}; - -/// Server for backing the VaultLink plugin -#[derive(Parser, Debug)] -#[command(version, about, long_about = None)] -pub struct Args { - #[arg(index = 1)] - pub config_path: Option, - - #[arg( - long, - require_equals = true, - value_name = "WHEN", - num_args = 0..=1, - default_value_t = ColorWhen::Auto, - default_missing_value = "always", - value_enum - )] - pub color: ColorWhen, -} - -#[derive(ValueEnum, Copy, Clone, Debug, PartialEq, Eq)] -pub enum ColorWhen { - Always, - Auto, - Never, -} - -impl std::fmt::Display for ColorWhen { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.to_possible_value() - .expect("no values are skipped") - .get_name() - .fmt(f) - } -} diff --git a/backend/sync_server/src/consts.rs b/backend/sync_server/src/consts.rs index bec936b4..f38012de 100644 --- a/backend/sync_server/src/consts.rs +++ b/backend/sync_server/src/consts.rs @@ -1,4 +1,4 @@ -pub const DEFAULT_CONFIG_PATH: &str = "config.yml"; +pub const CONFIG_PATH: &str = "config.yml"; pub const DEFAULT_DATABASES_DIRECTORY_PATH: &str = "databases"; pub const DEFAULT_HOST: &str = "127.0.0.1"; pub const DEFAULT_PORT: u16 = 3000; diff --git a/backend/sync_server/src/main.rs b/backend/sync_server/src/main.rs index 2b8abccd..61f6f2af 100644 --- a/backend/sync_server/src/main.rs +++ b/backend/sync_server/src/main.rs @@ -1,4 +1,3 @@ -mod cli; mod config; mod consts; mod database; @@ -7,8 +6,6 @@ mod server; mod utils; use anyhow::{Context as _, Result}; -use clap::Parser; -use cli::args::Args; use errors::{SyncServerError, init_error}; use log::info; use server::create_server; @@ -16,8 +13,6 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; #[tokio::main] async fn main() -> Result<(), SyncServerError> { - let args = Args::parse(); - tracing_subscriber::registry() .with( tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| { @@ -38,7 +33,7 @@ async fn main() -> Result<(), SyncServerError> { env!("CARGO_PKG_VERSION") ); - create_server(args.config_path) + create_server() .await .context("Failed to start server") .map_err(init_error) diff --git a/backend/sync_server/src/server.rs b/backend/sync_server/src/server.rs index 083be5ba..511187e0 100644 --- a/backend/sync_server/src/server.rs +++ b/backend/sync_server/src/server.rs @@ -1,4 +1,4 @@ -use std::{ffi::OsString, sync::Arc}; +use std::sync::Arc; use aide::{ axum::{ @@ -48,11 +48,11 @@ mod requests; mod responses; mod update_document; -pub async fn create_server(config_path: Option) -> Result<()> { +pub async fn create_server() -> Result<()> { aide::r#gen::on_error(|err| error!("{err}")); aide::r#gen::extract_schemas(true); - let app_state = AppState::try_new(config_path) + let app_state = AppState::try_new() .await .context("Failed to initialise app state")?; diff --git a/backend/sync_server/src/server/app_state.rs b/backend/sync_server/src/server/app_state.rs index 2a8a96eb..0b02abcb 100644 --- a/backend/sync_server/src/server/app_state.rs +++ b/backend/sync_server/src/server/app_state.rs @@ -1,8 +1,6 @@ -use std::ffi::OsString; - use anyhow::Result; -use crate::{config::Config, consts::DEFAULT_CONFIG_PATH, database::Database}; +use crate::{config::Config, consts::CONFIG_PATH, database::Database}; #[derive(Clone, Debug)] pub struct AppState { @@ -11,11 +9,10 @@ pub struct AppState { } impl AppState { - pub async fn try_new(config_path: Option) -> Result { - let config_path = config_path.unwrap_or_else(|| OsString::from(DEFAULT_CONFIG_PATH)); - let path = std::path::PathBuf::from(config_path); + pub async fn try_new() -> Result { + let path = std::path::Path::new(CONFIG_PATH); - let config = Config::read_or_create(&path).await?; + let config = Config::read_or_create(path).await?; let database = Database::try_new(&config.database).await?; Ok(Self { config, database }) diff --git a/frontend/test-client/src/cli.ts b/frontend/test-client/src/cli.ts index 799ee790..4747f2af 100644 --- a/frontend/test-client/src/cli.ts +++ b/frontend/test-client/src/cli.ts @@ -27,7 +27,7 @@ async function runTest({ const initialSettings: Partial = { isSyncEnabled: true, - token: "test-token-change-me", // same as in backend/config-e2e.yml + token: "test-token-change-me", // same as in backend/config.yml vaultName: uuidv4(), syncConcurrency: concurrency, remoteUri: "http://localhost:3000"