extend cdist-type-emulator with singleton type

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-03-09 22:09:44 +01:00
parent 41d82ea89a
commit 70485e3516
2 changed files with 14 additions and 7 deletions

View File

@ -57,6 +57,7 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname"
: ${__cdist_name_parameter:=parameter}
: ${__cdist_name_parameter_required:=required}
: ${__cdist_name_parameter_optional:=optional}
: ${__cdist_name_singleton:=singleton}
: ${__cdist_name_target_host:=target_host}
: ${__cdist_name_type:=type}
: ${__cdist_name_type_bin:=type_bin}
@ -162,11 +163,6 @@ __cdist_init_deploy()
ln -sf "$__cdist_conf_dir" "$__cdist_local_base_dir/$__cdist_name_conf_dir"
}
# __cdist_cache_host()
# {
# echo "${__cdist_cache_hosts}/${__cdist_target_host}"
# }
__cdist_type_has_explorer()
{
# We only create output, if there's at least one explorer
@ -196,6 +192,11 @@ __cdist_type_gencode()
echo "${__cdist_type_dir}/$1/${__cdist_name_gencode}"
}
__cdist_type_singleton()
{
echo "${__cdist_type_dir}/$1/${__cdist_name_singleton}"
}
__cdist_type_parameter_dir()
{
echo "$(__cdist_type_dir "$1")/${__cdist_name_parameter}"

View File

@ -25,12 +25,18 @@
#
. cdist-config
[ $# -ge 1 ] || __cdist_usage "<id> <options>"
set -eu
__cdist_object_id="$1"; shift
# Find out whether type is a singleton or regular type
__cdist_type="$__cdist_myname"
if [ -f "$(__cdist_type_singleton "$__cdist_type")" ]; then
__cdist_object_id="singleton"
else
[ $# -ge 1 ] || __cdist_usage "<id> <options>"
__cdist_object_id="$1"; shift
fi
echo "$__cdist_object_id" | grep -q "^${__cdist_sane_regexp}\$" || \
__cdist_usage "Insane object id, ${__cdist_object_id}."