Allow setting PAD_API_KEY from command-line or env? #8

Closed
opened 2 years ago by decentral1se · 0 comments
Owner

Then we can override b384354e95/config.py (L6) without having to edit the file? It might also be nice to create an error check if the key is not set & error out with an explanatory message?

I did:

diff --git a/config.py b/config.py
index eca98cd..d63c027 100644
--- a/config.py
+++ b/config.py
@@ -1,6 +1,8 @@
+import os
+
 class Config(object):
        APPLICATION_ROOT = '/'
        PORTNUMBER = 5001
        PAD_URL = 'https://pad.vvvvvvaria.org/' # with a slash in the end!
        PAD_API_URL = 'https://pad.vvvvvvaria.org/api/1.2.15/'
-       PAD_API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
+       PAD_API_KEY = os.environ.get('OCTOMODE_PAD_API_KEY', '')

And then:

export OCTOMODE_PAD_API_KEY=...; make run
Then we can override https://git.vvvvvvaria.org/varia/octomode/src/commit/b384354e95200b2f2baa76681536387ddbde22bc/config.py#L6 without having to edit the file? It might also be nice to create an error check if the key is not set & error out with an explanatory message? I did: ```diff diff --git a/config.py b/config.py index eca98cd..d63c027 100644 --- a/config.py +++ b/config.py @@ -1,6 +1,8 @@ +import os + class Config(object): APPLICATION_ROOT = '/' PORTNUMBER = 5001 PAD_URL = 'https://pad.vvvvvvaria.org/' # with a slash in the end! PAD_API_URL = 'https://pad.vvvvvvaria.org/api/1.2.15/' - PAD_API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' + PAD_API_KEY = os.environ.get('OCTOMODE_PAD_API_KEY', '') ``` And then: ``` export OCTOMODE_PAD_API_KEY=...; make run ```
decentral1se referenced this issue from a commit 2 years ago
decentral1se closed this issue 2 years ago
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.