From 2691b0f43db3b77636fd5dfbf7ae8adfb972633c Mon Sep 17 00:00:00 2001 From: abikouo Date: Thu, 20 May 2021 11:17:10 +0200 Subject: [PATCH] lint validation --- .github/workflows/ci.yml | 2 +- molecule/default/tasks/waiter.yml | 32 +++++++++++++++---------------- plugins/module_utils/jsonpath.py | 5 +---- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e98f925c..393d224e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,7 +92,7 @@ jobs: # The 3.3.0 release of molecule introduced a breaking change. See # https://github.com/ansible-community/molecule/issues/3083 - name: Install molecule and openshift dependencies - run: pip install ansible "molecule<3.3.0" yamllint openshift flake8 jsonpatch + run: pip install ansible "molecule<3.3.0" yamllint openshift flake8 jsonpatch jmespath # The latest release doesn't work with Molecule currently. # See: https://github.com/ansible-community/molecule/issues/2757 diff --git a/molecule/default/tasks/waiter.yml b/molecule/default/tasks/waiter.yml index e2c1da0c..9fdb8a73 100644 --- a/molecule/default/tasks/waiter.yml +++ b/molecule/default/tasks/waiter.yml @@ -374,9 +374,9 @@ namespace: "{{ wait_namespace }}" spec: containers: - - name: crashing-container - image: busybox - command: ['/dummy/dummy-shell', '-c', 'sleep 2000'] + - name: crashing-container + image: busybox + command: ['/dummy/dummy-shell', '-c', 'sleep 2000'] wait: yes wait_timeout: 10 wait_property: @@ -390,7 +390,7 @@ - crash_pod is failed - crash_pod.changed - '"Resource creation timed out" in crash_pod.msg' - + - name: add a valid pod and wait until container is running k8s: definition: @@ -401,9 +401,9 @@ namespace: "{{ wait_namespace }}" spec: containers: - - name: crashing-container - image: busybox - command: ['/bin/sh', '-c', 'sleep 10000'] + - name: crashing-container + image: busybox + command: ['/bin/sh', '-c', 'sleep 10000'] wait: yes wait_timeout: 10 wait_property: @@ -428,16 +428,16 @@ namespace: "{{ wait_namespace }}" spec: containers: - - name: redis-container - image: redis - volumeMounts: - - name: test - mountPath: "/etc/test" - readOnly: true + - name: redis-container + image: redis + volumeMounts: + - name: test + mountPath: "/etc/test" + readOnly: true volumes: - - name: test - configMap: - name: redis-config + - name: test + configMap: + name: redis-config wait: yes wait_timeout: 10 wait_property: diff --git a/plugins/module_utils/jsonpath.py b/plugins/module_utils/jsonpath.py index 411e2289..a4310683 100644 --- a/plugins/module_utils/jsonpath.py +++ b/plugins/module_utils/jsonpath.py @@ -16,7 +16,6 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -import traceback from ansible.module_utils.basic import missing_required_lib from ansible.module_utils._text import to_native @@ -60,8 +59,6 @@ def match_json_property(module, data, expr, value=None): jmespath.functions.REVERSE_TYPES_MAP['string'] = jmespath.functions.REVERSE_TYPES_MAP['string'] + ('AnsibleUnicode', 'AnsibleUnsafeText', ) try: content = jmespath.search(expr, data) - with open("/tmp/play.cont", "w") as f: - f.write("{}".format(content)) if content is None or content == []: return False if value is None or _match_value(content, value): @@ -69,4 +66,4 @@ def match_json_property(module, data, expr, value=None): return True return False except Exception as err: - _raise_or_fail(err, msg="JMESPathError failed to extract from JSON document using expr: {}".format(expr)) + _raise_or_fail(err, msg="JMESPathError failed to extract from JSON document using expr: {0}".format(expr))