From b75481a4d41cb45c25cccdf2bfb053a10e7b9ede Mon Sep 17 00:00:00 2001
From: Daniel Heule <hda@sfs.biz>
Date: Tue, 21 Jan 2014 23:18:10 +0100
Subject: [PATCH] parameter default handling in __key_value type corrected

---
 cdist/conf/type/__key_value/gencode-remote          | 4 ++--
 cdist/conf/type/__key_value/manifest                | 3 +--
 cdist/conf/type/__key_value/parameter/default/state | 1 +
 3 files changed, 4 insertions(+), 4 deletions(-)
 create mode 100644 cdist/conf/type/__key_value/parameter/default/state

diff --git a/cdist/conf/type/__key_value/gencode-remote b/cdist/conf/type/__key_value/gencode-remote
index ec91894f..b79d9688 100755
--- a/cdist/conf/type/__key_value/gencode-remote
+++ b/cdist/conf/type/__key_value/gencode-remote
@@ -21,8 +21,8 @@
 
 key="$__object_id"
 [ -f "$__object/parameter/key" ] && key="$(cat "$__object/parameter/key")"
-state_should=present
-[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
+
+state_should="$(cat "$__object/parameter/state")"
 
 file="$(cat "$__object/parameter/file")"
 delimiter="$(cat "$__object/parameter/delimiter")"
diff --git a/cdist/conf/type/__key_value/manifest b/cdist/conf/type/__key_value/manifest
index 8ed9cc9c..56f4c874 100755
--- a/cdist/conf/type/__key_value/manifest
+++ b/cdist/conf/type/__key_value/manifest
@@ -19,8 +19,7 @@
 # along with cdist. If not, see <http://www.gnu.org/licenses/>.
 #
 
-state_should=present
-[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
+state_should="$(cat "$__object/parameter/state")"
 
 if [ "$state_should" = "present" -a ! -f "$__object/parameter/value" ]; then
    echo "Missing required parameter 'value'" >&2
diff --git a/cdist/conf/type/__key_value/parameter/default/state b/cdist/conf/type/__key_value/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__key_value/parameter/default/state
@@ -0,0 +1 @@
+present