From 90f7ec40fe812c47a81c27d8b4d18f6a7c39a857 Mon Sep 17 00:00:00 2001
From: nuex <nx@nu-ex.com>
Date: Mon, 17 Jun 2013 12:10:19 -0400
Subject: [PATCH] __postgres_database: make state parameter optional

---
 cdist/conf/type/__postgres_database/gencode-remote     | 3 ++-
 cdist/conf/type/__postgres_database/man.text           | 7 ++-----
 cdist/conf/type/__postgres_database/parameter/optional | 1 +
 cdist/conf/type/__postgres_database/parameter/required | 1 -
 4 files changed, 5 insertions(+), 7 deletions(-)
 delete mode 100644 cdist/conf/type/__postgres_database/parameter/required

diff --git a/cdist/conf/type/__postgres_database/gencode-remote b/cdist/conf/type/__postgres_database/gencode-remote
index c097efce..0ffc842a 100755
--- a/cdist/conf/type/__postgres_database/gencode-remote
+++ b/cdist/conf/type/__postgres_database/gencode-remote
@@ -19,7 +19,8 @@
 #
 
 name="$__object_id"
-state_should="$(cat "$__object/parameter/state")"
+state_should="present"
+[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
 state_is="$(cat "$__object/explorer/state")"
 
 if [ "$state_should" != "$state_is" ]; then
diff --git a/cdist/conf/type/__postgres_database/man.text b/cdist/conf/type/__postgres_database/man.text
index d01ca8f6..88259b6f 100644
--- a/cdist/conf/type/__postgres_database/man.text
+++ b/cdist/conf/type/__postgres_database/man.text
@@ -13,14 +13,11 @@ DESCRIPTION
 This cdist type allows you to create or drop postgres databases.
 
 
-REQUIRED PARAMETERS
+OPTIONAL PARAMETERS
 -------------------
 state::
    either 'present' or 'absent'
 
-
-OPTIONAL PARAMETERS
--------------------
 owner::
    the role owning this database
 
@@ -29,7 +26,7 @@ EXAMPLES
 --------
 
 --------------------------------------------------------------------------------
-__postgres_database mydbname --state present --owner mydbusername
+__postgres_database mydbname --owner mydbusername
 --------------------------------------------------------------------------------
 
 
diff --git a/cdist/conf/type/__postgres_database/parameter/optional b/cdist/conf/type/__postgres_database/parameter/optional
index 7ee3bde8..d86b6469 100644
--- a/cdist/conf/type/__postgres_database/parameter/optional
+++ b/cdist/conf/type/__postgres_database/parameter/optional
@@ -1 +1,2 @@
+state
 owner
diff --git a/cdist/conf/type/__postgres_database/parameter/required b/cdist/conf/type/__postgres_database/parameter/required
deleted file mode 100644
index ff72b5c7..00000000
--- a/cdist/conf/type/__postgres_database/parameter/required
+++ /dev/null
@@ -1 +0,0 @@
-state