forked from ungleich-public/cdist
allow parameters to be missing, if not used
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
dc2a49afe8
commit
e1a5a26cbf
2 changed files with 26 additions and 11 deletions
|
@ -207,6 +207,17 @@ __cdist_type_parameter_file()
|
|||
echo "$(__cdist_type_parameter_dir "$1")/$2"
|
||||
}
|
||||
|
||||
# Shorthand for required and optional
|
||||
__cdist_type_parameter_required()
|
||||
{
|
||||
__cdist_type_parameter_file "$1/$__cdist_name_parameter_required"
|
||||
}
|
||||
|
||||
__cdist_type_parameter_optional()
|
||||
{
|
||||
__cdist_type_parameter_file "$1/$__cdist_name_parameter_optional"
|
||||
}
|
||||
|
||||
__cdist_type_from_object()
|
||||
{
|
||||
echo "${1%%/*}"
|
||||
|
|
|
@ -78,20 +78,24 @@ while [ $# -gt 0 ]; do
|
|||
done
|
||||
|
||||
# Ensure required parameters are given
|
||||
while read required; do
|
||||
if [ ! -f "${tempparameter}/${required}" ]; then
|
||||
__cdist_usage "Missing required parameter $required"
|
||||
fi
|
||||
if [ -f "$(__cdist_type_parameter_required "$__cdist_type")" ]; then
|
||||
while read required; do
|
||||
if [ ! -f "${tempparameter}/${required}" ]; then
|
||||
__cdist_usage "Missing required parameter $required"
|
||||
fi
|
||||
|
||||
mv "${tempparameter}/${required}" "${__cdist_parameter_dir}"
|
||||
done < "$(__cdist_type_parameter_file "$__cdist_type" "$__cdist_name_parameter_required")"
|
||||
mv "${tempparameter}/${required}" "${__cdist_parameter_dir}"
|
||||
done < "$(__cdist_type_parameter_required "$__cdist_type")"
|
||||
fi
|
||||
|
||||
# Allow optional parameters
|
||||
while read optional; do
|
||||
if [ -f "${tempparameter}/${optional}" ]; then
|
||||
mv "${tempparameter}/${optional}" "${__cdist_parameter_dir}"
|
||||
fi
|
||||
done < "$(__cdist_type_parameter_file "$__cdist_type" "$__cdist_name_parameter_optional")"
|
||||
if [ -f "$(__cdist_type_parameter_optional "$__cdist_type")" ]; then
|
||||
while read optional; do
|
||||
if [ -f "${tempparameter}/${optional}" ]; then
|
||||
mv "${tempparameter}/${optional}" "${__cdist_parameter_dir}"
|
||||
fi
|
||||
done < "$(__cdist_type_parameter_optional "$__cdist_type")"
|
||||
fi
|
||||
|
||||
# Error out on other paramaters
|
||||
cd "${tempparameter}"
|
||||
|
|
Loading…
Reference in a new issue