From be4e698d61b0ab2954d5b410bd9079b450c4be6c Mon Sep 17 00:00:00 2001 From: C0ffeeCode Date: Wed, 1 May 2024 20:04:21 +0200 Subject: [PATCH] tada --- .gitignore | 4 +++- go_client/Containerfile | 1 + go_client/tests/secret_test.go | 3 ++- migrations/20240428160456_init.sql | 2 ++ src/storage.rs | 5 +++++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a76edee..2d669dc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,10 @@ .vs/ .vscode/ .idea/ +.env *.pdf target/ go_client/openapi.json -crates/storage-sled/sled_db \ No newline at end of file +crates/storage-sled/sled_db +test.db diff --git a/go_client/Containerfile b/go_client/Containerfile index 6cbe75f..90ca186 100644 --- a/go_client/Containerfile +++ b/go_client/Containerfile @@ -7,6 +7,7 @@ RUN go mod download COPY . . # RUN go build -o /app +RUN go build CMD go test tests/* # FROM docker.io/library/alpine:3.19 diff --git a/go_client/tests/secret_test.go b/go_client/tests/secret_test.go index af50611..21cc769 100644 --- a/go_client/tests/secret_test.go +++ b/go_client/tests/secret_test.go @@ -13,7 +13,8 @@ import ( var client *vault.Client var ctx context.Context -var mountpath = "" +// Apparently used as a default if mountpath is an empty string (client library) +var mountpath = "/kv-v2" func TestMain(m *testing.M) { ctx = context.Background() diff --git a/migrations/20240428160456_init.sql b/migrations/20240428160456_init.sql index 91d683d..95f17bd 100644 --- a/migrations/20240428160456_init.sql +++ b/migrations/20240428160456_init.sql @@ -4,3 +4,5 @@ CREATE TABLE secret_engines ( mount_point TEXT PRIMARY KEY NOT NULL, engine_type TEXT NOT NULL ); + +INSERT INTO secret_engines (mount_point, engine_type) VALUES ('/kv-v2', 'kv'); diff --git a/src/storage.rs b/src/storage.rs index 4a46653..062e055 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -23,5 +23,10 @@ pub async fn create_pool(db_url: String) -> AnyPool { .await .expect(&db_url); + sqlx::migrate!() + .run(&pool) + .await + .expect("Failed to apply migrations"); + pool }