From d60d1ac9287415d0013bfd911aad6ab58b52fb6a Mon Sep 17 00:00:00 2001 From: Samuel Brolia Date: Wed, 18 Jul 2018 15:49:14 +0100 Subject: [PATCH 1/2] Added default for client_key when reading config from config file --- chef/api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chef/api.py b/chef/api.py index 870592f..99a3672 100644 --- a/chef/api.py +++ b/chef/api.py @@ -117,6 +117,8 @@ def _ruby_value(match): value = cls.ruby_value_re.sub(_ruby_value, value) except UnknownRubyExpression: continue + # Set defaults + key_path = '/etc/chef/client.pem' if key == 'chef_server_url': log.debug('Found URL: %r', value) url = value From bb9c0e70f8011ae278eae11f789f62bee8024351 Mon Sep 17 00:00:00 2001 From: Samuel Brolia Date: Thu, 19 Jul 2018 11:33:31 +0100 Subject: [PATCH 2/2] Set the default at the beginning rather than in each iteration of the loop --- chef/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chef/api.py b/chef/api.py index 99a3672..74a5096 100644 --- a/chef/api.py +++ b/chef/api.py @@ -84,6 +84,8 @@ def from_config_file(cls, path): log.debug('Unable to read config file "%s"', path) return url = key_path = client_name = None + # Set defaults + key_path = '/etc/chef/client.pem' ssl_verify = True for line in open(path): if not line.strip() or line.startswith('#'): @@ -117,8 +119,6 @@ def _ruby_value(match): value = cls.ruby_value_re.sub(_ruby_value, value) except UnknownRubyExpression: continue - # Set defaults - key_path = '/etc/chef/client.pem' if key == 'chef_server_url': log.debug('Found URL: %r', value) url = value