From 0fcf8b87355215e843ae2a7afb781703046bdb40 Mon Sep 17 00:00:00 2001 From: Andrew Korzhuev Date: Fri, 8 Sep 2023 19:43:41 +0200 Subject: [PATCH] api: remove openssl dep. split publishing --- .github/workflows/publish.yml | 45 -------------------------- .github/workflows/publish_api.yml | 24 ++++++++++++++ .github/workflows/publish_jwt.yml | 24 ++++++++++++++ jwt/Cargo.toml | 2 +- snowflake-api/Cargo.toml | 8 ++--- snowflake-api/examples/filetransfer.rs | 2 +- snowflake-api/examples/run_sql.rs | 2 +- snowflake-api/src/lib.rs | 2 +- snowflake-api/src/session.rs | 6 ++-- 9 files changed, 59 insertions(+), 56 deletions(-) delete mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/publish_api.yml create mode 100644 .github/workflows/publish_jwt.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index d106451..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,45 +0,0 @@ -on: - push: - tags: - - '*' - workflow_dispatch: - -name: Publish - -jobs: - - publish-jwt: - name: Publish Snowflake JWT - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v2 - - - name: stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - - run: cargo publish -p snowflake-jwt - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - - publish-api: - name: Publish Snowflake API - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v2 - - - name: stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - - run: cargo publish -p snowflake-api - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/publish_api.yml b/.github/workflows/publish_api.yml new file mode 100644 index 0000000..009c26b --- /dev/null +++ b/.github/workflows/publish_api.yml @@ -0,0 +1,24 @@ +on: + workflow_dispatch: + +name: Publish API + +jobs: + + publish-api: + name: Publish Snowflake API + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + + - name: stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - run: cargo publish -p snowflake-api + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/publish_jwt.yml b/.github/workflows/publish_jwt.yml new file mode 100644 index 0000000..072182a --- /dev/null +++ b/.github/workflows/publish_jwt.yml @@ -0,0 +1,24 @@ +on: + workflow_dispatch: + +name: Publish JWT + +jobs: + + publish-jwt: + name: Publish Snowflake JWT + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + + - name: stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - run: cargo publish -p snowflake-jwt + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/jwt/Cargo.toml b/jwt/Cargo.toml index 1a36323..e8043e9 100644 --- a/jwt/Cargo.toml +++ b/jwt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "snowflake-jwt" -version = "0.1.1" +version = "0.3.0" edition = "2021" description = "Snowflake JWT token generator" authors = ["Andrew Korzhuev ", "Artem Semenov "] diff --git a/snowflake-api/Cargo.toml b/snowflake-api/Cargo.toml index 2b7f933..9b88655 100644 --- a/snowflake-api/Cargo.toml +++ b/snowflake-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "snowflake-api" -version = "0.2.0" +version = "0.3.0" edition = "2021" description = "Snowflake API bindings" authors = ["Andrew Korzhuev "] @@ -13,8 +13,8 @@ license = "Apache-2.0" [dependencies] thiserror = "1" -snowflake-jwt = "0.1.1" -reqwest = { version = "0.11", features = ["json"] } +snowflake-jwt = "0.3.0" +reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "json"] } reqwest-middleware = "0.2" reqwest-retry = "0.2" log = "0.4" @@ -33,4 +33,4 @@ anyhow = "1" pretty_env_logger = "0.5.0" clap = { version = "4", features = ["derive"] } arrow = { version = "42", features = ["prettyprint"] } -tokio = { version = "1", features=["macros", "rt-multi-thread"] } +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } diff --git a/snowflake-api/examples/filetransfer.rs b/snowflake-api/examples/filetransfer.rs index 811c49e..841630b 100644 --- a/snowflake-api/examples/filetransfer.rs +++ b/snowflake-api/examples/filetransfer.rs @@ -53,7 +53,7 @@ async fn main() -> Result<()> { let mut api = match (&args.private_key, &args.password) { (Some(pkey), None) => { - let pem = fs::read(pkey)?; + let pem = fs::read_to_string(pkey)?; SnowflakeApi::with_certificate_auth( &args.account_identifier, &args.warehouse, diff --git a/snowflake-api/examples/run_sql.rs b/snowflake-api/examples/run_sql.rs index c0aab66..52da49f 100644 --- a/snowflake-api/examples/run_sql.rs +++ b/snowflake-api/examples/run_sql.rs @@ -66,7 +66,7 @@ async fn main() -> Result<()> { let mut api = match (&args.private_key, &args.password) { (Some(pkey), None) => { - let pem = fs::read(pkey)?; + let pem = fs::read_to_string(pkey)?; SnowflakeApi::with_certificate_auth( &args.account_identifier, &args.warehouse, diff --git a/snowflake-api/src/lib.rs b/snowflake-api/src/lib.rs index 25e81a6..a23561d 100644 --- a/snowflake-api/src/lib.rs +++ b/snowflake-api/src/lib.rs @@ -134,7 +134,7 @@ impl SnowflakeApi { schema: Option<&str>, username: &str, role: Option<&str>, - private_key_pem: &[u8], + private_key_pem: &str, ) -> Result { let connection = Arc::new(Connection::new()?); diff --git a/snowflake-api/src/session.rs b/snowflake-api/src/session.rs index db1274e..2d3d0a4 100644 --- a/snowflake-api/src/session.rs +++ b/snowflake-api/src/session.rs @@ -103,7 +103,7 @@ pub struct Session { username: String, role: Option, - private_key_pem: Option>, + private_key_pem: Option, password: Option, } @@ -120,7 +120,7 @@ impl Session { schema: Option<&str>, username: &str, role: Option<&str>, - private_key_pem: &[u8], + private_key_pem: &str, ) -> Self { // uppercase everything as this is the convention let account_identifier = account_identifier.to_uppercase(); @@ -131,7 +131,7 @@ impl Session { let username = username.to_uppercase(); let role = role.map(str::to_uppercase); - let private_key_pem = Some(private_key_pem.to_vec()); + let private_key_pem = Some(private_key_pem.to_string()); Session { connection,