zulip / python-zulip-api

Python library for the Zulip API.
https://zulip.com/api/
Apache License 2.0
361 stars 362 forks source link

Allow passing config via environment variables to zulip-botserver #485

Closed pirate closed 3 years ago

pirate commented 5 years ago

Component: zulip-botserver Package: https://pypi.org/project/zulip-botserver/ Code: https://github.com/zulip/python-zulip-api/tree/master/zulip_botserver

Instead of requiring that config be passed as a file with the --config-file option, it would be great if we could pass config via environment variables. This would make our secure key storage system much easier, as right now we use env variables to pass down secure keys to containers, and creating a config file to store them on disk is suboptimal.

[helloworld]
email=foo-bot@hostname
key=dOHHlyqgpt5g0tVuVl6NHxDLlc9eFRX4
site=http://hostname
token=aQVQmSd6j6IHphJ9m1jhgHdbnhl5ZcsY

Becomes:

env BOT_EMAIL=foo-bot@hostname BOT_KEY=abc... BOT_SITE=https://hostname BOT_TOKEN=abc... zulip-botserver

I would require adding ~20 LOC to https://github.com/zulip/python-zulip-api/blob/master/zulip_botserver/zulip_botserver/server.py, if this proposal sounds reasonable, I can probably submit a PR for it myself without too much difficulty.

timabbott commented 5 years ago

Allowing environment variables here seems reasonable. We already support them for the main Python API bindings. See the os.environ stuff in python-zulip-api/zulip/zulip/__init__.py; we can potentially extract some of that as a function or something to reuse.

zbenjamin commented 5 years ago

@zulipbot claim

zbenjamin commented 5 years ago

Ah, I think I mis-read this issue. It looks like @showell implemented this in #491. I thought this issue was about being able to specify a config file via an environment variable. This is useful so that one can easily run a bot server with multiple bots in an environment like Heroku while also using a production web server like gunicorn.

showell commented 5 years ago

@zbenjamin My changes were for the standalone config. We probably need to fix botserver the same way.

zulipbot commented 5 years ago

Hello @zbenjamin, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.

You can reclaim this issue or claim any other issue by commenting @zulipbot claim on that issue.

Thanks for your contributions, and hope to see you again soon!

Aadi-0110 commented 4 years ago

@zulipbot claim

zulipbot commented 4 years ago

Welcome to Zulip, @Aadi-0110! We just sent you an invite to collaborate on this repository at https://github.com/zulip/python-zulip-api/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!

Here's some tips to get you off to a good start:

As you work on this issue, you'll also want to refer to the Zulip code contribution guide, as well as the rest of the developer documentation on that site.

See you on the other side (that is, the pull request side)!

LoopThrough-i-j commented 4 years ago

@zulipbot claim

zulipbot commented 4 years ago

Welcome to Zulip, @LoopThrough-i-j! We just sent you an invite to collaborate on this repository at https://github.com/zulip/python-zulip-api/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!

Here's some tips to get you off to a good start:

As you work on this issue, you'll also want to refer to the Zulip code contribution guide, as well as the rest of the developer documentation on that site.

See you on the other side (that is, the pull request side)!