Conversation
ae9c5d0 to
7515249
Compare
|
I pushed unit tests for the conditional set-me functionality. I think some of them perhaps should be split up a bit more, but I wasn't sure about the exact granularity we wanted. Please take a look. (You can try running the tests with I also noticed that some of the old tests are still failing, but I think I will not have time to fix those before I go on vacation. |
e70692f to
4836df8
Compare
aarnq
left a comment
There was a problem hiding this comment.
This looks good, though I get three "Do you want to continue" which is a bit too much, can we make it so that it is only printed once after conditionals, validate + schema validate?
That PR has been merged. |
f45ac47 to
475313c
Compare
I'm surprised you got three, I only got two (one after validate and one after schema validate). Now there should only be one, unless I missed the thing that made you get three. Will work on the conditionals for the schema now. |
b75bad0 to
30d1044
Compare
bin/init.bash
Outdated
| if [[ $(yq4 "${2}" "${1}") =~ ^set-me.* ]]; then | ||
| if [[ $(yq4 "${2}" "${1}") == "set-me" ]]; then | ||
| yq4 --inplace "${2} = ${3}" "${1}" | ||
| elif [[ $(yq4 "${2}" "${1}") =~ ^set\-me\-if\-.*$ ]]; then |
There was a problem hiding this comment.
Do the dashes need to be escaped?
There was a problem hiding this comment.
Maybe not. In any case, this function is not used anymore after the config template rework, so I'll just remove it.
config/sc-config.yaml
Outdated
| objectStorageSwift: | ||
| ips: | ||
| - "set-me-if-enabled" | ||
| - set-me-if-(.harbor.persistence.type == "swift") |
robinAwallace
left a comment
There was a problem hiding this comment.
This looks very nice! Just one nit pick, but it LGTM! 🥳
| if [[ $1 == "sc" ]]; then | ||
| check_config "${config_template_path}/common-config.yaml" \ | ||
| "${config_template_path}/sc-config.yaml" \ | ||
| "${config_template_path}/secrets.yaml" | ||
| yq_merge "${config_template_path}/common-config.yaml" \ | ||
| "${config_template_path}/sc-config.yaml" \ | ||
| > "${template_file}" | ||
| check_conditionals "${config[config_file_sc]}" "${template_file}" | ||
| validate "${config[config_file_sc]}" "${template_file}" | ||
| schema_validate "${config[config_file_sc]}" "${config_template_path}/schemas/config.yaml" | ||
| check_conditionals "${secrets[secrets_file]}" "${config_template_path}/secrets.yaml" | ||
| validate "${secrets[secrets_file]}" "${config_template_path}/secrets.yaml" | ||
| schema_validate "${secrets[secrets_file]}" "${config_template_path}/schemas/secrets.yaml" | ||
| elif [[ $1 == "wc" ]]; then |
There was a problem hiding this comment.
Nit: could you extract the common parts for sc/wc and run them after the if-statements?
Something like this?
| if [[ $1 == "sc" ]]; then | |
| check_config "${config_template_path}/common-config.yaml" \ | |
| "${config_template_path}/sc-config.yaml" \ | |
| "${config_template_path}/secrets.yaml" | |
| yq_merge "${config_template_path}/common-config.yaml" \ | |
| "${config_template_path}/sc-config.yaml" \ | |
| > "${template_file}" | |
| check_conditionals "${config[config_file_sc]}" "${template_file}" | |
| validate "${config[config_file_sc]}" "${template_file}" | |
| schema_validate "${config[config_file_sc]}" "${config_template_path}/schemas/config.yaml" | |
| check_conditionals "${secrets[secrets_file]}" "${config_template_path}/secrets.yaml" | |
| validate "${secrets[secrets_file]}" "${config_template_path}/secrets.yaml" | |
| schema_validate "${secrets[secrets_file]}" "${config_template_path}/schemas/secrets.yaml" | |
| elif [[ $1 == "wc" ]]; then | |
| if [[ $1 == "sc" ]]; then | |
| check_config "${config_template_path}/common-config.yaml" \ | |
| "${config_template_path}/sc-config.yaml" \ | |
| "${config_template_path}/secrets.yaml" | |
| yq_merge "${config_template_path}/common-config.yaml" \ | |
| "${config_template_path}/sc-config.yaml" \ | |
| > "${template_file}" | |
| config_to_validate="${config[config_file_sc]}" | |
| elif [[ $1 == "wc" ]]; then | |
| ... | |
| else | |
| ... | |
| fi | |
| check_conditionals "${config_to_validate}" "${template_file}" | |
| validate "${config_to_validate}" "${template_file}" | |
| schema_validate "${config_to_validate}" "${config_template_path}/schemas/config.yaml" | |
| check_conditionals "${secrets[secrets_file]}" "${config_template_path}/secrets.yaml" | |
| validate "${secrets[secrets_file]}" "${config_template_path}/secrets.yaml" | |
| schema_validate "${secrets[secrets_file]}" "${config_template_path}/schemas/secrets.yaml" |
Warning
This is public repository, ensure not to disclose:
What kind of PR is this?
Required: Mark one of the following that is applicable:
Optional: Mark one or more of the following that are applicable:
Important
Breaking changes should be marked
kind/admin-changeorkind/dev-changedepending on typeCritical security fixes should be marked with
kind/securityWhat does this PR do / why do we need this PR?
Adds conditional set-me config that will warn the user if the option is not set and the condition is fulfilled.
Additional information to reviewers
set-me-if-has to be a validyq4condition. I added the parentheses because I felt it made it easier to read, but they are not strictly necessary unless there are multiple conditions.set-mes in the secrets file are not validated at all currently, so it seemed out of scope for this task.set-meonly in the temporary config file, not in the actual config file. Not sure what the desired outcome would be here but this was more natural with how I implemented it, open for feedback on this.set-meoptions should already be dealt with for existing environments, so it wouldn't make much of a difference. Open for feedback on this as well.Screenshots
Checklist
NetworkPolicy Dashboard