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.

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