-
Notifications
You must be signed in to change notification settings - Fork 77
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
Read Zulip config from env vars #1872
Conversation
@@ -71,8 +75,6 @@ struct Response { | |||
content: String, | |||
} | |||
|
|||
pub const BOT_EMAIL: &str = "[email protected]"; |
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 wanted to also set this global but then it needs to be cloned multiple times, so unsure what's the best solution
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 I see the concern about needing to be cloned. If you do it in a LazyLock like you did the URL, then you can do &*ZULIP_BOT_EMAIL
to get a reference. The basic_auth
method does not need an owned value.
An alternative would be to place all these environment values inside a structure stored in the Context
, and just pass that around as an argument (or pass in the whole Context).
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.
thank you for a second opinion! I've amended the code with just adding another LazyLock to keep changes as contained here as possible.
e8e9941
to
c096e57
Compare
c096e57
to
ec08941
Compare
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.
Thanks!
thanks @ehuss ! |
Sometimes we want to test the triagebot against a test Zulip instance (f.e. #1853) but currently the Zulip config is hardcoded. This patch allows settings env vars to use a custom Zulip instance. If these env vars are not set, the triagebot will work as usual and connect to the production Zulip instance.
I've tested this with a binary that I didn't include in the repository, it simply uses the public api is
zulip.rs
:code
maybe r? @ehuss (or anyone who has time for a review)