Skip to content

Commit

Permalink
cloudflare#136 pointed out that the config file profile name has a ca…
Browse files Browse the repository at this point in the history
…pital F in it. Now it takes lower case "f" value
  • Loading branch information
mahtin committed Mar 30, 2022
1 parent da1645c commit cbeee2c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
16 changes: 13 additions & 3 deletions CloudFlare/read_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ def read_configs(profile=None):
config['certtoken'] = os.getenv('CLOUDFLARE_API_CERTKEY') if os.getenv('CLOUDFLARE_API_CERTKEY') != None else os.getenv('CF_API_CERTKEY')
config['extras'] = os.getenv('CLOUDFLARE_API_EXTRAS') if os.getenv('CLOUDFLARE_API_EXTRAS') != None else os.getenv('CF_API_EXTRAS')
config['base_url'] = os.getenv('CLOUDFLARE_API_URL') if os.getenv('CLOUDFLARE_API_URL') != None else os.getenv('CF_API_URL')
if profile is None:
profile = 'CloudFlare'
config['profile'] = profile

# grab values from config files
cp = configparser.ConfigParser()
Expand All @@ -34,6 +31,19 @@ def read_configs(profile=None):
except Exception as e:
raise Exception("%s: configuration file error" % (profile))

# Is it CloudFlare or Cloudflare? (A legacy issue)
if profile is None:
if len(cp.sections()) > 0:
if 'CloudFlare' in cp:
profile = 'CloudFlare'
if 'Cloudflare' in cp:
profile = 'Cloudflare'

## still not found - then set to to CloudFlare for legacy reasons
if profile == None:
profile = "CloudFlare"
config['profile'] = profile

if len(cp.sections()) > 0:
# we have a configuration file - lets use it
try:
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,11 @@ These are optional environment variables; however, they do override the values s

### Using configuration file to store email and keys

The default profile name is `Cloudflare` for obvious reasons.

```bash
$ cat ~/.cloudflare/cloudflare.cfg
[CloudFlare]
[Cloudflare]
email = user@example.com # Do not set if using an API Token
token = 00000000000000000000000000000000
certtoken = v1.0-...
Expand Down Expand Up @@ -1127,7 +1129,7 @@ An automatically generated table of commands is provided [here](TABLE-OF-COMMAND
Extra API calls can be added via the configuration file
```bash
$ cat ~/.cloudflare/cloudflare.cfg
[CloudFlare]
[Cloudflare]
extras =
/client/v4/command
/client/v4/command/:command_identifier
Expand Down
6 changes: 4 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,12 @@ These are optional environment variables; however, they do override the values s
Using configuration file to store email and keys
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The default profile name is ``Cloudflare`` for obvious reasons.

.. code:: bash

$ cat ~/.cloudflare/cloudflare.cfg
[CloudFlare]
[Cloudflare]
email = user@example.com # Do not set if using an API Token
token = 00000000000000000000000000000000
certtoken = v1.0-...
Expand Down Expand Up @@ -1143,7 +1145,7 @@ Extra API calls can be added via the configuration file
.. code:: bash

$ cat ~/.cloudflare/cloudflare.cfg
[CloudFlare]
[Cloudflare]
extras =
/client/v4/command
/client/v4/command/:command_identifier
Expand Down

0 comments on commit cbeee2c

Please sign in to comment.