begin restructure, use name __cdist_object_self for type/object_id combination
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								0a028785c3
							
						
					
				
			
			
				commit
				
					
						19e6ea9c80
					
				
			
		
					 1 changed files with 21 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -27,26 +27,39 @@
 | 
			
		|||
. cdist-config
 | 
			
		||||
set -eu
 | 
			
		||||
 | 
			
		||||
################################################################################
 | 
			
		||||
# Prepare object and type
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
__cdist_type="$__cdist_myname"
 | 
			
		||||
 | 
			
		||||
# Find out whether type is a singleton or regular type
 | 
			
		||||
if [ -f "$(__cdist_type_singleton "$__cdist_type")" ]; then
 | 
			
		||||
   __cdist_object_id="singleton"
 | 
			
		||||
   __cdist_object_id="$__cdist_name_singleton"
 | 
			
		||||
else
 | 
			
		||||
   [ $# -ge 1 ] || __cdist_usage "<id> <options>"
 | 
			
		||||
   __cdist_object_id="$1"; shift
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo "$__cdist_object_id" | grep -q "^${__cdist_sane_regexp}\$" || \
 | 
			
		||||
# Verify object id
 | 
			
		||||
__cdist_object_id_sane=$(echo "$__cdist_object_id" | grep "^${__cdist_sane_regexp}\$")
 | 
			
		||||
if [ -z "$__cdist_object_id_sane" ]; then
 | 
			
		||||
   __cdist_usage "Insane object id, ${__cdist_object_id}."
 | 
			
		||||
 | 
			
		||||
# Remove double slash if id begins with /
 | 
			
		||||
if [ "$(echo $__cdist_object_id | grep "^/")" ]; then
 | 
			
		||||
   __cdist_object="${__cdist_type}${__cdist_object_id}"
 | 
			
		||||
else
 | 
			
		||||
   __cdist_object="${__cdist_type}/${__cdist_object_id}"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Prevent double slash if id begins with /
 | 
			
		||||
if [ "$(echo $__cdist_object_id | grep "^/")" ]; then
 | 
			
		||||
   __cdist_object_self="${__cdist_type}${__cdist_object_id}"
 | 
			
		||||
else
 | 
			
		||||
   __cdist_object_self="${__cdist_type}/${__cdist_object_id}"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
################################################################################
 | 
			
		||||
# Verify object
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
__cdist_ddir="$(__cdist_object_dir "$__cdist_object")"
 | 
			
		||||
__cdist_parameter_dir="$(__cdist_object_parameter_dir "$__cdist_object")"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue