Browse Source

chg: dev: [apache] refactor out ``yaml_get_values``.

framadate
Valentin Lab 6 years ago
parent
commit
b9bfa7ab8b
  1. 41
      apache/lib/common
  2. 23
      apache/test/custom_rules
  3. 27
      apache/test/vhost
  4. 25
      apache/test/vhost_cert_provider
  5. 24
      apache/test/vhost_files

41
apache/lib/common

@ -616,44 +616,9 @@ EOF
_get_custom_rules() { _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
} }

23
apache/test/custom_rules

@ -2,6 +2,21 @@
exname=$(basename $0) 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=" prefix_cmd="
. /etc/shlib . /etc/shlib
@ -10,7 +25,13 @@ include parse
. ../lib/common . ../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 # mock
cfg-get-value() { cfg-get-value() {

27
apache/test/vhost

@ -2,6 +2,22 @@
exname=$(basename $0) 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=" prefix_cmd="
. /etc/shlib . /etc/shlib
@ -10,7 +26,16 @@ include parse
. ../lib/common . ../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 # mock
relation-get() { relation-get() {

25
apache/test/vhost_cert_provider

@ -2,6 +2,22 @@
exname=$(basename $0) 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=" prefix_cmd="
. /etc/shlib . /etc/shlib
@ -10,9 +26,14 @@ include parse
. ../lib/common . ../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 ## Mocks

24
apache/test/vhost_files

@ -2,6 +2,21 @@
exname=$(basename $0) 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=" prefix_cmd="
. /etc/shlib . /etc/shlib
@ -10,7 +25,14 @@ include parse
. ../lib/common . ../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 ## Mocks

Loading…
Cancel
Save