diff --git a/Cargo.lock b/Cargo.lock index 311b98f1..d44ea8fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1071,7 +1071,6 @@ dependencies = [ "axum", "axum-extra", "axum-test-helper", - "base64 0.21.5", "bytes", "clap", "gdc_rust_types", @@ -1089,7 +1088,6 @@ dependencies = [ "opentelemetry_sdk", "prometheus", "reqwest", - "schemars", "serde", "serde_json", "thiserror", diff --git a/rust-connector-sdk/.gitignore b/rust-connector-sdk/.gitignore deleted file mode 100644 index ea8c4bf7..00000000 --- a/rust-connector-sdk/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/rust-connector-sdk/Cargo.toml b/rust-connector-sdk/Cargo.toml index dd2ebf48..9d74a70c 100644 --- a/rust-connector-sdk/Cargo.toml +++ b/rust-connector-sdk/Cargo.toml @@ -19,7 +19,6 @@ ndc-test = { git = "http://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.18" async-trait = "^0.1.74" axum = "^0.6.20" axum-extra = "^0.8.0" -base64 = "0.21.5" bytes = "1.5.0" clap = { version = "^4.4.7", features = ["derive", "env"] } http = "^0.2" @@ -33,7 +32,6 @@ opentelemetry_api = "^0.20.0" opentelemetry_sdk = "^0.20.0" prometheus = "^0.13.3" reqwest = "^0.11.22" -schemars = { version = "^0.8.16", features = ["smol_str"] } serde = { version = "^1.0.192", features = ["derive"] } serde_json = { version = "^1.0.108", features = ["raw_value"] } thiserror = "^1.0" diff --git a/rust-connector-sdk/src/lib.rs b/rust-connector-sdk/src/lib.rs index aec462cd..5a1f3d2e 100644 --- a/rust-connector-sdk/src/lib.rs +++ b/rust-connector-sdk/src/lib.rs @@ -4,7 +4,6 @@ pub mod default_main; pub mod json_rejection; pub mod json_response; pub mod routes; -pub mod secret; pub mod tracing; pub use ndc_client::models; diff --git a/rust-connector-sdk/src/secret.rs b/rust-connector-sdk/src/secret.rs deleted file mode 100644 index 14bd0f80..00000000 --- a/rust-connector-sdk/src/secret.rs +++ /dev/null @@ -1,71 +0,0 @@ -use schemars::{schema::Schema, JsonSchema}; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)] -#[serde(rename_all = "camelCase")] -#[schemars(title = "SecretValue")] -/// Either a literal string or a reference to a Hasura secret -pub enum SecretValueImpl { - Value(String), - StringValueFromSecret(String), -} - -/// Use this type to refer to secret strings within a -/// connector's configuration types. For example, a connection -/// string which might contain a password should be configured -/// using this type. -/// -/// This marker type indicates that a value should be configured -/// from secrets drawn from a secret store. -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct SecretValue(pub SecretValueImpl); - -impl JsonSchema for SecretValue { - fn schema_name() -> String { - SecretValueImpl::schema_name() - } - - fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { - let mut s = SecretValueImpl::json_schema(gen); - if let Schema::Object(o) = &mut s { - if let Some(m) = &mut o.metadata { - m.id = Some(Self::schema_id().into()); - } - } - s - } - - fn schema_id() -> std::borrow::Cow<'static, str> { - "https://hasura.io/jsonschemas/SecretValue".into() - } -} - -#[cfg(test)] -mod tests { - use goldenfile::Mint; - use schemars::schema_for; - use std::io::Write; - use std::path::PathBuf; - - use super::SecretValue; - - #[test] - pub fn test_json_schema() { - let test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests"); - - let mut mint = Mint::new(test_dir); - - let expected_path = PathBuf::from_iter(["json_schema", "secret_value.jsonschema"]); - - let mut expected = mint.new_goldenfile(expected_path).unwrap(); - - let schema = schema_for!(SecretValue); - - write!( - expected, - "{}", - serde_json::to_string_pretty(&schema).unwrap() - ) - .unwrap(); - } -} diff --git a/rust-connector-sdk/tests/json_schema/secret_value.jsonschema b/rust-connector-sdk/tests/json_schema/secret_value.jsonschema deleted file mode 100644 index 7c5b0c38..00000000 --- a/rust-connector-sdk/tests/json_schema/secret_value.jsonschema +++ /dev/null @@ -1,32 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://hasura.io/jsonschemas/SecretValue", - "title": "SecretValue", - "description": "Either a literal string or a reference to a Hasura secret", - "oneOf": [ - { - "type": "object", - "required": [ - "value" - ], - "properties": { - "value": { - "type": "string" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "stringValueFromSecret" - ], - "properties": { - "stringValueFromSecret": { - "type": "string" - } - }, - "additionalProperties": false - } - ] -} \ No newline at end of file