From 70485e3516011a7cb10868db9285b6f0b9e8568f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 22:09:44 +0100 Subject: [PATCH] extend cdist-type-emulator with singleton type Signed-off-by: Nico Schottelius --- bin/cdist-config | 11 ++++++----- bin/cdist-type-emulator | 10 ++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index 7f68ca67..bebf449c 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -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}" diff --git a/bin/cdist-type-emulator b/bin/cdist-type-emulator index 69be9405..9c54c714 100755 --- a/bin/cdist-type-emulator +++ b/bin/cdist-type-emulator @@ -25,12 +25,18 @@ # . cdist-config -[ $# -ge 1 ] || __cdist_usage " " 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 " " + __cdist_object_id="$1"; shift +fi + echo "$__cdist_object_id" | grep -q "^${__cdist_sane_regexp}\$" || \ __cdist_usage "Insane object id, ${__cdist_object_id}."