You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
2.4 KiB

  1. #!/bin/bash
  2. exname=$(basename $0)
  3. prefix_cmd="
  4. . /etc/shlib
  5. include common
  6. include parse
  7. . ../lib/common
  8. depends compose
  9. "
  10. ##
  11. ## Mocks
  12. ##
  13. relation-get() {
  14. local key="$1"
  15. echo "$CFG" | shyaml get-value "$key" 2>/dev/null
  16. }
  17. export -f relation-get
  18. get_compose_relations() {
  19. local service="$1"
  20. printf "%s\0" "${RELATIONS[@]}"
  21. }
  22. export -f get_compose_relations
  23. merge_yaml_str() {
  24. printf "<merge_yaml_str("
  25. printf "'%s', " "$@"
  26. printf ")>"
  27. }
  28. export -f merge_yaml_str
  29. compose() {
  30. printf "Calling: compose "
  31. printf "%s " "$*"
  32. echo
  33. }
  34. export -f compose
  35. yaml_key_val_str() {
  36. printf "%s: %s" "$1" "$2"
  37. }
  38. export -f yaml_key_val_str
  39. file_put() {
  40. echo "file_put $1"
  41. cat - | prefix " | "
  42. }
  43. export -f file_put
  44. docker() {
  45. echo "docker" "$@"
  46. echo stdin:
  47. cat - | prefix " | "
  48. }
  49. export -f docker
  50. config-add() {
  51. echo "config-add"
  52. echo "$1" | prefix " | "
  53. }
  54. export -f config-add
  55. mkdir() {
  56. echo "called: $FUNCNAME $@" >&2
  57. }
  58. export -f mkdir
  59. setfacl() {
  60. echo "called: $FUNCNAME $@" >&2
  61. }
  62. export -f setfacl
  63. chgrp() {
  64. echo "called: $FUNCNAME $@" >&2
  65. }
  66. export -f chgrp
  67. chmod() {
  68. echo "called: $FUNCNAME $@" >&2
  69. }
  70. export -f chmod
  71. cached_cmd_on_base_image() {
  72. echo "called: $FUNCNAME $@" >&2
  73. echo "stdout:" >&2
  74. echo "<GID>" | prefix " | " >&2
  75. echo "<GID>"
  76. }
  77. export -f cached_cmd_on_base_image
  78. ##
  79. ## cert-provider
  80. ##
  81. try "
  82. export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE'
  83. export CONFIGSTORE='\$CONFIGSTORE'
  84. export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME'
  85. export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME'
  86. DOMAIN=www.example.com
  87. DOCKER_SITE_PATH=/var/www/\$DOMAIN
  88. CFG='
  89. ssl:
  90. foo: |
  91. a
  92. b
  93. '
  94. RELATIONS=()
  95. apache_vhost_create" "unknown cert key"
  96. is errlvl 1
  97. is err reg 'Error: .*cert-provider.*'
  98. try "
  99. export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE'
  100. export CONFIGSTORE='\$CONFIGSTORE'
  101. export DATASTORE='\$DATASTORE'
  102. export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME'
  103. export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME'
  104. DOMAIN=www.example.com
  105. DOCKER_SITE_PATH=/var/www/\$DOMAIN
  106. CFG='
  107. ssl:
  108. foo: 12
  109. '
  110. RELATIONS=(cert-provider foo a True)
  111. apache_vhost_create" "known cert key"
  112. noerror
  113. is out reg 'Calling: compose .*foo: options: <merge_yaml_str\(.a., .12., )>.*run --rm --service-ports foo.*'
  114. is out part 'config-add
  115. | services:
  116. | $MASTER_TARGET_SERVICE_NAME:
  117. | volumes:
  118. | - $DATASTORE/foo/etc/letsencrypt:/etc/letsencrypt:ro'