Skip to content

Commit 03b79ae

Browse files
committed
Set required params and autorequire
Some fields are always required and things break if they are not set. It's also possible to automatically require the password files which gives a better guarantee that things are executed in the correct order.
1 parent 6a9bc39 commit 03b79ae

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/puppet_x/certs/common.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ module Common
5555
end
5656

5757
newparam(:ca) do
58+
isrequired
59+
5860
validate do |value|
5961
ca_resource = resource.catalog.resource(value.to_s)
6062
if ca_resource && ca_resource.class.to_s != 'Puppet::Type::Ca'
@@ -68,12 +70,18 @@ module Common
6870
catalog.resource(@parameters[:ca].value.to_s).to_hash[:name]
6971
end
7072
end
73+
74+
autorequire(:file) do
75+
[self[:password_file]].compact
76+
end
7177
end
7278

7379
FILE_COMMON_PARAMS = Proc.new do
7480
ensurable
7581

76-
newparam(:path, :namevar => true)
82+
newparam(:path, :namevar => true) do
83+
isrequired
84+
end
7785

7886
newparam(:password_file)
7987

@@ -84,6 +92,8 @@ module Common
8492
define_method(:managed?) { true }
8593

8694
newparam(:key_pair) do
95+
isrequired
96+
8797
validate do |value|
8898
param_resource = resource.catalog.resource(value.to_s)
8999

@@ -120,6 +130,7 @@ module Common
120130
# Copied from Puppet's lib/puppet/type/file.rb
121131
autorequire(:file) do
122132
req = []
133+
req << self[:password_file] if self[:password_file]
123134
path = Pathname.new(self[:path])
124135
if !path.root?
125136
# Start at our parent, to avoid autorequiring ourself

0 commit comments

Comments
 (0)