From 3da45fb8a29ad32c399725893180bb09b164921d Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 4 Oct 2021 02:57:18 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=E2=AC=86=EF=B8=8F(dependencies)=20update?= =?UTF-8?q?=20python=20dependencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements/development.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/requirements/development.txt b/requirements/development.txt index bf280bccd..9049da9b9 100644 --- a/requirements/development.txt +++ b/requirements/development.txt @@ -1,13 +1,13 @@ # Utils -yq==2.11.1 +yq==2.12.2 # Quality -ansible-lint==4.3.5 -flake8==3.8.4 -isort==5.7.0 -pylint==2.6.0 +ansible-lint==5.2.0 +flake8==3.9.2 +isort==5.9.3 +pylint==2.11.1 # Tests -pyfakefs==4.3.3 -pytest-cov==2.11.1 -pytest==6.2.2 +pyfakefs==4.5.1 +pytest-cov==3.0.0 +pytest==6.2.5 From 32aae2a2a7ba543cd9c0c1fdd3786b81f8c617d0 Mon Sep 17 00:00:00 2001 From: Julien Maupetit Date: Mon, 4 Oct 2021 14:52:47 +0200 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=9A=A8(project)=20fix=20ansible-lint?= =?UTF-8?q?=20rules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the `ansible-lint-rules` project is no longer maintained, we've decided to stick to the base ansible-lint rules. --- Dockerfile | 7 ------- Makefile | 5 ++--- tasks/create_docker_registry_secrets.yml | 8 +++++--- tasks/load_app_defaults.yml | 2 +- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index e40d99499..08fcfae75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -72,13 +72,6 @@ RUN apt-get update && \ COPY requirements/development.txt /app/requirements.txt RUN pip install --no-cache-dir -r /app/requirements.txt -# Install more ansible_lint_rules -ENV ANSIBLE_LINT_RULES_DIR="/usr/local/share/ansible-lint/rules" -RUN mkdir -p "${ANSIBLE_LINT_RULES_DIR}" && \ - curl -sLo /tmp/ansible-lint-rules.zip https://github.com/lean-delivery/ansible-lint-rules/archive/1.2.0.zip && \ - unzip -j /tmp/ansible-lint-rules.zip '*/rules/*' -d "${ANSIBLE_LINT_RULES_DIR}" && \ - rm -rf "/tmp/ansible-lint-rules.zip" - # pylint history and cache files ENV PYLINTHOME="/app/.pylint.d" diff --git a/Makefile b/Makefile index 0a4bcef36..45d2da7c8 100644 --- a/Makefile +++ b/Makefile @@ -29,8 +29,7 @@ K8S_DOMAIN ?= "$(shell hostname -I | awk '{print $$1}')" K3D_CLUSTER_NAME ?= arnold # -- Linters -ANSIBLE_LINT_RULES_DIR = /usr/local/share/ansible-lint/rules -ANSIBLE_LINT_SKIP_RULES = E602 +ANSIBLE_LINT_SKIP_RULES = # ============================================================================== # RULES @@ -65,7 +64,7 @@ lint-ansible: ## lint ansible sources @echo 'Checking syntax…' $(ARNOLD_RUN_DEV) ansible-playbook --syntax-check ./*.yml @echo 'Linting sources…' - $(ARNOLD_RUN_DEV) ansible-lint -R -r $(ANSIBLE_LINT_RULES_DIR) -x $(ANSIBLE_LINT_SKIP_RULES) ./*.yml + $(ARNOLD_RUN_DEV) ansible-lint -R -x $(ANSIBLE_LINT_SKIP_RULES) ./*.yml .PHONY: lint-ansible lint-bash: ## lint bash scripts with shellcheck diff --git a/tasks/create_docker_registry_secrets.yml b/tasks/create_docker_registry_secrets.yml index 8d80ab413..d19424577 100644 --- a/tasks/create_docker_registry_secrets.yml +++ b/tasks/create_docker_registry_secrets.yml @@ -6,11 +6,13 @@ path: "group_vars/customer/{{ customer }}/{{ env_type }}/secrets/registries.vault.yml" register: registries_vault -- block: - - name: Check if registries vault exists +- name: Check if registries vault exists + block: + - name: End play debug error message debug: msg: "No registries vault is associated with the namespace" - - meta: end_play + - name: Exit playbook + meta: end_play when: not registries_vault.stat.exists - name: Import registries variable diff --git a/tasks/load_app_defaults.yml b/tasks/load_app_defaults.yml index 2e00261e9..2193fb80a 100644 --- a/tasks/load_app_defaults.yml +++ b/tasks/load_app_defaults.yml @@ -11,7 +11,7 @@ - name: Define missing variables with defaults set_fact: - "{{ app_var.key }}": "{{ lookup('vars', app_var.key, default=app_var.value) }}" + "{{ app_var.key }}": "{{ lookup('vars', app_var.key, default=app_var.value) }}" # noqa var-naming loop: "{{ lookup('dict', defaults) }}" loop_control: loop_var: "app_var" From 870cf2f800c8e7595cc91e257112fe2d05ac0083 Mon Sep 17 00:00:00 2001 From: Julien Maupetit Date: Mon, 4 Oct 2021 15:01:44 +0200 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=9A=A8(project)=20fix=20pylint=20erro?= =?UTF-8?q?rs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We now must use f-strings everywhere! --- filter_plugins/deploy.py | 38 +++++++++++------------ lookup_plugins/apps.py | 6 +++- tests/units/plugins/filter/test_deploy.py | 4 +-- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/filter_plugins/deploy.py b/filter_plugins/deploy.py index d3d9e8dcb..004393c90 100644 --- a/filter_plugins/deploy.py +++ b/filter_plugins/deploy.py @@ -8,19 +8,19 @@ def blue_green_host(host, prefix=None): """ - Add next/previous prefix to the base host, if prefix is empty or equals - to 'current', the host is left unchanged. + Add next/previous prefix to the base host, if prefix is empty or equals + to 'current', the host is left unchanged. - Example usage: + Example usage: - {{ "foo.bar.com" | blue_green_host("previous") }} - # Should return: previous.foo.bar.com + {{ "foo.bar.com" | blue_green_host("previous") }} + # Should return: previous.foo.bar.com - {{ "foo.bar.com" | blue_green_host() }} - # Should return: foo.bar.com + {{ "foo.bar.com" | blue_green_host() }} + # Should return: foo.bar.com - {{ "foo.bar.com" | blue_green_host("current") }} - # Should return: foo.bar.com + {{ "foo.bar.com" | blue_green_host("current") }} + # Should return: foo.bar.com """ if prefix is None or not prefix: @@ -28,23 +28,21 @@ def blue_green_host(host, prefix=None): if prefix not in BLUE_GREEN_PREFIXES: raise AnsibleFilterError( - "prefix '{}' is not allowed (must be in {})".format( - prefix, BLUE_GREEN_PREFIXES - ) + f"prefix '{prefix}' is not allowed (must be in {BLUE_GREEN_PREFIXES})" ) - return "{}.{}".format(prefix, host) if prefix != "current" else host + return f"{prefix}.{host}" if prefix != "current" else host def blue_green_hosts(host): """ - Add next/current/previous prefix to the base host, and return that list - of possible hosts. + Add next/current/previous prefix to the base host, and return that list + of possible hosts. - Example usage: + Example usage: - {{ "foo.bar.com" | blue_green_hosts }} - # Should return: previous.foo.bar.com, foo.bar.com, next.foo.bar.com + {{ "foo.bar.com" | blue_green_hosts }} + # Should return: previous.foo.bar.com, foo.bar.com, next.foo.bar.com """ if not host: @@ -52,14 +50,14 @@ def blue_green_hosts(host): return ",".join( [ - "{}.{}".format(prefix, host) if prefix != "current" else host + f"{prefix}.{host}" if prefix != "current" else host for prefix in BLUE_GREEN_PREFIXES ] ) # pylint: disable=no-self-use,too-few-public-methods -class FilterModule(): +class FilterModule: """Filters used for deployments""" def filters(self): diff --git a/lookup_plugins/apps.py b/lookup_plugins/apps.py index 58e06a12b..44c511116 100644 --- a/lookup_plugins/apps.py +++ b/lookup_plugins/apps.py @@ -4,6 +4,7 @@ """ from __future__ import absolute_import, division, print_function +from locale import getpreferredencoding from pathlib import Path import yaml @@ -162,7 +163,10 @@ def __init__(self, loader=None, templar=None, **kwargs): def _yaml_load(file_path): """Syntactic sugar to get yaml content with a simpler line of code""" - return yaml.load(Path(file_path).read_text(), Loader=yaml.FullLoader) + return yaml.load( + Path(file_path).read_text(encoding=getpreferredencoding()), + Loader=yaml.FullLoader, + ) def _get_app_service(self, service_path): """Explore an application service""" diff --git a/tests/units/plugins/filter/test_deploy.py b/tests/units/plugins/filter/test_deploy.py index a713cca18..bcd0cf4ec 100644 --- a/tests/units/plugins/filter/test_deploy.py +++ b/tests/units/plugins/filter/test_deploy.py @@ -44,8 +44,8 @@ def test_with_next_previous_prefix(self): host = "foo.com" - self.assertEqual(blue_green_host(host, "previous"), "previous.{}".format(host)) - self.assertEqual(blue_green_host(host, "next"), "next.{}".format(host)) + self.assertEqual(blue_green_host(host, "previous"), f"previous.{host}") + self.assertEqual(blue_green_host(host, "next"), f"next.{host}") class TestBlueGreenHostsFilter(unittest.TestCase): From acca6bbe2108d93675c0b791fd35c2df094546d5 Mon Sep 17 00:00:00 2001 From: Julien Maupetit Date: Mon, 4 Oct 2021 15:04:07 +0200 Subject: [PATCH 4/4] =?UTF-8?q?=E2=AC=86=EF=B8=8F(project)=20activate=20re?= =?UTF-8?q?novate=20options=20for=20commit=20body=20description?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the renovate configuration, when activated, the flag `commitBodyTable` enables to append a table with all the updates in the commit. To fit to our previous commit description with pybot, we have activated this flag. --- renovate.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/renovate.json b/renovate.json index 03512a57c..d90a15c0d 100644 --- a/renovate.json +++ b/renovate.json @@ -1,5 +1,8 @@ { "extends": ["github>openfun/renovate-configuration"], + "commitMessagePrefix": "⬆️(project)", + "commitMessageAction": "upgrade", + "commitBodyTable": true, "enabledManagers": ["pip_requirements"], "packageRules": [ {