Browse Source

new: [apache] default value for ``ssl``, is first cert-provider if any.

framadate
Valentin Lab 6 years ago
parent
commit
73ff38dbce
  1. 25
      apache/lib/common
  2. 5
      apache/test/vhost_cert_provider
  3. 4
      apache/test/vhost_files

25
apache/lib/common

@ -72,6 +72,22 @@ is_protocol_enabled() {
export -f is_protocol_enabled export -f is_protocol_enabled
_get_ssl_option_value() {
local target_relation rn ts rc td
relation-get ssl 2>/dev/null && return 0
target_relation="cert-provider"
while read-0 rn ts rc td; do
[ "$rn" == "${target_relation}" ] || continue
info "A cert-provider '$ts' declared as 'ssl' value"
echo "$ts"
return 0
done < <(get_service_relations "$SERVICE_NAME")
return 1
}
__vhost_cfg_normalize_protocol() { __vhost_cfg_normalize_protocol() {
local protocol local protocol
@ -83,7 +99,7 @@ __vhost_cfg_normalize_protocol() {
case "$protocol" in case "$protocol" in
auto) auto)
if __vhost_cfg_ssl="$(relation-get ssl 2>/dev/null)"; then
if __vhost_cfg_ssl="$(_get_ssl_option_value)"; then
protocol="https" protocol="https"
export __vhost_cfg_ssl export __vhost_cfg_ssl
else else
@ -114,7 +130,8 @@ __vhost_cfg_normalize_protocol() {
ssl_get_plugin_fun() { ssl_get_plugin_fun() {
# from ssl conf, return the function that should manage SSL code creation # from ssl conf, return the function that should manage SSL code creation
local cfg="$(relation-get ssl 2>/dev/null)" type keys
local cfg type keys
cfg=$(_get_ssl_option_value)
if [ -z "$cfg" ]; then if [ -z "$cfg" ]; then
return 0 return 0
else else
@ -150,7 +167,7 @@ ssl_get_plugin_fun() {
merged_config=$(merge_yaml_str "$relation_config" "$ssl_cfg") || return 1 merged_config=$(merge_yaml_str "$relation_config" "$ssl_cfg") || return 1
printf "%s\0" "$fun" "$key" "$merged_config" printf "%s\0" "$fun" "$key" "$merged_config"
return 0 return 0
done < <(get_compose_relations "$SERVICE_NAME") || return 1
done < <(get_service_relations "$SERVICE_NAME") || return 1
case "$key" in case "$key" in
cert|ca-cert|key) cert|ca-cert|key)
: :
@ -271,7 +288,7 @@ apache_vhost_statement() {
__vhost_full_vhost_statement http __vhost_full_vhost_statement http
fi fi
if is_protocol_enabled https; then if is_protocol_enabled https; then
"$SSL_PLUGIN_FUN"_vars "$(relation-get ssl 2>/dev/null)"
"$SSL_PLUGIN_FUN"_vars "$(_get_ssl_option_value 2>/dev/null)"
cat <<EOF cat <<EOF
<IfModule mod_ssl.c> <IfModule mod_ssl.c>

5
apache/test/vhost_cert_provider

@ -24,11 +24,10 @@ relation-get() {
} }
export -f relation-get export -f relation-get
get_compose_relations() {
local service="$1"
get_service_relations() {
printf "%s\0" "${RELATIONS[@]}" printf "%s\0" "${RELATIONS[@]}"
} }
export -f get_compose_relations
export -f get_service_relations
merge_yaml_str() { merge_yaml_str() {
printf "<merge_yaml_str(" printf "<merge_yaml_str("

4
apache/test/vhost_files

@ -22,6 +22,10 @@ relation-get() {
} }
export -f relation-get export -f relation-get
get_service_relations() {
printf "%s\0" "${RELATIONS[@]}"
}
export -f get_service_relations
file_put() { file_put() {
echo "file_put $1" echo "file_put $1"

Loading…
Cancel
Save