Skip to content

Commit 5333754

Browse files
committed
Extract the logic to generate choria modules name
This code will be needed in another file. Modulesync does not seem to have built-in support for adding utility methods, so just put them in a local file and require it where the methods are needed.
1 parent 22712c7 commit 5333754

2 files changed

Lines changed: 20 additions & 19 deletions

File tree

lib/util.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def choria_module_name
2+
case @metadata[:module_name]
3+
when "action-policy"
4+
"mcollective_util_actionpolicy"
5+
when "mcollective_choria"
6+
"mcollective_choria"
7+
when "tasks-agent"
8+
"mcollective_agent_bolt_tasks"
9+
when /-agent$/
10+
"mcollective_agent_#{@metadata[:module_name].sub(/-agent$/, '')}"
11+
else
12+
raise "Don't know how to construct module name"
13+
end
14+
end

moduleroot/data/defaults.yaml.erb

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,17 @@
1-
<%
2-
module_name = case @metadata[:module_name]
3-
when "action-policy"
4-
"mcollective_util_actionpolicy"
5-
when "mcollective_choria"
6-
"mcollective_choria"
7-
when "tasks-agent"
8-
"mcollective_agent_bolt_tasks"
9-
when /-agent$/
10-
"mcollective_agent_#{@metadata[:module_name].sub(/-agent$/, '')}"
11-
else
12-
raise "Don't know how to construct module name"
13-
end
14-
-%>
1+
<% require_relative '../../lib/util.rb' -%>
152
lookup_options:
16-
<%= module_name %>::gem_dependencies:
3+
<%= choria_module_name %>::gem_dependencies:
174
merge:
185
strategy: deep
19-
<%= module_name %>::package_dependencies:
6+
<%= choria_module_name %>::package_dependencies:
207
merge:
218
strategy: deep
22-
<%= module_name %>::config:
9+
<%= choria_module_name %>::config:
2310
merge:
2411
strategy: deep
25-
<%= module_name %>::client_config:
12+
<%= choria_module_name %>::client_config:
2613
merge:
2714
strategy: deep
28-
<%= module_name %>::server_config:
15+
<%= choria_module_name %>::server_config:
2916
merge:
3017
strategy: deep

0 commit comments

Comments
 (0)