Skip to content

Commit e79ff4b

Browse files
authored
Merge pull request #457 from volans-/https
Allow to force the PuppetDB connection protocol
2 parents 1bf3ee6 + e043c64 commit e79ff4b

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

README.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ connect. Therefor you'll also have to supply the following settings:
190190
* ``PUPPETDB_CERT = /path/to/public/keyfile.crt``
191191

192192
For information about how to generate the correct keys please refer to the
193-
`pypuppetdb documentation`_.
193+
`pypuppetdb documentation`_. Alternatively is possible to explicitly specify
194+
the protocol to be used setting the ``PUPPETDB_PROTO`` variable.
194195

195196
Other settings that might be interesting in no particular order:
196197

puppetboard/core.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def get_puppetdb():
4747
ssl_verify=app.config['PUPPETDB_SSL_VERIFY'],
4848
ssl_key=app.config['PUPPETDB_KEY'],
4949
ssl_cert=app.config['PUPPETDB_CERT'],
50-
timeout=app.config['PUPPETDB_TIMEOUT'],)
50+
timeout=app.config['PUPPETDB_TIMEOUT'],
51+
protocol=app.config['PUPPETDB_PROTO'],)
5152
PUPPETDB = puppetdb
5253

5354
return PUPPETDB

puppetboard/default_settings.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
PUPPETDB_HOST = 'localhost'
44
PUPPETDB_PORT = 8080
5+
PUPPETDB_PROTO = None
56
PUPPETDB_SSL_VERIFY = True
67
PUPPETDB_KEY = None
78
PUPPETDB_CERT = None

puppetboard/docker_settings.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
PUPPETDB_HOST = os.getenv('PUPPETDB_HOST', 'puppetdb')
44
PUPPETDB_PORT = int(os.getenv('PUPPETDB_PORT', '8080'))
5-
# Since this is an env it will alwas be a string, we need
5+
# Since this is an env it will always be a string, we need
66
# to conver that string to a bool
77
SSL_VERIFY = os.getenv('PUPPETDB_SSL_VERIFY', 'True')
88
if SSL_VERIFY.upper() == 'TRUE':
@@ -14,6 +14,7 @@
1414

1515
PUPPETDB_KEY = os.getenv('PUPPETDB_KEY', None)
1616
PUPPETDB_CERT = os.getenv('PUPPETDB_CERT', None)
17+
PUPPETDB_PROTO = os.getenv('PUPPETDB_PROTO', None)
1718
PUPPETDB_TIMEOUT = int(os.getenv('PUPPETDB_TIMEOUT', '20'))
1819
DEFAULT_ENVIRONMENT = os.getenv('DEFAULT_ENVIRONMENT', 'production')
1920
SECRET_KEY = os.getenv('SECRET_KEY', os.urandom(24))

test/test_docker_settings.py

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ def test_set_host_port(cleanUpEnv):
4040
assert docker_settings.PUPPETDB_PORT == 9081
4141

4242

43+
def test_set_proto(cleanUpEnv):
44+
os.environ['PUPPETDB_PROTO'] = 'https'
45+
reload(docker_settings)
46+
assert docker_settings.PUPPETDB_PROTO == 'https'
47+
48+
4349
def test_cert_true_test(cleanUpEnv):
4450
os.environ['PUPPETDB_SSL_VERIFY'] = 'True'
4551
reload(docker_settings)

0 commit comments

Comments
 (0)