Skip to content

Commit

Permalink
fixed #452 - native MySQL and Postgres support
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Nov 2, 2022
1 parent 1ed386c commit c236da5
Show file tree
Hide file tree
Showing 17 changed files with 251 additions and 54 deletions.
160 changes: 159 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN cd /opt/warpgate \
&& just yarn \
&& just openapi \
&& just yarn build \
&& cargo build --release
&& cargo build --features mysql,postgres --release

FROM debian:bullseye-20221024
LABEL maintainer=heywoodlh
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
projects := "warpgate warpgate-admin warpgate-common warpgate-db-entities warpgate-db-migrations warpgate-database-protocols warpgate-protocol-ssh warpgate-protocol-mysql warpgate-protocol-http warpgate-core warpgate-sso"

run *ARGS:
RUST_BACKTRACE=1 RUST_LOG=warpgate cd warpgate && cargo run -- --config ../config.yaml {{ARGS}}
RUST_BACKTRACE=1 RUST_LOG=warpgate cargo run -- --config config.yaml {{ARGS}}

fmt:
for p in {{projects}}; do cargo fmt -p $p -v; done
Expand Down
1 change: 0 additions & 1 deletion warpgate-admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ poem-openapi = { version = "^2.0.10", features = [
russh-keys = { version = "0.22.0-beta.4", features = ["openssl"] }
rust-embed = "6.3"
sea-orm = { version = "^0.9", features = [
"sqlx-sqlite",
"runtime-tokio-native-tls",
"macros",
], default-features = false }
Expand Down
1 change: 0 additions & 1 deletion warpgate-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ rand = "0.8"
rand_chacha = "0.3"
rand_core = { version = "0.6", features = ["std"] }
sea-orm = { version = "^0.9", features = [
"sqlx-sqlite",
"runtime-tokio-native-tls",
"macros",
], default-features = false }
Expand Down
6 changes: 5 additions & 1 deletion warpgate-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ rand = "0.8"
rand_chacha = "0.3"
rand_core = { version = "0.6", features = ["std"] }
sea-orm = { version = "^0.9", features = [
"sqlx-sqlite",
"runtime-tokio-native-tls",
"macros",
], default-features = false }
Expand All @@ -50,3 +49,8 @@ warpgate-sso = { version = "*", path = "../warpgate-sso" }
rustls = { version = "0.20", features = ["dangerous_configuration"] }
rustls-pemfile = "1.0"
webpki = "0.22"

[features]
postgres = ["sea-orm/sqlx-postgres"]
mysql = ["sea-orm/sqlx-mysql"]
sqlite = ["sea-orm/sqlx-sqlite"]
1 change: 0 additions & 1 deletion warpgate-core/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub async fn connect_to_db(config: &WarpgateConfig) -> Result<DatabaseConnection

let db = Database::connect(ConnectOptions::new(url.to_string())).await?;
db.begin().await?.commit().await?;
drop(db);

secure_file(&abs_path)?;
}
Expand Down
13 changes: 9 additions & 4 deletions warpgate-db-entities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ name = "warpgate-db-entities"
version = "0.6.4"

[dependencies]
chrono = {version = "0.4", features = ["serde"]}
poem-openapi = {version = "^2.0.10", features = ["chrono", "uuid"]}
sea-orm = {version = "^0.9", features = ["macros", "with-chrono", "with-uuid", "with-json"], default-features = false}
chrono = { version = "0.4", features = ["serde"] }
poem-openapi = { version = "^2.0.10", features = ["chrono", "uuid"] }
sea-orm = { version = "^0.9", features = [
"macros",
"with-chrono",
"with-uuid",
"with-json",
], default-features = false }
serde = "1.0"
serde_json = "1.0"
uuid = {version = "1.0", features = ["v4", "serde"]}
uuid = { version = "1.0", features = ["v4", "serde"] }
warpgate-common = { version = "*", path = "../warpgate-common" }
2 changes: 1 addition & 1 deletion warpgate-db-entities/src/TargetRoleAssignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use uuid::Uuid;
#[sea_orm(table_name = "target_roles")]
#[oai(rename = "TargetRoleAssignment")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
#[sea_orm(primary_key, auto_increment = true)]
pub id: u32,
pub target_id: Uuid,
pub role_id: Uuid,
Expand Down
Loading

0 comments on commit c236da5

Please sign in to comment.