Fix: re-add incorrectly removed format test
This was removed in Iccf6228ab9e6d621d3047994b3adc192d67273c9 but should not have been as it has allowed for code format drift. This also * Pins the version of yapf to 0.24.0 * Fixes some drift * Updates formatting to the version of yapf being used Change-Id: Ie3d9fd6344a29d8ddb76a36d4a31d001a4c8b7c6
This commit is contained in:
parent
018496fd18
commit
3ac95edc60
@ -82,9 +82,7 @@ class Builder:
|
||||
script = renderer.render_template(
|
||||
sub_config,
|
||||
template='scripts/genesis.sh',
|
||||
context={
|
||||
'tarball': tarball
|
||||
})
|
||||
context={'tarball': tarball})
|
||||
|
||||
_write_script(output_dir, 'genesis.sh', script)
|
||||
|
||||
@ -117,9 +115,7 @@ class Builder:
|
||||
return renderer.render_template(
|
||||
sub_config,
|
||||
template='scripts/join.sh',
|
||||
context={
|
||||
'tarball': tarball
|
||||
})
|
||||
context={'tarball': tarball})
|
||||
|
||||
def _build_node_validate_script(self, node_name):
|
||||
sub_config = self.config.extract_node_config(node_name)
|
||||
|
@ -71,9 +71,8 @@ class Configuration:
|
||||
**kwargs)
|
||||
|
||||
def __getitem__(self, path):
|
||||
return self.get_path(path,
|
||||
jinja2.StrictUndefined(
|
||||
'No match found for path %s' % path))
|
||||
return self.get_path(
|
||||
path, jinja2.StrictUndefined('No match found for path %s' % path))
|
||||
|
||||
def get_first(self, *paths, default=None):
|
||||
result = self._get_first(*paths)
|
||||
|
@ -87,8 +87,9 @@ class ContextMiddleware(object):
|
||||
"""
|
||||
|
||||
def _format_uuid_string(self, string):
|
||||
return (string.replace('urn:', '').replace('uuid:', '').strip('{}')
|
||||
.replace('-', '').lower())
|
||||
return (string.replace('urn:', '').replace('uuid:',
|
||||
'').strip('{}').replace(
|
||||
'-', '').lower())
|
||||
|
||||
def _is_uuid_like(self, val):
|
||||
try:
|
||||
|
@ -69,8 +69,8 @@ class KubeClient(object):
|
||||
self.client.patch_node(node_name, body)
|
||||
return resp_body_succ.get_output_json()
|
||||
except (ApiException, MaxRetryError) as e:
|
||||
LOG.exception(
|
||||
"An exception occurred during node labels update: " + str(e))
|
||||
LOG.exception("An exception occurred during node labels update: " +
|
||||
str(e))
|
||||
raise KubernetesApiError
|
||||
|
||||
def get_node_labels(self, node_name):
|
||||
@ -89,8 +89,8 @@ class KubeClient(object):
|
||||
else:
|
||||
return {}
|
||||
except (ApiException, MaxRetryError) as e:
|
||||
LOG.exception(
|
||||
"An exception occurred in fetching node labels: " + str(e))
|
||||
LOG.exception("An exception occurred in fetching node labels: " +
|
||||
str(e))
|
||||
if hasattr(e, 'status') and str(e.status) == "404":
|
||||
raise NodeNotFoundException
|
||||
else:
|
||||
|
@ -34,11 +34,11 @@ class PKI:
|
||||
return self._ca_config_string
|
||||
|
||||
def generate_ca(self, ca_name):
|
||||
result = self._cfssl(
|
||||
['gencert', '-initca', 'csr.json'],
|
||||
files={
|
||||
'csr.json': self.csr(name=ca_name, groups=['Kubernetes']),
|
||||
})
|
||||
result = self._cfssl(['gencert', '-initca', 'csr.json'],
|
||||
files={
|
||||
'csr.json':
|
||||
self.csr(name=ca_name, groups=['Kubernetes']),
|
||||
})
|
||||
|
||||
return (self._wrap_ca(ca_name, result['cert']),
|
||||
self._wrap_ca_key(ca_name, result['key']))
|
||||
|
@ -36,10 +36,9 @@ def insert_charts_into_bundler(bundler):
|
||||
if _source_file_is_excluded(source_filename):
|
||||
continue
|
||||
source_path = os.path.join(root, source_filename)
|
||||
destination_path = os.path.join('etc/genesis/armada/assets/charts',
|
||||
os.path.relpath(
|
||||
source_path,
|
||||
'/opt/promenade/charts'))
|
||||
destination_path = os.path.join(
|
||||
'etc/genesis/armada/assets/charts',
|
||||
os.path.relpath(source_path, '/opt/promenade/charts'))
|
||||
stat = os.stat(source_path)
|
||||
LOG.debug('Copying asset file %s (mode=%o)', source_path,
|
||||
stat.st_mode)
|
||||
@ -49,10 +48,8 @@ def insert_charts_into_bundler(bundler):
|
||||
|
||||
|
||||
def render_role_into_bundler(*, bundler, config, role):
|
||||
role_root = pkg_resources.resource_filename('promenade',
|
||||
os.path.join(
|
||||
'templates', 'roles',
|
||||
role))
|
||||
role_root = pkg_resources.resource_filename(
|
||||
'promenade', os.path.join('templates', 'roles', role))
|
||||
for root, _dirnames, filenames in os.walk(role_root, followlinks=True):
|
||||
destination_base = os.path.relpath(root, role_root)
|
||||
for source_filename in filenames:
|
||||
@ -89,10 +86,8 @@ def render_template(config, *, template, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
template_contents = pkg_resources.resource_string('promenade',
|
||||
os.path.join(
|
||||
'templates',
|
||||
template))
|
||||
template_contents = pkg_resources.resource_string(
|
||||
'promenade', os.path.join('templates', template))
|
||||
|
||||
env = _build_env()
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
pytest
|
||||
flake8>=3.3.0
|
||||
bandit>=1.5
|
||||
yapf
|
||||
yapf==0.24.0
|
||||
sphinx>=1.6.2
|
||||
sphinx_rtd_theme==0.2.4
|
||||
|
@ -33,65 +33,69 @@ TEST_DATA = [(
|
||||
"label-c": "value4",
|
||||
"label-d": "value99",
|
||||
},
|
||||
), (
|
||||
'Add labels when none exist',
|
||||
None,
|
||||
{
|
||||
"label-a": "value1",
|
||||
"label-b": "value2",
|
||||
"label-c": "value3",
|
||||
},
|
||||
{
|
||||
"label-a": "value1",
|
||||
"label-b": "value2",
|
||||
"label-c": "value3",
|
||||
},
|
||||
), (
|
||||
'No updates',
|
||||
{
|
||||
"label-a": "value1",
|
||||
"label-b": "value2",
|
||||
"label-c": "value3",
|
||||
},
|
||||
{
|
||||
"label-a": "value1",
|
||||
"label-b": "value2",
|
||||
"label-c": "value3",
|
||||
},
|
||||
{},
|
||||
), (
|
||||
'Delete labels',
|
||||
{
|
||||
"label-a": "value1",
|
||||
"label-b": "value2",
|
||||
"label-c": "value3",
|
||||
},
|
||||
{},
|
||||
{
|
||||
"label-a": None,
|
||||
"label-b": None,
|
||||
"label-c": None,
|
||||
},
|
||||
), (
|
||||
'Delete labels when none',
|
||||
None,
|
||||
{},
|
||||
{},
|
||||
), (
|
||||
'Avoid kubernetes.io labels Deletion',
|
||||
{
|
||||
"label-a": "value1",
|
||||
"label-b": "value2",
|
||||
"kubernetes.io/hostname": "ubutubox",
|
||||
},
|
||||
{
|
||||
"label-a": "value99",
|
||||
},
|
||||
{
|
||||
"label-a": "value99",
|
||||
"label-b": None,
|
||||
},
|
||||
)]
|
||||
),
|
||||
(
|
||||
'Add labels when none exist',
|
||||
None,
|
||||
{
|
||||
"label-a": "value1",
|
||||
"label-b": "value2",
|
||||
"label-c": "value3",
|
||||
},
|
||||
{
|
||||
"label-a": "value1",
|
||||
"label-b": "value2",
|
||||
"label-c": "value3",
|
||||
},
|
||||
),
|
||||
(
|
||||
'No updates',
|
||||
{
|
||||
"label-a": "value1",
|
||||
"label-b": "value2",
|
||||
"label-c": "value3",
|
||||
},
|
||||
{
|
||||
"label-a": "value1",
|
||||
"label-b": "value2",
|
||||
"label-c": "value3",
|
||||
},
|
||||
{},
|
||||
),
|
||||
(
|
||||
'Delete labels',
|
||||
{
|
||||
"label-a": "value1",
|
||||
"label-b": "value2",
|
||||
"label-c": "value3",
|
||||
},
|
||||
{},
|
||||
{
|
||||
"label-a": None,
|
||||
"label-b": None,
|
||||
"label-c": None,
|
||||
},
|
||||
), (
|
||||
'Delete labels when none',
|
||||
None,
|
||||
{},
|
||||
{},
|
||||
),
|
||||
(
|
||||
'Avoid kubernetes.io labels Deletion',
|
||||
{
|
||||
"label-a": "value1",
|
||||
"label-b": "value2",
|
||||
"kubernetes.io/hostname": "ubutubox",
|
||||
},
|
||||
{
|
||||
"label-a": "value99",
|
||||
},
|
||||
{
|
||||
"label-a": "value99",
|
||||
"label-b": None,
|
||||
},
|
||||
)]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('description,existing_lbl,input_lbl,expected',
|
||||
|
@ -140,7 +140,8 @@ VALID_DOCS = [
|
||||
},
|
||||
{
|
||||
'data': {
|
||||
'files': [{
|
||||
'files':
|
||||
[{
|
||||
'mode':
|
||||
365,
|
||||
'path':
|
||||
@ -149,14 +150,15 @@ VALID_DOCS = [
|
||||
'kubernetes/node/bin/kubelet',
|
||||
'tar_url':
|
||||
'https://dl.k8s.io/v1.10.2/kubernetes-node-linux-amd64.tar.gz'
|
||||
}, {
|
||||
'content':
|
||||
'/var/lib/docker/containers/*/*-json.log\n{\n compress\n copytruncate\n create 0644 root root\n daily\n dateext\n dateformat -%Y%m%d-%s\n maxsize 10M\n missingok\n notifempty\n su root root\n rotate 1\n}',
|
||||
'mode':
|
||||
292,
|
||||
'path':
|
||||
'/etc/logrotate.d/json-logrotate'
|
||||
}],
|
||||
},
|
||||
{
|
||||
'content':
|
||||
'/var/lib/docker/containers/*/*-json.log\n{\n compress\n copytruncate\n create 0644 root root\n daily\n dateext\n dateformat -%Y%m%d-%s\n maxsize 10M\n missingok\n notifempty\n su root root\n rotate 1\n}',
|
||||
'mode':
|
||||
292,
|
||||
'path':
|
||||
'/etc/logrotate.d/json-logrotate'
|
||||
}],
|
||||
'images': {
|
||||
'haproxy': 'haproxy:1.8.3',
|
||||
'helm': {
|
||||
|
@ -86,9 +86,9 @@ def _valid_dg(config, dynamic_tag, context_name=None):
|
||||
if config.get('context', {}).get(context_name):
|
||||
return True
|
||||
else:
|
||||
raise TagGenExeception('Dynamic tag "%s" requested, but "%s"'
|
||||
' not found in context' % (dynamic_tag,
|
||||
context_name))
|
||||
raise TagGenExeception(
|
||||
'Dynamic tag "%s" requested, but "%s"'
|
||||
' not found in context' % (dynamic_tag, context_name))
|
||||
else:
|
||||
return False
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user