From 55d6e21a1ddc03ad763e31e3e62fd34785586f5f Mon Sep 17 00:00:00 2001 From: Stephan Leemburg Date: Sun, 31 Jul 2022 19:30:42 +0200 Subject: [PATCH] only-if-file-present --- cdist/conf/type/__line/gencode-remote | 2 +- cdist/conf/type/__line/man.rst | 5 +++-- cdist/conf/type/__line/parameter/boolean | 2 ++ .../parameter/default/{ifexists => only-if-file-present} | 0 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 cdist/conf/type/__line/parameter/boolean rename cdist/conf/type/__line/parameter/default/{ifexists => only-if-file-present} (100%) diff --git a/cdist/conf/type/__line/gencode-remote b/cdist/conf/type/__line/gencode-remote index 95c2360d..db2a79f8 100755 --- a/cdist/conf/type/__line/gencode-remote +++ b/cdist/conf/type/__line/gencode-remote @@ -38,7 +38,7 @@ if [ -z "$state_is" ]; then echo "touch $file" else # only bark if the file should exists - if [ -f "$__object/parameter/ifexists" ]; then + if [ -f "$__object/parameter/only-if-file-present" ]; then exit 0 fi printf 'The file "%s" is missing. Please create it before using %s on it.\n' "$file" "${__type##*/}" >&2 diff --git a/cdist/conf/type/__line/man.rst b/cdist/conf/type/__line/man.rst index dd41fc40..384f0ed9 100644 --- a/cdist/conf/type/__line/man.rst +++ b/cdist/conf/type/__line/man.rst @@ -31,8 +31,9 @@ file If supplied, use this as the destination file. Otherwise the object_id is used. -ifexists - Only apply the line if the file exists. +only-if-file-present + Only apply the line if the file exists. This can be used to prevent + adding the line to a non-existent file. line Specifies the line which should be absent or present. diff --git a/cdist/conf/type/__line/parameter/boolean b/cdist/conf/type/__line/parameter/boolean new file mode 100644 index 00000000..4aa8d4ef --- /dev/null +++ b/cdist/conf/type/__line/parameter/boolean @@ -0,0 +1,2 @@ +create +only-if-file-present diff --git a/cdist/conf/type/__line/parameter/default/ifexists b/cdist/conf/type/__line/parameter/default/only-if-file-present similarity index 100% rename from cdist/conf/type/__line/parameter/default/ifexists rename to cdist/conf/type/__line/parameter/default/only-if-file-present