Skip to content

Commit

Permalink
[ci_gen_kustomize_values] Allow reject vars patches
Browse files Browse the repository at this point in the history
  • Loading branch information
pablintino committed Dec 17, 2024
1 parent 587205f commit 93455e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions roles/ci_gen_kustomize_values/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ with a message.
* `ci_gen_kustomize_fetch_ocp_state`: (Boolean) If true it enables generating CI templates based on the OCP state. Defaults to `true`.
* `cifmw_ci_gen_kustomize_values_storage_class_prefix`: (String) Prefix for `storageClass` in generated values.yaml files. Defaults to `"lvms-"` only if `cifmw_use_lvms` is True, otherwise it defaults to `""`. The prefix is prepended to the `cifmw_ci_gen_kustomize_values_storage_class`. It is not recommended to override this value, instead set `cifmw_use_lvms` True or False.
* `cifmw_ci_gen_kustomize_values_storage_class`: (String) Value for `storageClass` in generated values.yaml files. Defaults to `"lvms-local-storage"` only if `cifmw_use_lvms` is True, otherwise it defaults to `"local-storage"`.
* `cifmw_ci_gen_kustomize_values_remove_keys_expressions`: (List) Remove keys matching the regular expressions from source ConfigMaps (values.yaml).
Defaults to `["^nodes$", "^node(_[0-9]+)?$"]`.
* `cifmw_ci_gen_kustomize_values_remove_keys_expressions*`: (List) Remove keys matching the regular expressions from source ConfigMaps (values.yaml).
Defaults to `["^nodes$", "^node(_[0-9]+)?$"]`. Accepts passing additional expressions by passing variables that matches `cifmw_ci_gen_kustomize_values_remove_keys_expressions.+`.

### Specific parameters for edpm-values
This configMap needs some more parameters in order to properly override the `architecture` provided one.
Expand Down
18 changes: 17 additions & 1 deletion roles/ci_gen_kustomize_values/tasks/generate_snippets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@
cifmw_ci_gen_kustomize_values_snippets_dir_prefix ~ _datatype) |
path_join
}}
_cifmw_gen_kustomize_values_reject_extra_expressions: >-
{{
hostvars[inventory_hostname] |
dict2items |
selectattr("key", "match", "^cifmw_ci_gen_kustomize_values_remove_keys_expressions.+") |
sort(attribute='key') |
map(attribute="value") |
list
}}
ansible.builtin.set_fact:
values_datatype: "{{ _datatype }}"
snippet_datadir: "{{ _dest_dir }}"
Expand All @@ -77,11 +86,18 @@
{{
_raw_manifests | reject('equalto', _config_map_content)
}}
_cifmw_gen_kustomize_values_reject_expressions: >-
{{
(
_cifmw_gen_kustomize_values_reject_extra_expressions +
cifmw_ci_gen_kustomize_values_remove_keys_expressions
) | flatten | unique
}}
_cifmw_gen_kustomize_values_base_cm_content: >-
{{
_config_map_content |
ansible.utils.remove_keys(
target=cifmw_ci_gen_kustomize_values_remove_keys_expressions,
target=_cifmw_gen_kustomize_values_reject_expressions,
matching_parameter='regex')
}}
cacheable: false
Expand Down

0 comments on commit 93455e4

Please sign in to comment.