Moved default parameter values from scripts to cdist parameter handling.

For more generalisation, the default parameter values are now handled by
cdist instead of trying to get a value and use a default if parameter is
not given.

It handles the default values in a more general way, instead of write
one default in (possibly) multiple places.
Problem occurred when checking the 'state' parameter, which required to
set a default value in two places.
remotes/origin/beta
Matthias Stecher 5 years ago
parent a761d4842c
commit 5e6e17b3e5
  1. 12
      cdist/conf/type/__cron/gencode-remote
  2. 2
      cdist/conf/type/__cron/manifest
  3. 1
      cdist/conf/type/__cron/parameter/default/day_of_month
  4. 1
      cdist/conf/type/__cron/parameter/default/day_of_week
  5. 1
      cdist/conf/type/__cron/parameter/default/hour
  6. 1
      cdist/conf/type/__cron/parameter/default/minute
  7. 1
      cdist/conf/type/__cron/parameter/default/month
  8. 1
      cdist/conf/type/__cron/parameter/default/state

@ -31,11 +31,11 @@ if [ -f "$__object/parameter/raw" ]; then
elif [ -f "$__object/parameter/raw_command" ]; then
entry="$command"
else
minute="$(cat "$__object/parameter/minute" 2>/dev/null || echo "*")"
hour="$(cat "$__object/parameter/hour" 2>/dev/null || echo "*")"
day_of_month="$(cat "$__object/parameter/day_of_month" 2>/dev/null || echo "*")"
month="$(cat "$__object/parameter/month" 2>/dev/null || echo "*")"
day_of_week="$(cat "$__object/parameter/day_of_week" 2>/dev/null || echo "*")"
minute="$(cat "$__object/parameter/minute")"
hour="$(cat "$__object/parameter/hour")"
day_of_month="$(cat "$__object/parameter/day_of_month")"
month="$(cat "$__object/parameter/month")"
day_of_week="$(cat "$__object/parameter/day_of_week")"
entry="$minute $hour $day_of_month $month $day_of_week $command # $name"
fi
@ -52,7 +52,7 @@ else
state_is=absent
fi
state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo "present")"
state_should="$(cat "$__object/parameter/state")"
[ "$state_is" = "$state_should" ] && exit 0

@ -23,7 +23,7 @@ if [ -f "$__object/parameter/raw" ] && [ -f "$__object/parameter/raw_command" ];
exit 1
fi
case "$(cat "$__object/parameter/state" 2>/dev/null || echo "present")" in
case "$(cat "$__object/parameter/state")" in
present) ;;
absent) ;;

Loading…
Cancel
Save