diff --git a/CloudFlare/read_configs.py b/CloudFlare/read_configs.py index 653c63a..a222b7e 100644 --- a/CloudFlare/read_configs.py +++ b/CloudFlare/read_configs.py @@ -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() @@ -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: diff --git a/README.md b/README.md index 9f8116e..46a8e8c 100644 --- a/README.md +++ b/README.md @@ -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-... @@ -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 diff --git a/README.rst b/README.rst index 49b0232..10c4558 100644 --- a/README.rst +++ b/README.rst @@ -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-... @@ -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