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

Closed
opened 2022-04-08 16:30:16 +02:00 by decentral1se · 0 comments
Collaborator

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 ```
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: CC/octomode#8
No description provided.