forked from ungleich-public/cdist
re-include parameter check
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
6e5ed1c8e8
commit
34b5e44091
1 changed files with 31 additions and 22 deletions
|
@ -79,8 +79,6 @@ __cdist_object_source_add "${__cdist_object_dir}"
|
||||||
|
|
||||||
|
|
||||||
# Record parameter
|
# Record parameter
|
||||||
set -x
|
|
||||||
|
|
||||||
__cdist_parameter_dir="$(__cdist_object_parameter_dir "$__cdist_object_self")"
|
__cdist_parameter_dir="$(__cdist_object_parameter_dir "$__cdist_object_self")"
|
||||||
mkdir -p "${__cdist_parameter_dir}"
|
mkdir -p "${__cdist_parameter_dir}"
|
||||||
|
|
||||||
|
@ -106,44 +104,55 @@ for requirement in $require; do
|
||||||
echo $requirement >> "$(__cdist_object_require "$__cdist_object_self")"
|
echo $requirement >> "$(__cdist_object_require "$__cdist_object_self")"
|
||||||
echo Object $__cdist_object_self requires $requirement
|
echo Object $__cdist_object_self requires $requirement
|
||||||
done
|
done
|
||||||
|
set -u
|
||||||
|
|
||||||
|
|
||||||
exit 1
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Check newly created object
|
# Check newly created object
|
||||||
#
|
#
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
#
|
||||||
# Ensure required parameters are given
|
# Ensure required parameters are given
|
||||||
|
#
|
||||||
if [ -f "$(__cdist_type_parameter_required "$__cdist_type")" ]; then
|
if [ -f "$(__cdist_type_parameter_required "$__cdist_type")" ]; then
|
||||||
while read required; do
|
while read required; do
|
||||||
if [ ! -f "${tempparameter}/${required}" ]; then
|
if [ ! -f "${__cdist_parameter_dir}/${required}" ]; then
|
||||||
__cdist_usage "Missing required parameter $required"
|
__cdist_usage "Missing required parameter $required"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mv "${tempparameter}/${required}" "${__cdist_parameter_dir}"
|
|
||||||
done < "$(__cdist_type_parameter_required "$__cdist_type")"
|
done < "$(__cdist_type_parameter_required "$__cdist_type")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Allow optional parameters
|
#
|
||||||
|
# Ensure that only optional or required parameters are given
|
||||||
|
#
|
||||||
|
|
||||||
if [ -f "$(__cdist_type_parameter_optional "$__cdist_type")" ]; then
|
if [ -f "$(__cdist_type_parameter_optional "$__cdist_type")" ]; then
|
||||||
while read optional; do
|
cat "$(__cdist_type_parameter_optional "$__cdist_type")" > \
|
||||||
if [ -f "${tempparameter}/${optional}" ]; then
|
"$__cdist_tmp_file"
|
||||||
mv "${tempparameter}/${optional}" "${__cdist_parameter_dir}"
|
|
||||||
fi
|
|
||||||
done < "$(__cdist_type_parameter_optional "$__cdist_type")"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Error out on other paramaters
|
if [ -f "$(__cdist_type_parameter_required "$__cdist_type")" ]; then
|
||||||
cd "${tempparameter}"
|
cat "$(__cdist_type_parameter_required "$__cdist_type")" >> \
|
||||||
other="$(ls)"
|
"$__cdist_tmp_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$__cdist_parameter_dir"
|
||||||
|
for parameter in $(ls -1); do
|
||||||
|
is_valid=$(grep "^$parameter\$" "$__cdist_tmp_file")
|
||||||
|
|
||||||
|
[ "$is_valid" ] || "Unknown parameter $parameter"
|
||||||
|
done
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
if [ "$other" ]; then
|
################################################################################
|
||||||
__cdist_usage "Unsupported parameter: $other"
|
# Merge object
|
||||||
fi
|
#
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Ensure that only optional or required parameters are given
|
||||||
|
#
|
||||||
|
|
||||||
# old stuff
|
# old stuff
|
||||||
# if [ -e "${__cdist_new_object_dir}" ]; then
|
# if [ -e "${__cdist_new_object_dir}" ]; then
|
||||||
|
|
Loading…
Reference in a new issue