New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support environment variable substitution #433
Conversation
20efd7e
to
cab3d45
Compare
3f9a97a
to
638987c
Compare
"description": "Comma separated list of headers to send with the request", | ||
"pattern": "([a-zA-Z0-9-]+: ?.+,)*([a-zA-Z0-9-]+: ?.+)", | ||
"examples": ["Authentication: digest 1234,Content-Type: application/json"] | ||
"description": "Comma separated list of headers to send with the request. May contain [variables](https://doc.arroyo.dev/connectors/variables).", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd expect this link to be something like "https://doc.arroyo.dev/connectors/overview#connection-formats" since we probably wouldn't want an entire doc page just to explain variable substitution
arroyo-types/src/lib.rs
Outdated
type Value = VarStr; | ||
|
||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
formatter.write_str("a string") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this forms the error message if deserialization fails. More details here.
arroyo-types/Cargo.toml
Outdated
@@ -8,3 +8,5 @@ bincode = "2.0.0-rc.3" | |||
serde = { version = "1.0", features = ["derive"] } | |||
arrow = { workspace = true } | |||
arrow-array = { workspace = true } | |||
regex = "1.10.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we try to avoid adding dependencies to arroyo-types since it's the base for everything — can this be moved elsewhere? For example, things that are needed by both api and the worker generally live in arroyo-rpc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done.
@@ -103,15 +104,15 @@ pub struct ConfluentSchemaRegistry { | |||
topic: String, | |||
client: Client, | |||
api_key: Option<String>, | |||
api_secret: Option<String>, | |||
api_secret: Option<VarStr>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure ConfluentSchemaRegistry should be aware of VarStr — maybe it makes more sense to have the resolution happen earlier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking was that we should try to delay variable substitution as long as possible, and do it just in time when it's needed. I think that pattern minimizes the risk that we accidentally log sensitive data.
@@ -72,12 +72,28 @@ where | |||
.map(|m| m.to_string()), | |||
); | |||
|
|||
let headers = string_to_map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we abstract this code out into a method so we don't have to repeat it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done.
In the Kafka, Polling HTTP, WebSocket, and SSE sources, support environment variables in the passwords, secrets, and headers fields. This is done by setting the format of the field in the JSON schema to 'var-str', which tells typify to replace the type with the VarStr struct, which has a function for substituting environment variables. The VarStr struct serializes/deserializes from a JSON string.
In the Kafka, Polling HTTP, WebSocket, and SSE sources, support environment variables in the passwords, secrets, and headers fields.
This is done by setting the
format
of the field in the JSON schema tovar-str
, which tells typify to replace the type with theVarStr
struct, which has a function for substituting environment variables. TheVarStr
struct serializes/deserializes from a JSON string.If the variable is needed for testing the connection and it's missing, it'll look like this:
And in SQL it looks like this: