2 Commits

  1. 2
      cron/hooks/pre_deploy
  2. 2
      cron/lib/common
  3. 19
      cron/test/entries_from_service

2
cron/hooks/pre_deploy

@ -6,7 +6,7 @@ set -e
root_crontab="$SERVICE_CONFIGSTORE/etc/crontabs/root" root_crontab="$SERVICE_CONFIGSTORE/etc/crontabs/root"
cron_content=$(set pipefail; cron:entries | tr '\0' '\n') || {
cron_content=$(set -o pipefail; cron:entries | tr '\0' '\n') || {
err "Failed to make cron entries" >&2 err "Failed to make cron entries" >&2
exit 1 exit 1
} }

2
cron/lib/common

@ -73,7 +73,7 @@ cron:get_config() {
;; ;;
esac > "$cache_file.tmp" esac > "$cache_file.tmp"
mv -v "$cache_file.tmp" "$cache_file" >&2
mv "$cache_file.tmp" "$cache_file" >&2
## if cache file is empty, this is an error ## if cache file is empty, this is an error
if [ ! -s "$cache_file" ]; then if [ ! -s "$cache_file" ]; then

19
cron/test/entries_from_service

@ -45,11 +45,6 @@ cfg-get-value() {
} }
export -f cfg-get-value export -f cfg-get-value
yaml_get_interpret() {
shyaml get-value
}
export -f yaml_get_interpret
get_top_master_service_for_service() { get_top_master_service_for_service() {
local service="$1" local service="$1"
echo "$service" echo "$service"
@ -62,6 +57,12 @@ get_service_charm() {
} }
export -f get_service_charm export -f get_service_charm
charm.get_dir() {
local charm="$1"
echo "/path/to/charm-store/$charm"
}
export -f charm.get_dir
export CACHEDIR=$(mktemp -d -t tmp.XXXXXXXXXX) export CACHEDIR=$(mktemp -d -t tmp.XXXXXXXXXX)
export state_tmpdir=$(mktemp -d -t tmp.XXXXXXXXXX) export state_tmpdir=$(mktemp -d -t tmp.XXXXXXXXXX)
trap "rm -rf \"$state_tmpdir\"" EXIT trap "rm -rf \"$state_tmpdir\"" EXIT
@ -107,7 +108,7 @@ is out '' TRIM
try " try "
set pipefail &&
set -o pipefail &&
cron:entries_from_service 'foo' ' cron:entries_from_service 'foo' '
(0 0 * * *) {-p 10 -k} dc run --rm foo (0 0 * * *) {-p 10 -k} dc run --rm foo
' | tr '\0' '\n'" "one command no label" ' | tr '\0' '\n'" "one command no label"
@ -118,7 +119,7 @@ is out "\
try " try "
set pipefail &&
set -o pipefail &&
cron:entries_from_service 'foo' ' cron:entries_from_service 'foo' '
wiz: (0 0 * * *) {-p 10 -k} dc run --rm foo wiz: (0 0 * * *) {-p 10 -k} dc run --rm foo
' | tr '\0' '\n'" "one command with label" ' | tr '\0' '\n'" "one command with label"
@ -130,7 +131,7 @@ is out "\
try " try "
set pipefail &&
set -o pipefail &&
cron:entries_from_service 'foo' ' cron:entries_from_service 'foo' '
wiz: (0 0 * * *) {-p 10 -k} dc run --rm foo wiz: (0 0 * * *) {-p 10 -k} dc run --rm foo
bam: (@daily) {-p 10 -D -k} dc run --rm foo --hop bam: (@daily) {-p 10 -D -k} dc run --rm foo --hop
@ -145,7 +146,7 @@ is out "\
try " try "
set pipefail &&
set -o pipefail &&
cron:entries_from_service 'foo' '!var-expand cron:entries_from_service 'foo' '!var-expand
(0 0 * * *) {-p 10 -k} dc run --rm \$BASE_SERVICE_NAME \$MASTER_BASE_SERVICE_NAME (0 0 * * *) {-p 10 -k} dc run --rm \$BASE_SERVICE_NAME \$MASTER_BASE_SERVICE_NAME
' | tr '\0' '\n'" "using relation's var" ' | tr '\0' '\n'" "using relation's var"

Loading…
Cancel
Save