Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 44d7d65

Browse files
committed
update environment variables to be prefixed with CLOUDFLARE_
Updates all references and usage of environment variables from `CF_` prefix to `CLOUDFLARE_` should they be present. This follows suit of the other SDKs and tooling in the Cloudflare ecosystem allowing reuse of credentials between them all. A full prefix was chosen to avoid conflicts and potential leaking of details between other tools that use the `CF_` prefix. Eventually, we will aim to deprecate the `CF_` lookups entirely but for now, just prefer them if they are present.
1 parent 4c80399 commit 44d7d65

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

CloudFlare/read_configs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def read_configs(profile=None):
1414
config = {'email': None, 'token': None, 'certtoken': None, 'extras': None, 'base_url': None, 'profile': None}
1515

1616
# envioronment variables override config files - so setup first
17-
config['email'] = os.getenv('CF_API_EMAIL')
18-
config['token'] = os.getenv('CF_API_KEY')
19-
config['certtoken'] = os.getenv('CF_API_CERTKEY')
20-
config['extras'] = os.getenv('CF_API_EXTRAS')
21-
config['base_url'] = os.getenv('CF_API_URL')
17+
config['email'] = os.getenv('CLOUDFLARE_EMAIL') if os.getenv('CLOUDFLARE_EMAIL') != None else os.getenv('CF_API_EMAIL')
18+
config['token'] = os.getenv('CLOUDFLARE_API_KEY') if os.getenv('CLOUDFLARE_API_KEY') != None else os.getenv('CF_API_KEY')
19+
config['certtoken'] = os.getenv('CLOUDFLARE_API_CERTKEY') if os.getenv('CLOUDFLARE_API_CERTKEY') != None else os.getenv('CF_API_CERTKEY')
20+
config['extras'] = os.getenv('CLOUDFLARE_API_EXTRAS') if os.getenv('CLOUDFLARE_API_EXTRAS') != None os.getenv('CF_API_EXTRAS')
21+
config['base_url'] = os.getenv('CLOUDFLARE_API_URL') if os.getenv('CLOUDFLARE_API_URL') != None os.getenv('CF_API_URL')
2222
if profile is None:
2323
profile = 'CloudFlare'
2424
config['profile'] = profile

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,16 @@ import CloudFlare
202202

203203
If the account email and API key are not passed when you create the class, then they are retrieved from either the users exported shell environment variables or the .cloudflare.cfg or ~/.cloudflare.cfg or ~/.cloudflare/cloudflare.cfg files, in that order.
204204

205-
If you're using an API Token, any `cloudflare.cfg` file must either not contain an `email` attribute or be a zero length string and the `CF_API_EMAIL` environment variable must be unset or be a zero length string, otherwise the token will be treated as a key and will throw an error.
205+
If you're using an API Token, any `cloudflare.cfg` file must either not contain an `email` attribute or be a zero length string and the `CLOUDFLARE_EMAIL` environment variable must be unset or be a zero length string, otherwise the token will be treated as a key and will throw an error.
206206

207207
There is one call that presently doesn't need any email or token certification (the */ips* call); hence you can test without any values saved away.
208208

209209
### Using shell environment variables
210210

211211
```bash
212-
$ export CF_API_EMAIL='user@example.com' # Do not set if using an API Token
213-
$ export CF_API_KEY='00000000000000000000000000000000'
214-
$ export CF_API_CERTKEY='v1.0-...'
212+
$ export CLOUDFLARE_EMAIL='user@example.com' # Do not set if using an API Token
213+
$ export CLOUDFLARE_API_KEY='00000000000000000000000000000000'
214+
$ export CLOUDFLARE_API_CERTKEY='v1.0-...'
215215
$
216216
```
217217

@@ -297,7 +297,7 @@ This can be used with email values also.
297297

298298
### About /certificates and certtoken
299299

300-
The *CF_API_CERTKEY* or *certtoken* values are used for the Origin-CA */certificates* API calls.
300+
The *CLOUDFLARE_API_CERTKEY* or *certtoken* values are used for the Origin-CA */certificates* API calls.
301301
You can leave *certtoken* in the configuration with a blank value (or omit the option variable fully).
302302

303303
The *extras* values are used when adding API calls outside of the core codebase.
@@ -426,7 +426,7 @@ Next a simple/single error response.
426426
This is simulated by providing incorrect authentication information.
427427

428428
```
429-
$ CF_API_EMAIL='someone@example.com' cli4 /zones/
429+
$ CLOUDFLARE_EMAIL='someone@example.com' cli4 /zones/
430430
cli4: /zones - 9103 Unknown X-Auth-Key or X-Auth-Email
431431
$
432432
```

0 commit comments

Comments
 (0)