Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆️(dependencies) update python dependencies #694

Merged
merged 4 commits into from Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions Dockerfile
Expand Up @@ -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"
jmaupetit marked this conversation as resolved.
Show resolved Hide resolved

# pylint history and cache files
ENV PYLINTHOME="/app/.pylint.d"

Expand Down
5 changes: 2 additions & 3 deletions Makefile
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
38 changes: 18 additions & 20 deletions filter_plugins/deploy.py
Expand Up @@ -8,58 +8,56 @@

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:
return host

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:
raise AnsibleFilterError("host cannot be empty")

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):
Expand Down
6 changes: 5 additions & 1 deletion lookup_plugins/apps.py
Expand Up @@ -4,6 +4,7 @@
"""
from __future__ import absolute_import, division, print_function

from locale import getpreferredencoding
from pathlib import Path

import yaml
Expand Down Expand Up @@ -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"""
Expand Down
3 changes: 3 additions & 0 deletions renovate.json
@@ -1,5 +1,8 @@
{
"extends": ["github>openfun/renovate-configuration"],
"commitMessagePrefix": "⬆️(project)",
"commitMessageAction": "upgrade",
"commitBodyTable": true,
"enabledManagers": ["pip_requirements"],
"packageRules": [
{
Expand Down
16 changes: 8 additions & 8 deletions 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
8 changes: 5 additions & 3 deletions tasks/create_docker_registry_secrets.yml
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tasks/load_app_defaults.yml
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions tests/units/plugins/filter/test_deploy.py
Expand Up @@ -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):
Expand Down