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

Add context to update-ips port parsing error #1975

Merged
merged 1 commit into from
Jan 25, 2024
Merged
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
12 changes: 6 additions & 6 deletions bin/update-ips.bash
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,15 @@ parse_url_host() {

# Parse the port from an URL.
#
# Usage: parse_url_port <url>
# Usage: parse_url_port <url> <config_option>
parse_url_port() {
port="$(echo "${1}" | sed 's/https\?:\/\///' | sed 's/[A-Za-z.0-9-]*:\?//' | sed 's/\/.*//')"
[ -n "${port}" ] && echo "${port}" && return
case "${1}" in
http://*) echo 80 ;;
https://*) echo 443 ;;
*)
log_error "Could not determine default port for: ${1}"
log_error "Could not determine default port for ${2}, missing protocol: ${1}"
exit 1
;;
esac
Expand Down Expand Up @@ -405,7 +405,7 @@ allow_object_storage() {
local port
url=$(yq_read "${cluster}" '.objectStorage.s3.regionEndpoint' "")
host=$(parse_url_host "${url}")
port=$(parse_url_port "${url}")
port=$(parse_url_port "${url}" '.objectStorage.s3.regionEndpoint')

allow_host "${config["override_common"]}" '.networkPolicies.global.objectStorage.ips' "${host}"
allow_ports "${config["override_common"]}" '.networkPolicies.global.objectStorage.ports' "${port}"
Expand Down Expand Up @@ -448,7 +448,7 @@ sync_swift() {
local os_auth_host
local os_auth_port
os_auth_host=$(parse_url_host "${os_auth_url}")
os_auth_port=$(parse_url_port "${os_auth_url}")
os_auth_port=$(parse_url_port "${os_auth_url}" "${swift_config_option}.authUrl")

local -a object_storage_swift_ips
local -a object_storage_swift_ports
Expand All @@ -462,7 +462,7 @@ sync_swift() {
local swift_port
swift_url="$(get_swift_url "${swift_config_option}")"
swift_host=$(parse_url_host "${swift_url}")
swift_port=$(parse_url_port "${swift_url}")
swift_port=$(parse_url_port "${swift_url}" "${swift_config_option}")

# shellcheck disable=SC2207
object_storage_swift_ips+=($(get_dns_ips "${swift_host}"))
Expand Down Expand Up @@ -493,7 +493,7 @@ sync_rclone() {
local host
local port
host=$(parse_url_host "${url}")
port=$(parse_url_port "${url}")
port=$(parse_url_port "${url}" "${endpoint_config_option}")

allow_domain "${config["override_sc"]}" "${netpol_config_option}.ips" "${host}"
allow_ports "${config["override_sc"]}" "${netpol_config_option}.ports" "${port}"
Expand Down