Harden OCI tenancy discovery from profile
This commit is contained in:
parent
10ef95c3eb
commit
a2de0a6b3b
|
|
@ -8060,8 +8060,24 @@ refresh_oci_edge_endpoint() {
|
|||
tenancy_id="$(awk -v profile="[${OCI_CLI_PROFILE:-DEFAULT}]" '
|
||||
$0 == profile { in_profile=1; next }
|
||||
/^\[/ { in_profile=0 }
|
||||
in_profile && $1 ~ /^tenancy=/ { sub(/^tenancy=/, "", $0); print $0; exit }
|
||||
in_profile && $0 ~ /^[[:space:]]*tenancy[[:space:]]*=/ {
|
||||
sub(/^[[:space:]]*tenancy[[:space:]]*=[[:space:]]*/, "", $0)
|
||||
print $0
|
||||
exit
|
||||
}
|
||||
' "${oci_config_file}" 2>/dev/null || true)"
|
||||
# OCI profile names are case-sensitive in the file but operators may
|
||||
# export a differently-cased OCI_CLI_PROFILE. If the selected section
|
||||
# was not found, use the first tenancy entry as a safe fallback.
|
||||
if [[ -z "${tenancy_id}" ]]; then
|
||||
tenancy_id="$(awk '
|
||||
/^[[:space:]]*tenancy[[:space:]]*=/ {
|
||||
sub(/^[[:space:]]*tenancy[[:space:]]*=[[:space:]]*/, "", $0)
|
||||
print $0
|
||||
exit
|
||||
}
|
||||
' "${oci_config_file}" 2>/dev/null || true)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Existing-instance mode can retain an old/null public_ip in state. Query
|
||||
|
|
|
|||
Loading…
Reference in New Issue