begin to sort cdist-config by alphabet

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
remotes/origin/1.4
Nico Schottelius 14 years ago
parent 25bf9e4185
commit 359e252ef7
  1. 152
      bin/cdist-config

@ -134,7 +134,7 @@ __cdist_tmp_file=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX")
: ${__cdist_remote_out_object_base_dir:=$__cdist_remote_out_dir/$__cdist_name_object}
################################################################################
# Function list
# Internal functions
#
__cdist_debug_echo()
{
@ -143,6 +143,12 @@ __cdist_debug_echo()
fi
}
__cdist_exec_fail_on_error()
{
sh -e "$@"
[ "$?" -eq 0 ] || __cdist_exit_err "Error: $1 exited non-zero."
}
__cdist_exit_err()
{
echo "$@" >&2
@ -170,59 +176,60 @@ __cdist_init_deploy()
ln -sf "$__cdist_conf_dir" "$__cdist_local_base_dir/$__cdist_name_conf_dir"
}
__cdist_type_has_explorer()
{
# We only create output, if there's at least one explorer
# and can thus be used as a boolean ;-)
if [ -d "$(__cdist_type_explorer_dir "$1")" ]; then
ls -1 "$(__cdist_type_explorer_dir "$1")"
fi
}
################################################################################
# Object
#
__cdist_type_dir()
__cdist_object_code()
{
echo "${__cdist_type_dir}/$1"
echo "$(__cdist_object_dir "$1")/${__cdist_name_code}"
}
__cdist_type_explorer_dir()
__cdist_object_code_finished()
{
echo "${__cdist_type_dir}/$1/${__cdist_name_explorer}"
echo "$(__cdist_object_dir "$1")/${__cdist_name_code_finished}"
}
__cdist_remote_type_explorer_dir()
# Find objects, remove ./ and /MARKER
__cdist_object_list()
{
echo "${__cdist_remote_type_dir}/$1/${__cdist_name_explorer}"
}
local basedir="$1"; shift
# Use subshell to prevent changing cwd in program
(
cd "${basedir}"
find . -name "$__cdist_name_object_source" | \
sed -e 's;^./;;' -e "s;/${__cdist_name_object_source}\$;;"
)
__cdist_type_gencode()
{
echo "${__cdist_type_dir}/$1/${__cdist_name_gencode}"
}
__cdist_type_singleton()
__cdist_object_source()
{
echo "${__cdist_type_dir}/$1/${__cdist_name_singleton}"
local object_dir="$1"; shift
cat "${object_dir}/${__cdist_name_object_source}"
}
__cdist_type_parameter_dir()
__cdist_object_parameter_dir()
{
echo "$(__cdist_type_dir "$1")/${__cdist_name_parameter}"
echo "$(__cdist_object_dir "$1")/${__cdist_name_parameter}"
}
# Shorthand for required and optional
__cdist_type_parameter_required()
__cdist_remote_object_parameter_dir()
{
echo "$(__cdist_type_parameter_dir "$1")/$__cdist_name_parameter_required"
echo "$(__cdist_remote_object_dir "$1")/${__cdist_name_parameter}"
}
__cdist_type_parameter_optional()
__cdist_object_require()
{
echo "$(__cdist_type_parameter_dir "$1")/$__cdist_name_parameter_optional"
echo "$(__cdist_object_dir "$1")/${__cdist_name_require}"
}
__cdist_type_from_object()
__cdist_object_type_explorer_dir()
{
echo "${1%%/*}"
echo "$(__cdist_object_dir "$1")/${__cdist_name_explorer}"
}
__cdist_object_id_from_object()
@ -236,81 +243,86 @@ __cdist_object_dir()
echo "$__cdist_object_dir"
}
################################################################################
# Remote
#
__cdist_remote_object_dir()
{
echo "${__cdist_remote_out_object_base_dir}/$1"
}
__cdist_object_code()
__cdist_remote_object_type_explorer_dir()
{
echo "$(__cdist_object_dir "$1")/${__cdist_name_code}"
echo "$(__cdist_remote_object_dir "$1")/${__cdist_name_explorer}"
}
__cdist_object_code_finished()
__cdist_remote_type_explorer_dir()
{
echo "$(__cdist_object_dir "$1")/${__cdist_name_code_finished}"
echo "${__cdist_remote_type_dir}/$1/${__cdist_name_explorer}"
}
__cdist_object_parameter_dir()
################################################################################
# Temp clenup
#
__cdist_tmp_removal()
{
echo "$(__cdist_object_dir "$1")/${__cdist_name_parameter}"
rm -rf "${__cdist_tmp_dir}"
}
__cdist_remote_object_parameter_dir()
trap __cdist_tmp_removal EXIT
################################################################################
# Type
#
__cdist_type_dir()
{
echo "$(__cdist_remote_object_dir "$1")/${__cdist_name_parameter}"
echo "${__cdist_type_dir}/$1"
}
__cdist_object_require()
__cdist_type_explorer_dir()
{
echo "$(__cdist_object_dir "$1")/${__cdist_name_require}"
echo "${__cdist_type_dir}/$1/${__cdist_name_explorer}"
}
__cdist_object_type_explorer_dir()
__cdist_type_from_object()
{
echo "$(__cdist_object_dir "$1")/${__cdist_name_explorer}"
echo "${1%%/*}"
}
__cdist_remote_object_type_explorer_dir()
__cdist_type_has_explorer()
{
echo "$(__cdist_remote_object_dir "$1")/${__cdist_name_explorer}"
# We only create output, if there's at least one explorer
# and can thus be used as a boolean ;-)
if [ -d "$(__cdist_type_explorer_dir "$1")" ]; then
ls -1 "$(__cdist_type_explorer_dir "$1")"
fi
}
# Find objects, remove ./ and /MARKER
__cdist_object_list()
__cdist_type_gencode()
{
local basedir="$1"; shift
# Use subshell to prevent changing cwd in program
(
cd "${basedir}"
find . -name "$__cdist_name_object_source" | \
sed -e 's;^./;;' -e "s;/${__cdist_name_object_source}\$;;"
)
echo "${__cdist_type_dir}/$1/${__cdist_name_gencode}"
}
__cdist_object_source()
__cdist_type_parameter_dir()
{
local object_dir="$1"; shift
cat "${object_dir}/${__cdist_name_object_source}"
echo "$(__cdist_type_dir "$1")/${__cdist_name_parameter}"
}
__cdist_exec_fail_on_error()
__cdist_type_parameter_optional()
{
sh -e "$@"
[ "$?" -eq 0 ] || __cdist_exit_err "Error: $1 exited non-zero."
echo "$(__cdist_type_parameter_dir "$1")/$__cdist_name_parameter_optional"
}
__cdist_tmp_removal()
__cdist_type_parameter_required()
{
rm -rf "${__cdist_tmp_dir}"
echo "$(__cdist_type_parameter_dir "$1")/$__cdist_name_parameter_required"
}
################################################################################
# Trap for tmp removal
#
trap __cdist_tmp_removal EXIT
__cdist_type_singleton()
{
echo "${__cdist_type_dir}/$1/${__cdist_name_singleton}"
}

Loading…
Cancel
Save