Silence the YAML NoneType warning for password_security-compliance

If the value is not set (the default) then the context causes a error
message to be emitted to the Juju log.  Whilst this doesn't affect the
operations of the charm, it is likely to cause support requests.  This
change only attempts to decode the config option if it is actually set.

Change-Id: I0ccccdab92cb46f7354732f9d620797910ba55c0
This commit is contained in:
Alex Kavanagh 2020-04-16 15:19:42 +01:00
parent 7ff71cad6c
commit 5871699dd4
1 changed files with 7 additions and 3 deletions

View File

@ -217,9 +217,13 @@ class KeystoneContext(context.OSContextGenerator):
flags = context.config_flags_parser(ldap_flags)
ctxt['ldap_config_flags'] = flags
ctxt['password_security_compliance'] = (
self._decode_password_security_compliance_string(
config('password-security-compliance')))
# Only try to decode it if there is something actually set - this
# siliences a NoneType warning in the logs if it isn't set
password_security_compliance = config('password-security-compliance')
if password_security_compliance:
ctxt['password_security_compliance'] = (
self._decode_password_security_compliance_string(
password_security_compliance))
# Base endpoint URL's which are used in keystone responses
# to unauthenticated requests to redirect clients to the