diff --git a/apache/lib/common b/apache/lib/common index 3bf0109..dc72b51 100644 --- a/apache/lib/common +++ b/apache/lib/common @@ -616,44 +616,9 @@ EOF _get_custom_rules() { - local cfg="$1" custom_rules type elt value first - custom_rules=$(e "$cfg" | cfg-get-value apache-custom-rules 2>/dev/null) || true - if [ -z "$custom_rules" -o "$custom_rules" == "None" ]; then - return 0 - fi - type=$(echo "$custom_rules" | shyaml get-type) - value= - case "$type" in - "sequence") - first=1 - while read-0 elt; do - elt="$(echo "$elt" | yaml_get_interpret)" || return 1 - [ "$elt" ] || continue - if [ "$first" ]; then - first= - else - value+=$'\n' - fi - first= - value+="$elt" - done < <(echo "$custom_rules" | shyaml -y get-values-0) - ;; - "struct") - while read-0 _key val; do - value+=$'\n'"$(echo "$val" | yaml_get_interpret)" || return 1 - done < <(echo "$custom_rules" | shyaml -y key-values-0) - ;; - "str") - value+=$(echo "$custom_rules") - ;; - "NoneType") - value="" - ;; - *) - value+=$(echo "$custom_rules") - ;; - esac - printf "%s" "$value" + local cfg="$1" custom_rules + custom_rules=$(e "$cfg" | shyaml -y -q get-value apache-custom-rules 2>/dev/null) || true + e "$custom_rules" | yaml_get_values } diff --git a/apache/test/custom_rules b/apache/test/custom_rules index 1207838..df1d80e 100644 --- a/apache/test/custom_rules +++ b/apache/test/custom_rules @@ -2,6 +2,21 @@ exname=$(basename $0) +compose_core=$(which compose-core) || { + echo "Requires compose-core executable to be in \$PATH." >&2 + exit 1 +} + +fetch-def() { + local path="$1" fname="$2" + ( . "$path" 1>&2 || { + echo "Failed to load '$path'." >&2 + exit 1 + } + declare -f "$fname" + ) +} + prefix_cmd=" . /etc/shlib @@ -10,7 +25,13 @@ include parse . ../lib/common -" +$(fetch-def "$compose_core" yaml_get_values) +$(fetch-def "$compose_core" yaml_get_interpret) + +" || { + echo "Couldn't build prefix cmd" >&2 + exit 1 +} # mock cfg-get-value() { diff --git a/apache/test/vhost b/apache/test/vhost index 8e812e0..58e150d 100644 --- a/apache/test/vhost +++ b/apache/test/vhost @@ -2,6 +2,22 @@ exname=$(basename $0) +compose_core=$(which compose-core) || { + echo "Requires compose-core executable to be in \$PATH." >&2 + exit 1 +} + +fetch-def() { + local path="$1" fname="$2" + ( . "$path" 1>&2 || { + echo "Failed to load '$path'." >&2 + exit 1 + } + declare -f "$fname" + ) +} + + prefix_cmd=" . /etc/shlib @@ -10,7 +26,16 @@ include parse . ../lib/common -" +$(fetch-def "$compose_core" yaml_get_values) +$(fetch-def "$compose_core" yaml_get_interpret) + +" || { + echo "Couldn't build prefix cmd" >&2 + exit 1 +} + + + # mock relation-get() { diff --git a/apache/test/vhost_cert_provider b/apache/test/vhost_cert_provider index 093175d..6754dba 100644 --- a/apache/test/vhost_cert_provider +++ b/apache/test/vhost_cert_provider @@ -2,6 +2,22 @@ exname=$(basename $0) +compose_core=$(which compose-core) || { + echo "Requires compose-core executable to be in \$PATH." >&2 + exit 1 +} + +fetch-def() { + local path="$1" fname="$2" + ( . "$path" 1>&2 || { + echo "Failed to load '$path'." >&2 + exit 1 + } + declare -f "$fname" + ) +} + + prefix_cmd=" . /etc/shlib @@ -10,9 +26,14 @@ include parse . ../lib/common -depends compose +$(fetch-def "$compose_core" yaml_get_values) +$(fetch-def "$compose_core" yaml_get_interpret) + +" || { + echo "Couldn't build prefix cmd" >&2 + exit 1 +} -" ## ## Mocks diff --git a/apache/test/vhost_files b/apache/test/vhost_files index 3a2884b..4a17fa5 100644 --- a/apache/test/vhost_files +++ b/apache/test/vhost_files @@ -2,6 +2,21 @@ exname=$(basename $0) +compose_core=$(which compose-core) || { + echo "Requires compose-core executable to be in \$PATH." >&2 + exit 1 +} + +fetch-def() { + local path="$1" fname="$2" + ( . "$path" 1>&2 || { + echo "Failed to load '$path'." >&2 + exit 1 + } + declare -f "$fname" + ) +} + prefix_cmd=" . /etc/shlib @@ -10,7 +25,14 @@ include parse . ../lib/common -" +$(fetch-def "$compose_core" yaml_get_values) +$(fetch-def "$compose_core" yaml_get_interpret) + +" || { + echo "Couldn't build prefix cmd" >&2 + exit 1 +} + ## ## Mocks