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

Adds support for CONSUL_HTTP_TOKEN_FILE #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions consul/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,16 @@ def __init__(
self.snapshot = Consul.Snapshot(self)
self.status = Consul.Status(self)
self.token = os.getenv('CONSUL_HTTP_TOKEN', token)

# Token file preempts passed tokens any other way, if it exists
if 'CONSUL_HTTP_TOKEN_FILE' in os.environ:
token_file = os.environ['CONSUL_HTTP_TOKEN_FILE']
assert os.path.exists(token_file)
with open(token_file, 'r') as f:
tok = f.readline().strip()
if len(tok) != 0:
self.token = tok

self.txn = Consul.Txn(self)

class ACL(object):
Expand Down