Merge branch 'dev' of github.com:C0ffeeCode/rvault into dev
This commit is contained in:
commit
7f67ac0107
6 changed files with 51 additions and 37 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
|
@ -260,9 +260,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.95"
|
||||
version = "1.0.96"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b"
|
||||
checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
|
|
@ -585,9 +585,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
|
|||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.3"
|
||||
version = "0.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
|
||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"allocator-api2",
|
||||
|
|
@ -827,9 +827,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.153"
|
||||
version = "0.2.154"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
|
|
@ -1449,9 +1449,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
|||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.5.6"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871"
|
||||
checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@ WORKDIR /src
|
|||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY *.go ./
|
||||
RUN go build -o /app
|
||||
COPY . .
|
||||
# RUN go build -o /app
|
||||
CMD go test tests/*
|
||||
|
||||
FROM docker.io/library/alpine:3.19
|
||||
# FROM docker.io/library/alpine:3.19
|
||||
|
||||
COPY --from=builder /app /app
|
||||
CMD ["/app"]
|
||||
# COPY --from=builder /app /app
|
||||
# CMD ["/app"]
|
||||
|
|
|
|||
6
migrations/20240428160456_init.sql
Normal file
6
migrations/20240428160456_init.sql
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-- Add migration script here
|
||||
|
||||
CREATE TABLE secret_engines (
|
||||
mount_point TEXT PRIMARY KEY NOT NULL,
|
||||
engine_type TEXT NOT NULL
|
||||
);
|
||||
|
|
@ -9,18 +9,18 @@ pub fn kv_router() -> Router {
|
|||
Router::new()
|
||||
.route("/:mount_path/config", get(get_config))
|
||||
.route("/:mount_path/config", post(post_config))
|
||||
.route("/:mount_path/data/:path", get(get_data))
|
||||
.route("/:mount_path/data/:path/", get(get_data))
|
||||
.route("/:mount_path/data/:path", get(post_data))
|
||||
.route("/:mount_path/data/:path", delete(delete_data))
|
||||
.route("/:mount_path/delete/:path", post(delete_path))
|
||||
.route("/:mount_path/destroy/:path", post(destroy_path))
|
||||
.route("/:mount_path/metadata/:path", get(get_meta))
|
||||
.route("/:mount_path/metadata/:path/", get(get_meta))
|
||||
.route("/:mount_path/metadata/:path", post(post_meta))
|
||||
.route("/:mount_path/metadata/:path", delete(delete_meta))
|
||||
.route("/:mount_path/subkeys/:path", get(get_subkeys))
|
||||
.route("/:mount_path/undelete/:path", post(post_undelete))
|
||||
.route("/:mount_path/data/*path", get(get_data))
|
||||
// .route("/:mount_path/data/*path/", get(get_data))
|
||||
.route("/:mount_path/data/*path", post(post_data))
|
||||
.route("/:mount_path/data/*path", delete(delete_data))
|
||||
.route("/:mount_path/delete/*path", post(delete_path))
|
||||
.route("/:mount_path/destroy/*path", post(destroy_path))
|
||||
.route("/:mount_path/metadata/*path", get(get_meta))
|
||||
// .route("/:mount_path/metadata/*path/", get(get_meta))
|
||||
.route("/:mount_path/metadata/*path", post(post_meta))
|
||||
.route("/:mount_path/metadata/*path", delete(delete_meta))
|
||||
.route("/:mount_path/subkeys/*path", get(get_subkeys))
|
||||
.route("/:mount_path/undelete/*path", post(post_undelete))
|
||||
}
|
||||
|
||||
async fn get_config() -> &'static str {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
use axum::{
|
||||
extract::Request, http::StatusCode, routing::get, Router
|
||||
};
|
||||
use axum::{extract::Request, http::StatusCode, routing::get, Router};
|
||||
use log::*;
|
||||
use sqlx::{Any, Pool};
|
||||
use tokio::net::TcpListener;
|
||||
use std::{env, net::SocketAddr, str::FromStr};
|
||||
use tokio::net::TcpListener;
|
||||
|
||||
use crate::storage::create_pool;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,27 @@
|
|||
use sqlx::{
|
||||
any::{install_default_drivers, AnyPoolOptions},
|
||||
AnyPool,
|
||||
};
|
||||
use std::{fs::File, path::Path};
|
||||
|
||||
pub async fn create_pool(connection_string: String) -> AnyPool {
|
||||
use log::*;
|
||||
use sqlx::{any::AnyPoolOptions, AnyPool};
|
||||
|
||||
pub async fn create_pool(db_url: String) -> AnyPool {
|
||||
// TODO: Change to solely install applicable driver
|
||||
install_default_drivers();
|
||||
sqlx::any::install_default_drivers();
|
||||
|
||||
// Create SQLite database file if it does not exist
|
||||
if db_url.starts_with("sqlite:") {
|
||||
let path = db_url.replace("sqlite:", "");
|
||||
if !Path::new(&path).exists() {
|
||||
warn!("Sqlite database does not exist, creating file {}", path);
|
||||
File::create(&path).expect("Failed to create database file");
|
||||
}
|
||||
}
|
||||
|
||||
let pool = AnyPoolOptions::new()
|
||||
.max_connections(5)
|
||||
.test_before_acquire(true)
|
||||
.connect(&connection_string)
|
||||
.connect(&db_url)
|
||||
.await
|
||||
.expect(&connection_string);
|
||||
.expect(&db_url);
|
||||
|
||||
pool
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue