choria-mcorpc-support 2.20.6 → 2.20.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mcollective.rb +1 -1
- data/lib/mcollective/ddl/agentddl.rb +13 -11
- data/lib/mcollective/ddl/base.rb +19 -18
- data/lib/mcollective/ddl/dataddl.rb +5 -5
- data/lib/mcollective/ddl/discoveryddl.rb +2 -2
- data/lib/mcollective/ddl/validatorddl.rb +1 -1
- data/lib/mcollective/pluginpackager/agent_definition.rb +16 -10
- data/lib/mcollective/pluginpackager/forge_packager.rb +56 -49
- data/lib/mcollective/pluginpackager/templates/forge/manifests/init.pp.erb +2 -0
- data/lib/mcollective/validator/array_validator.rb +1 -1
- data/lib/mcollective/validator/ipv4address_validator.rb +5 -7
- data/lib/mcollective/validator/ipv6address_validator.rb +5 -7
- data/lib/mcollective/validator/shellsafe_validator.rb +1 -1
- data/lib/mcollective/validator/typecheck_validator.rb +15 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '069a8ceae281b1be5fc39b924c2b95c3fddb8242'
|
4
|
+
data.tar.gz: 97d52bf4968e7acc2c3534c74bc84e2ff75c0f27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d5810c5b35911eba73e85086caa5764efbfb0d9b77aa504bf64ad538a35da7a0f40552d6dc3a6e43e6f41420684f83f27922b1f8d33018b8b439ac0ecaee670
|
7
|
+
data.tar.gz: a69247825c9d2cc0c598f01ac46832ef02508522ca69a6fc886bed37866ad8652562b683a3f25901c5a8ea6feadf38a3af93d7a948ae018e96050a03c93541a4
|
data/lib/mcollective.rb
CHANGED
@@ -37,7 +37,7 @@ module MCollective
|
|
37
37
|
# aggregate summary(:value)
|
38
38
|
# end
|
39
39
|
# end
|
40
|
-
class AgentDDL<Base
|
40
|
+
class AgentDDL < Base
|
41
41
|
def initialize(plugin, plugintype=:agent, loadddl=true)
|
42
42
|
@process_aggregate_functions = nil
|
43
43
|
|
@@ -65,18 +65,18 @@ module MCollective
|
|
65
65
|
def summarize(&block)
|
66
66
|
unless @config.mode == :server
|
67
67
|
@process_aggregate_functions = true
|
68
|
-
|
68
|
+
yield
|
69
69
|
@process_aggregate_functions = nil
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
# Sets the aggregate array for the given action
|
74
|
-
def aggregate(function, format
|
74
|
+
def aggregate(function, format={:format => nil})
|
75
75
|
raise(DDLValidationError, "Formats supplied to aggregation functions should be a hash") unless format.is_a?(Hash)
|
76
76
|
raise(DDLValidationError, "Formats supplied to aggregation functions must have a :format key") unless format.keys.include?(:format)
|
77
77
|
raise(DDLValidationError, "Functions supplied to aggregate should be a hash") unless function.is_a?(Hash)
|
78
78
|
|
79
|
-
unless
|
79
|
+
unless function.keys.include?(:args) && function[:args]
|
80
80
|
raise DDLValidationError, "aggregate method for action '%s' missing a function parameter" % entities[@current_entity][:action]
|
81
81
|
end
|
82
82
|
|
@@ -133,7 +133,7 @@ module MCollective
|
|
133
133
|
# we set @current_entity so the input block can know what its talking
|
134
134
|
# to, this is probably an epic hack, need to improve.
|
135
135
|
@current_entity = name
|
136
|
-
|
136
|
+
yield if block_given?
|
137
137
|
@current_entity = nil
|
138
138
|
end
|
139
139
|
|
@@ -141,11 +141,13 @@ module MCollective
|
|
141
141
|
# with args as a hash. This will only be active if the @process_aggregate_functions
|
142
142
|
# is set to true which only happens in the #summarize block
|
143
143
|
def method_missing(name, *args, &block)
|
144
|
-
unless @process_aggregate_functions || is_function?(name)
|
145
|
-
|
146
|
-
|
144
|
+
super unless @process_aggregate_functions || is_function?(name)
|
145
|
+
|
146
|
+
{:function => name, :args => args}
|
147
|
+
end
|
147
148
|
|
148
|
-
|
149
|
+
def respond_to_missing?(method, *)
|
150
|
+
@process_aggregate_functions || is_function?(name) || super
|
149
151
|
end
|
150
152
|
|
151
153
|
# Checks if a method name matches a aggregate plugin.
|
@@ -169,7 +171,7 @@ module MCollective
|
|
169
171
|
|
170
172
|
return unless input
|
171
173
|
|
172
|
-
input.
|
174
|
+
input.each_key do |key|
|
173
175
|
if key.is_a?(Symbol) && arguments.include?(key.to_s) && !input.include?(key.to_s)
|
174
176
|
compat_arg = key.to_s
|
175
177
|
else
|
@@ -228,7 +230,7 @@ module MCollective
|
|
228
230
|
input = action_interface(action)[:input] || {}
|
229
231
|
compatible_args = symbolize_basic_input_arguments(input, arguments)
|
230
232
|
|
231
|
-
input.
|
233
|
+
input.each_key do |key|
|
232
234
|
unless input[key][:optional]
|
233
235
|
unless compatible_args.include?(key)
|
234
236
|
raise DDLValidationError, "Action #{action} needs a #{key} argument"
|
data/lib/mcollective/ddl/base.rb
CHANGED
@@ -42,7 +42,7 @@ module MCollective
|
|
42
42
|
# the config dir and if that does not exist, default to
|
43
43
|
# /etc/mcollective
|
44
44
|
def help(template=nil)
|
45
|
-
template
|
45
|
+
template ||= template_for_plugintype
|
46
46
|
template = Util.templatepath(template) unless Util.absolute_path?(template)
|
47
47
|
|
48
48
|
template = File.read(template)
|
@@ -52,14 +52,15 @@ module MCollective
|
|
52
52
|
unless template == "metadata-help.erb"
|
53
53
|
metadata_template = Util.templatepath("metadata-help.erb")
|
54
54
|
metadata_template = File.read(metadata_template)
|
55
|
-
metastring = ERB.new(metadata_template, 0,
|
55
|
+
metastring = ERB.new(metadata_template, 0, "%")
|
56
56
|
metastring = metastring.result(binding)
|
57
57
|
end
|
58
58
|
|
59
|
-
erb = ERB.new(template, 0,
|
59
|
+
erb = ERB.new(template, 0, "%")
|
60
60
|
erb.result(binding)
|
61
61
|
end
|
62
62
|
|
63
|
+
# rubocop:disable Lint/DuplicateMethods, Style/TrivialAccessors
|
63
64
|
def usage(usage_text)
|
64
65
|
@usage = usage_text
|
65
66
|
end
|
@@ -67,13 +68,13 @@ module MCollective
|
|
67
68
|
def template_for_plugintype
|
68
69
|
case @plugintype
|
69
70
|
when :agent
|
70
|
-
|
71
|
+
"rpc-help.erb"
|
71
72
|
else
|
72
|
-
if File.
|
73
|
-
|
73
|
+
if File.exist?(Util.templatepath("#{@plugintype}-help.erb"))
|
74
|
+
"#{@plugintype}-help.erb"
|
74
75
|
else
|
75
76
|
# Default help template gets loaded if plugintype-help does not exist.
|
76
|
-
|
77
|
+
"metadata-help.erb"
|
77
78
|
end
|
78
79
|
end
|
79
80
|
end
|
@@ -91,8 +92,8 @@ module MCollective
|
|
91
92
|
end
|
92
93
|
|
93
94
|
def findddlfile(ddlname=nil, ddltype=nil)
|
94
|
-
ddlname
|
95
|
-
ddltype
|
95
|
+
ddlname ||= @pluginname
|
96
|
+
ddltype ||= @plugintype
|
96
97
|
|
97
98
|
@config.libdir.each do |libdir|
|
98
99
|
ddlfile = File.join([libdir, "mcollective", ddltype.to_s, "#{ddlname}.ddl"])
|
@@ -170,17 +171,17 @@ module MCollective
|
|
170
171
|
:optional => properties[:optional]}
|
171
172
|
|
172
173
|
case properties[:type]
|
173
|
-
|
174
|
-
|
175
|
-
|
174
|
+
when :string
|
175
|
+
raise "Input type :string needs a :validation argument" unless properties.include?(:validation)
|
176
|
+
raise "Input type :string needs a :maxlength argument" unless properties.include?(:maxlength)
|
176
177
|
|
177
|
-
|
178
|
-
|
178
|
+
@entities[entity][:input][argument][:validation] = properties[:validation]
|
179
|
+
@entities[entity][:input][argument][:maxlength] = properties[:maxlength]
|
179
180
|
|
180
|
-
|
181
|
-
|
181
|
+
when :list
|
182
|
+
raise "Input type :list needs a :list argument" unless properties.include?(:list)
|
182
183
|
|
183
|
-
|
184
|
+
@entities[entity][:input][argument][:list] = properties[:list]
|
184
185
|
end
|
185
186
|
end
|
186
187
|
|
@@ -206,7 +207,7 @@ module MCollective
|
|
206
207
|
|
207
208
|
valid_requirements = [:mcollective]
|
208
209
|
|
209
|
-
requirement.
|
210
|
+
requirement.each_key do |key|
|
210
211
|
unless valid_requirements.include?(key)
|
211
212
|
raise "Requirement %s is not a valid requirement, only %s is supported" % [key, valid_requirements.join(", ")]
|
212
213
|
end
|
@@ -27,17 +27,17 @@ module MCollective
|
|
27
27
|
# :display_as => item.to_s.capitalize
|
28
28
|
# end
|
29
29
|
# end
|
30
|
-
class DataDDL<Base
|
30
|
+
class DataDDL < Base
|
31
31
|
def dataquery(input, &block)
|
32
32
|
raise "Data queries need a :description" unless input.include?(:description)
|
33
33
|
raise "Data queries can only have one definition" if @entities[:data]
|
34
34
|
|
35
|
-
@entities[:data]
|
36
|
-
|
37
|
-
|
35
|
+
@entities[:data] = {:description => input[:description],
|
36
|
+
:input => {},
|
37
|
+
:output => {}}
|
38
38
|
|
39
39
|
@current_entity = :data
|
40
|
-
|
40
|
+
yield if block_given?
|
41
41
|
@current_entity = nil
|
42
42
|
end
|
43
43
|
|
@@ -13,7 +13,7 @@ module MCollective
|
|
13
13
|
# discovery do
|
14
14
|
# capabilities [:classes, :facts, :identity, :agents, :compound]
|
15
15
|
# end
|
16
|
-
class DiscoveryDDL<Base
|
16
|
+
class DiscoveryDDL < Base
|
17
17
|
def discovery_interface
|
18
18
|
@entities[:discovery]
|
19
19
|
end
|
@@ -44,7 +44,7 @@ module MCollective
|
|
44
44
|
@entities[:discovery] = {:capabilities => []}
|
45
45
|
|
46
46
|
@current_entity = :discovery
|
47
|
-
|
47
|
+
yield if block_given?
|
48
48
|
@current_entity = nil
|
49
49
|
end
|
50
50
|
end
|
@@ -16,7 +16,7 @@ module MCollective
|
|
16
16
|
@dependencies = configuration[:dependency] || []
|
17
17
|
@target_path = File.expand_path(@path)
|
18
18
|
@metadata, mcversion = PluginPackager.get_metadata(@path, "agent")
|
19
|
-
@mcname = mcdependency[:mcname] ||
|
19
|
+
@mcname = mcdependency[:mcname] || "mcollective"
|
20
20
|
@mcversion = mcdependency[:mcversion] || mcversion
|
21
21
|
@metadata[:version] = (configuration[:version] || @metadata[:version])
|
22
22
|
@dependencies << {:name => "#{@mcname}-common", :version => @mcversion}
|
@@ -38,19 +38,23 @@ module MCollective
|
|
38
38
|
def agent
|
39
39
|
agent = {
|
40
40
|
:files => [],
|
41
|
+
:executable_files => [],
|
41
42
|
:dependencies => @dependencies.clone,
|
42
43
|
:description => "Agent plugin for #{@metadata[:name]}"
|
43
44
|
}
|
44
45
|
|
45
46
|
agentdir = File.join(@path, "agent")
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
return nil
|
52
|
-
end
|
48
|
+
return nil unless PluginPackager.check_dir_present(agentdir)
|
49
|
+
|
50
|
+
ddls = Dir.glob(File.join(agentdir, "*.{ddl,json}"))
|
51
|
+
agent[:files] = (Dir.glob(File.join(agentdir, "**", "**")) - ddls)
|
53
52
|
agent[:plugindependency] = {:name => "#{@mcname}-#{@metadata[:name]}-common", :version => @metadata[:version], :revision => @revision}
|
53
|
+
|
54
|
+
if @metadata[:provider] == "external"
|
55
|
+
agent[:executable_files] << File.join(agentdir, @metadata[:name])
|
56
|
+
end
|
57
|
+
|
54
58
|
agent
|
55
59
|
end
|
56
60
|
|
@@ -72,14 +76,14 @@ module MCollective
|
|
72
76
|
# Obtain common package files and dependencies.
|
73
77
|
def common
|
74
78
|
common = {
|
75
|
-
:files =>[],
|
79
|
+
:files => [],
|
76
80
|
:dependencies => @dependencies.clone,
|
77
81
|
:description => "Common libraries for #{@metadata[:name]}"
|
78
82
|
}
|
79
83
|
|
80
84
|
datadir = File.join(@path, "data", "**")
|
81
85
|
utildir = File.join(@path, "util", "**", "**")
|
82
|
-
ddldir = File.join(@path, "agent", "*.ddl")
|
86
|
+
ddldir = File.join(@path, "agent", "*.{ddl,json}")
|
83
87
|
validatordir = File.join(@path, "validator", "**")
|
84
88
|
|
85
89
|
[datadir, utildir, validatordir, ddldir].each do |directory|
|
@@ -88,9 +92,11 @@ module MCollective
|
|
88
92
|
|
89
93
|
# We fail if there is no ddl file present
|
90
94
|
if common[:files].grep(/^.*\.ddl$/).empty?
|
91
|
-
raise "cannot create package - No ddl file found in #{File.join(@path,
|
95
|
+
raise "cannot create package - No ddl file found in #{File.join(@path, 'agent')}"
|
92
96
|
end
|
93
97
|
|
98
|
+
common[:files].uniq!
|
99
|
+
|
94
100
|
common[:files].empty? ? nil : common
|
95
101
|
end
|
96
102
|
end
|
@@ -3,11 +3,11 @@ require "yaml"
|
|
3
3
|
module MCollective
|
4
4
|
module PluginPackager
|
5
5
|
class ForgePackager
|
6
|
-
def initialize(plugin, pluginpath
|
6
|
+
def initialize(plugin, pluginpath=nil, signature=nil, verbose=false, keep_artifacts=nil, module_template=nil)
|
7
7
|
@plugin = plugin
|
8
8
|
@verbose = verbose
|
9
9
|
@keep_artifacts = keep_artifacts
|
10
|
-
@module_template = module_template || File.join(File.dirname(__FILE__),
|
10
|
+
@module_template = module_template || File.join(File.dirname(__FILE__), "templates", "forge")
|
11
11
|
end
|
12
12
|
|
13
13
|
def which(cmd)
|
@@ -18,11 +18,11 @@ module MCollective
|
|
18
18
|
return exe if File.executable?(exe) && !File.directory?(exe)
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
21
|
+
nil
|
22
22
|
end
|
23
23
|
|
24
24
|
def create_packages
|
25
|
-
|
25
|
+
assert_new_enough_pdk
|
26
26
|
validate_environment
|
27
27
|
|
28
28
|
begin
|
@@ -44,7 +44,7 @@ module MCollective
|
|
44
44
|
ensure
|
45
45
|
if @keep_artifacts
|
46
46
|
puts("Keeping build artifacts")
|
47
|
-
puts("Build artifacts saved in %s" %
|
47
|
+
puts("Build artifacts saved in %s" % @tmpdir)
|
48
48
|
else
|
49
49
|
cleanup_tmpdirs
|
50
50
|
end
|
@@ -81,7 +81,15 @@ module MCollective
|
|
81
81
|
def filelist(type)
|
82
82
|
@plugin.packagedata[type][:files].map do |file|
|
83
83
|
file.gsub(/^\.\//, "") unless File.directory?(file)
|
84
|
-
end.compact
|
84
|
+
end.compact.uniq
|
85
|
+
rescue
|
86
|
+
[]
|
87
|
+
end
|
88
|
+
|
89
|
+
def executablelist(type)
|
90
|
+
@plugin.packagedata[type][:executable_files].map do |file|
|
91
|
+
file.gsub(/^\.\//, "") unless File.directory?(file)
|
92
|
+
end.compact.uniq
|
85
93
|
rescue
|
86
94
|
[]
|
87
95
|
end
|
@@ -100,11 +108,12 @@ module MCollective
|
|
100
108
|
{
|
101
109
|
hierakey(:config_name) => @plugin.metadata[:name].downcase,
|
102
110
|
hierakey(:common_files) => filelist(:common),
|
111
|
+
hierakey(:executable_files) => executablelist(:agent),
|
103
112
|
hierakey(:common_directories) => dirlist(:common),
|
104
113
|
hierakey(:server_files) => filelist(:agent),
|
105
114
|
hierakey(:server_directories) => dirlist(:agent),
|
106
115
|
hierakey(:client_files) => filelist(:client),
|
107
|
-
hierakey(:client_directories) => dirlist(:client)
|
116
|
+
hierakey(:client_directories) => dirlist(:client)
|
108
117
|
}.merge(module_override_data)
|
109
118
|
end
|
110
119
|
|
@@ -123,7 +132,7 @@ module MCollective
|
|
123
132
|
end
|
124
133
|
|
125
134
|
def copy_module_files
|
126
|
-
@plugin.packagedata.
|
135
|
+
@plugin.packagedata.each_value do |data|
|
127
136
|
data[:files].each do |file|
|
128
137
|
clean_dest_file = file.gsub("./lib/mcollective", "")
|
129
138
|
dest_dir = File.expand_path(File.join(@tmpdir, "files", "mcollective", File.dirname(clean_dest_file)))
|
@@ -142,13 +151,18 @@ module MCollective
|
|
142
151
|
agent_name = File.basename(file, ".ddl")
|
143
152
|
json_file = File.join(agent_dir, "%s.json" % agent_name)
|
144
153
|
|
154
|
+
if File.exist?(json_file)
|
155
|
+
Log.warn("JSON DDL %s already exist, not regenerating from the %s" % [json_file, agent_name])
|
156
|
+
next
|
157
|
+
end
|
158
|
+
|
145
159
|
ddl = DDL.new(agent_name, :agent, false)
|
146
160
|
ddl.instance_eval(File.read(file))
|
147
161
|
|
148
162
|
data = {
|
149
163
|
"$schema" => "https://choria.io/schemas/mcorpc/ddl/v1/agent.json",
|
150
164
|
"metadata" => ddl.meta,
|
151
|
-
"actions" => []
|
165
|
+
"actions" => []
|
152
166
|
}
|
153
167
|
|
154
168
|
ddl.actions.sort.each do |action|
|
@@ -165,7 +179,7 @@ module MCollective
|
|
165
179
|
end
|
166
180
|
|
167
181
|
def render_templates
|
168
|
-
templates = Dir.chdir(@module_template) do |
|
182
|
+
templates = Dir.chdir(@module_template) do |_path|
|
169
183
|
Dir.glob("**/*.erb")
|
170
184
|
end
|
171
185
|
|
@@ -177,69 +191,62 @@ module MCollective
|
|
177
191
|
end
|
178
192
|
|
179
193
|
def render_template(infile, outfile)
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
f.puts erb.result(binding)
|
184
|
-
end
|
185
|
-
rescue
|
186
|
-
STDERR.puts("Could not render template %s to %s" % [infile, outfile])
|
187
|
-
raise
|
194
|
+
erb = ERB.new(File.read(infile), nil, "-")
|
195
|
+
File.open(outfile, "w") do |f|
|
196
|
+
f.puts erb.result(binding)
|
188
197
|
end
|
198
|
+
rescue
|
199
|
+
STDERR.puts("Could not render template %s to %s" % [infile, outfile])
|
200
|
+
raise
|
189
201
|
end
|
190
202
|
|
191
203
|
def validate_environment
|
192
204
|
raise("Supplying a vendor is required, please use --vendor") if @plugin.vendor == "Puppet Labs"
|
193
|
-
raise("Vendor names may not have a space in them, please specify a valid vendor using --vendor") if @plugin.vendor.
|
205
|
+
raise("Vendor names may not have a space in them, please specify a valid vendor using --vendor") if @plugin.vendor.include?(" ")
|
194
206
|
end
|
195
207
|
|
196
|
-
def
|
197
|
-
|
198
|
-
|
199
|
-
if !puppet_bin
|
200
|
-
raise("Cannot build package. 'puppet' not found on path, and '/opt/puppetlabs/bin/puppet' is not present on the system.")
|
201
|
-
end
|
208
|
+
def pdk_path
|
209
|
+
pdk_bin = which("pdk")
|
210
|
+
pdk_bin ||= "/opt/puppetlabs/pdk/bin/pdk"
|
202
211
|
|
203
|
-
|
212
|
+
pdk_bin
|
213
|
+
end
|
214
|
+
|
215
|
+
def assert_new_enough_pdk
|
216
|
+
s = Shell.new("#{pdk_path} --version")
|
204
217
|
s.runcommand
|
205
218
|
actual_version = s.stdout.chomp
|
206
|
-
required_version =
|
219
|
+
required_version = "1.12.0"
|
207
220
|
|
208
221
|
if Util.versioncmp(actual_version, required_version) < 0
|
209
|
-
raise("Cannot build package.
|
222
|
+
raise("Cannot build package. pdk #{required_version} or greater required. We have #{actual_version}.")
|
210
223
|
end
|
211
224
|
end
|
212
225
|
|
213
226
|
def run_build
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
PluginPackager.safe_system('pdk build --force')
|
218
|
-
end
|
227
|
+
PluginPackager.execute_verbosely(@verbose) do
|
228
|
+
Dir.chdir(@tmpdir) do
|
229
|
+
PluginPackager.safe_system("#{pdk_path} build --force")
|
219
230
|
end
|
220
|
-
rescue
|
221
|
-
STDERR.puts("Build process has failed")
|
222
|
-
raise
|
223
231
|
end
|
232
|
+
rescue
|
233
|
+
STDERR.puts("Build process has failed")
|
234
|
+
raise
|
224
235
|
end
|
225
236
|
|
226
237
|
def move_package
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
raise
|
233
|
-
end
|
238
|
+
package_file = File.join(@tmpdir, "pkg", module_file_name)
|
239
|
+
FileUtils.cp(package_file, ".")
|
240
|
+
rescue
|
241
|
+
STDERR.puts("Could not copy package to working directory")
|
242
|
+
raise
|
234
243
|
end
|
235
244
|
|
236
245
|
def cleanup_tmpdirs
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
raise
|
242
|
-
end
|
246
|
+
FileUtils.rm_r(@tmpdir) if File.directory?(@tmpdir)
|
247
|
+
rescue
|
248
|
+
STDERR.puts("Could not remove temporary build directory %s" % [@tmpdir])
|
249
|
+
raise
|
243
250
|
end
|
244
251
|
end
|
245
252
|
end
|
@@ -6,6 +6,7 @@ class <%= module_name %> (
|
|
6
6
|
Array[String] $server_directories = [],
|
7
7
|
Array[String] $common_files = [],
|
8
8
|
Array[String] $common_directories = [],
|
9
|
+
Array[String] $executable_files = [],
|
9
10
|
Boolean $manage_gem_dependencies = true,
|
10
11
|
Hash $gem_dependencies = {},
|
11
12
|
Boolean $manage_package_dependencies = true,
|
@@ -26,6 +27,7 @@ class <%= module_name %> (
|
|
26
27
|
client_files => $client_files,
|
27
28
|
server_files => $server_files,
|
28
29
|
common_files => $common_files,
|
30
|
+
executable_files => $executable_files,
|
29
31
|
client_directories => $client_directories,
|
30
32
|
server_directories => $server_directories,
|
31
33
|
common_directories => $common_directories,
|
@@ -2,7 +2,7 @@ module MCollective
|
|
2
2
|
module Validator
|
3
3
|
class ArrayValidator
|
4
4
|
def self.validate(validator, array)
|
5
|
-
raise ValidatorError, "value should be one of %s" % [
|
5
|
+
raise ValidatorError, "value should be one of %s" % [array.join(", ")] unless array.include?(validator)
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module MCollective
|
2
2
|
module Validator
|
3
3
|
class Ipv4addressValidator
|
4
|
-
require
|
4
|
+
require "ipaddr"
|
5
5
|
|
6
6
|
def self.validate(validator)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
raise ValidatorError, "value should be an ipv4 address"
|
12
|
-
end
|
7
|
+
ip = IPAddr.new(validator)
|
8
|
+
raise ValidatorError, "value should be an ipv4 adddress" unless ip.ipv4?
|
9
|
+
rescue
|
10
|
+
raise ValidatorError, "value should be an ipv4 address"
|
13
11
|
end
|
14
12
|
end
|
15
13
|
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module MCollective
|
2
2
|
module Validator
|
3
3
|
class Ipv6addressValidator
|
4
|
-
require
|
4
|
+
require "ipaddr"
|
5
5
|
|
6
6
|
def self.validate(validator)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
raise ValidatorError, "value should be an ipv6 address"
|
12
|
-
end
|
7
|
+
ip = IPAddr.new(validator)
|
8
|
+
raise ValidatorError, "value should be an ipv6 adddress" unless ip.ipv6?
|
9
|
+
rescue
|
10
|
+
raise ValidatorError, "value should be an ipv6 address"
|
13
11
|
end
|
14
12
|
end
|
15
13
|
end
|
@@ -4,7 +4,7 @@ module MCollective
|
|
4
4
|
def self.validate(validator)
|
5
5
|
raise ValidatorError, "value should be a String" unless validator.is_a?(String)
|
6
6
|
|
7
|
-
[
|
7
|
+
["`", "$", ";", "|", "&&", ">", "<"].each do |chr|
|
8
8
|
raise ValidatorError, "value should not have #{chr} in it" if validator.match(Regexp.escape(chr))
|
9
9
|
end
|
10
10
|
end
|
@@ -2,25 +2,25 @@ module MCollective
|
|
2
2
|
module Validator
|
3
3
|
class TypecheckValidator
|
4
4
|
def self.validate(validator, validation_type)
|
5
|
-
raise ValidatorError, "value should be a #{validation_type
|
5
|
+
raise ValidatorError, "value should be a #{validation_type}" unless check_type(validator, validation_type)
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.check_type(validator, validation_type)
|
9
9
|
case validation_type
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
10
|
+
when Class
|
11
|
+
validator.is_a?(validation_type)
|
12
|
+
when :integer
|
13
|
+
validator.is_a?(Integer)
|
14
|
+
when :float
|
15
|
+
validator.is_a?(Float)
|
16
|
+
when :number
|
17
|
+
validator.is_a?(Numeric)
|
18
|
+
when :string
|
19
|
+
validator.is_a?(String)
|
20
|
+
when :boolean
|
21
|
+
[TrueClass, FalseClass].include?(validator.class)
|
22
|
+
else
|
23
|
+
false
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: choria-mcorpc-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.20.
|
4
|
+
version: 2.20.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- R.I.Pienaar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: systemu
|