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

Unified Annotation Handling without Duplicates #1821

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions roles/installer/templates/deployments/task.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ spec:
] %}
checksum-secret-{{ secret }}: "{{ lookup('ansible.builtin.vars', secret, default='')["resources"][0]["data"] | default('') | sha1 }}"
{% endfor %}
{% if task_annotations %}
{{ task_annotations | indent(width=8) }}
{% elif annotations %}
{{ annotations | indent(width=8) }}
{% endif %}
{% set combined_annotations = web_annotations + annotations %}
{% set seen = [] %}
{% for annotation in combined_annotations %}
{% if annotation not in seen %}
{{ annotation | indent(width=8) }}
{% do seen.append(annotation) %}
{% endif %}
{% endfor %}
spec:
serviceAccountName: '{{ ansible_operator_meta.name }}'
{% if image_pull_secret is defined %}
Expand Down
13 changes: 8 additions & 5 deletions roles/installer/templates/deployments/web.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ spec:
] %}
checksum-secret-{{ secret }}: "{{ lookup('ansible.builtin.vars', secret, default='')["resources"][0]["data"] | default('') | sha1 }}"
{% endfor %}
{% if web_annotations %}
{{ web_annotations | indent(width=8) }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case was only accepting one single annotation, In our case we need multiple lines

{% elif annotations %}
{{ annotations | indent(width=8) }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even worse that 'elif' case was completely overided by web_annotation...

{% endif %}
{% set combined_annotations = web_annotations + annotations %}
{% set seen = [] %}
{% for annotation in combined_annotations %}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very elegant way to factorize code with minimum impact

{% if annotation not in seen %}
{{ annotation | indent(width=8) }}
{% do seen.append(annotation) %}
{% endif %}
{% endfor %}
spec:
{% if uwsgi_listen_queue_size is defined and uwsgi_listen_queue_size|int > 128 %}
securityContext:
Expand Down
Loading