From b87b5eab31d38c1685e3c30056c7c18fd55531ff Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Thu, 20 Mar 2014 16:23:28 +0100 Subject: [PATCH] documentation to __object in execution run --- docs/man/cdist-reference.text.sh | 14 ++++++++------ docs/man/man7/cdist-type.text | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/docs/man/cdist-reference.text.sh b/docs/man/cdist-reference.text.sh index 62614c55..6552bf82 100755 --- a/docs/man/cdist-reference.text.sh +++ b/docs/man/cdist-reference.text.sh @@ -157,13 +157,13 @@ TYPES The following types are available: eof - -for type in man7/cdist-type__*.text; do +set -x +for type in man7/cdist-type__*.html; do no_dir="${type#man7/}"; no_type="${no_dir#cdist-type}"; - name="${no_type%.text}"; + name="${no_type%.html}"; name_no_underline="$(echo $name | sed 's/^__/\\__/g')" - man="${no_dir%.text}(7)" + man="${no_dir%.html}(7)" echo "- $name_no_underline" "($man)" done @@ -209,10 +209,12 @@ __messages_out:: Available for: initial manifest, type manifest, type gencode __object:: Directory that contains the current object. - Available for: type manifest, type explorer, type gencode + Available for: type manifest, type explorer, type gencode and + at the execution of the gencode scripts __object_id:: The type unique object id. - Available for: type manifest, type explorer, type gencode + Available for: type manifest, type explorer, type gencode and + at the execution of the gencode scripts Note: The leading and the trailing "/" will always be stripped (caused by the filesystem database and ensured by the core). Note: Double slashes ("//") will not be fixed and result in an error. diff --git a/docs/man/man7/cdist-type.text b/docs/man/man7/cdist-type.text index 8415f991..06026542 100644 --- a/docs/man/man7/cdist-type.text +++ b/docs/man/man7/cdist-type.text @@ -252,6 +252,27 @@ echo "touch /etc/cdist-configured" -------------------------------------------------------------------------------- +VARIABLE ACCESS FROM THE GENERATED SCRIPTS +------------------------------------------ +In the generated scripts, you have access to the following cdist variables + +- __object +- __object_id + +but only for read operations, means there is no back copy of this +files after the script execution. + +So when you generate a script with the following content, it will work: + +-------------------------------------------------------------------------------- +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi +-------------------------------------------------------------------------------- + + HINTS FOR TYPEWRITERS ---------------------- It must be assumed that the target is pretty dumb and thus does not have high