-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor large blob of code that converts yaml from snake case to cam…
…el case (#551) extract to a separate file to make it easier to maintain
- Loading branch information
1 parent
7cc8233
commit 9788e53
Showing
2 changed files
with
162 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
# Because we are passing through some yaml directly to Kubernetes resources, we have to retain the camelCase keys. | ||
# All CR parameters are converted to snake_case, but the original yaml is found in the special _kiali_io_kiali param. | ||
# We need to copy that original yaml into our vars where appropriate to keep the camelCase. | ||
|
||
- name: Replace snake_case with camelCase in deployment.affinity.node | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['deployment']['affinity'].pop('node') %} | ||
{{ kiali_vars | combine({'deployment': {'affinity': {'node': current_cr.spec.deployment.affinity.node }}}, recursive=True) }} | ||
when: | ||
- kiali_vars.deployment.affinity is defined | ||
- kiali_vars.deployment.affinity.node is defined | ||
- kiali_vars.deployment.affinity.node | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in deployment.affinity.pod | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['deployment']['affinity'].pop('pod') %} | ||
{{ kiali_vars | combine({'deployment': {'affinity': {'pod': current_cr.spec.deployment.affinity.pod }}}, recursive=True) }} | ||
when: | ||
- kiali_vars.deployment.affinity is defined | ||
- kiali_vars.deployment.affinity.pod is defined | ||
- kiali_vars.deployment.affinity.pod | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in deployment.affinity.pod_anti | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['deployment']['affinity'].pop('pod_anti') %} | ||
{{ kiali_vars | combine({'deployment': {'affinity': {'pod_anti': current_cr.spec.deployment.affinity.pod_anti }}}, recursive=True) }} | ||
when: | ||
- kiali_vars.deployment.affinity is defined | ||
- kiali_vars.deployment.affinity.pod_anti is defined | ||
- kiali_vars.deployment.affinity.pod_anti | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in deployment.tolerations | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['deployment'].pop('tolerations') %} | ||
{{ kiali_vars | combine({'deployment': {'tolerations': current_cr.spec.deployment.tolerations }}, recursive=True) }} | ||
when: | ||
- kiali_vars.deployment.tolerations is defined | ||
- kiali_vars.deployment.tolerations | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in deployment.additional_service_yaml | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['deployment'].pop('additional_service_yaml') %} | ||
{{ kiali_vars | combine({'deployment': {'additional_service_yaml': current_cr.spec.deployment.additional_service_yaml }}, recursive=True) }} | ||
when: | ||
- kiali_vars.deployment.additional_service_yaml is defined | ||
- kiali_vars.deployment.additional_service_yaml | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in deployment.resources | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['deployment'].pop('resources') %} | ||
{{ kiali_vars | combine({'deployment': {'resources': current_cr.spec.deployment.resources }}, recursive=True) }} | ||
when: | ||
- kiali_vars.deployment.resources is defined | ||
- kiali_vars.deployment.resources | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in deployment.ingress.override_yaml | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['deployment']['ingress'].pop('override_yaml') %} | ||
{{ kiali_vars | combine({'deployment': {'ingress': {'override_yaml': current_cr.spec.deployment.ingress.override_yaml }}}, recursive=True) }} | ||
when: | ||
- kiali_vars.deployment.ingress.override_yaml is defined | ||
- kiali_vars.deployment.ingress.override_yaml | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in deployment.pod_annotations | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['deployment'].pop('pod_annotations') %} | ||
{{ kiali_vars | combine({'deployment': {'pod_annotations': current_cr.spec.deployment.pod_annotations }}, recursive=True) }} | ||
when: | ||
- kiali_vars.deployment.pod_annotations is defined | ||
- kiali_vars.deployment.pod_annotations | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in deployment.pod_labels | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['deployment'].pop('pod_labels') %} | ||
{{ kiali_vars | combine({'deployment': {'pod_labels': current_cr.spec.deployment.pod_labels }}, recursive=True) }} | ||
when: | ||
- kiali_vars.deployment.pod_labels is defined | ||
- kiali_vars.deployment.pod_labels | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in deployment.service_annotations | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['deployment'].pop('service_annotations') %} | ||
{{ kiali_vars | combine({'deployment': {'service_annotations': current_cr.spec.deployment.service_annotations }}, recursive=True) }} | ||
when: | ||
- kiali_vars.deployment.service_annotations is defined | ||
- kiali_vars.deployment.service_annotations | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in deployment.hpa.spec | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['deployment']['hpa'].pop('spec') %} | ||
{{ kiali_vars | combine({'deployment': {'hpa': {'spec': current_cr.spec.deployment.hpa.spec }}}, recursive=True) }} | ||
when: | ||
- kiali_vars.deployment.hpa is defined | ||
- kiali_vars.deployment.hpa.spec is defined | ||
- kiali_vars.deployment.hpa.spec | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in deployment.node_selector | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['deployment'].pop('node_selector') %} | ||
{{ kiali_vars | combine({'deployment': {'node_selector': current_cr.spec.deployment.node_selector }}, recursive=True) }} | ||
when: | ||
- kiali_vars.deployment.node_selector is defined | ||
- kiali_vars.deployment.node_selector | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in external_services.custom_dashboards.prometheus.custom_headers | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['external_services']['custom_dashboards']['prometheus'].pop('custom_headers') %} | ||
{{ kiali_vars | combine({'external_services': {'custom_dashboards': {'prometheus': {'custom_headers': current_cr.spec.external_services.custom_dashboards.prometheus.custom_headers }}}}, recursive=True) }} | ||
when: | ||
- kiali_vars.external_services.custom_dashboards.prometheus.custom_headers is defined | ||
- kiali_vars.external_services.custom_dashboards.prometheus.custom_headers | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in external_services.custom_dashboards.prometheus.query_scope | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['external_services']['custom_dashboards']['prometheus'].pop('query_scope') %} | ||
{{ kiali_vars | combine({'external_services': {'custom_dashboards': {'prometheus': {'query_scope': current_cr.spec.external_services.custom_dashboards.prometheus.query_scope }}}}, recursive=True) }} | ||
when: | ||
- kiali_vars.external_services.custom_dashboards.prometheus.query_scope is defined | ||
- kiali_vars.external_services.custom_dashboards.prometheus.query_scope | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in external_services.prometheus.custom_headers | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['external_services']['prometheus'].pop('custom_headers') %} | ||
{{ kiali_vars | combine({'external_services': {'prometheus': {'custom_headers': current_cr.spec.external_services.prometheus.custom_headers }}}, recursive=True) }} | ||
when: | ||
- kiali_vars.external_services.prometheus.custom_headers is defined | ||
- kiali_vars.external_services.prometheus.custom_headers | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in external_services.prometheus.query_scope | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['external_services']['prometheus'].pop('query_scope') %} | ||
{{ kiali_vars | combine({'external_services': {'prometheus': {'query_scope': current_cr.spec.external_services.prometheus.query_scope }}}, recursive=True) }} | ||
when: | ||
- kiali_vars.external_services.prometheus.query_scope is defined | ||
- kiali_vars.external_services.prometheus.query_scope | length > 0 | ||
|
||
- name: Replace snake_case with camelCase in deployment.configmap_annotations | ||
set_fact: | ||
kiali_vars: | | ||
{% set a=kiali_vars['deployment'].pop('configmap_annotations') %} | ||
{{ kiali_vars | combine({'deployment': {'configmap_annotations': current_cr.spec.deployment.configmap_annotations }}, recursive=True) }} | ||
when: | ||
- kiali_vars.deployment.configmap_annotations is defined | ||
- kiali_vars.deployment.configmap_annotations | length > 0 |