kafo 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04471c1066e9f6dd65d78a5367cdc0eb56321c0c
4
- data.tar.gz: 17179ea8c8da4b0982b6a9bbedb82eade0e66cfe
3
+ metadata.gz: cefdaae9624b12013065f287d08701950388c0c9
4
+ data.tar.gz: 25fb99c469306555c8496b58e7db3371d4e03a98
5
5
  SHA512:
6
- metadata.gz: 3a55344a02495577be8d8a43227b605f39baeea111cad9555dcab69ea13a97547e6359ba3cf6c91a47d0736120ab544bb18e8dcdec45a1fa6460eb496c7273de
7
- data.tar.gz: ab04cfc6b76c6131d23557074736fe4eb75066ac978da2646202ceed53e3e8ce7e442afd97b4b1eaa607469c51729059125b630f4daf228ecc835761dcfb44c4
6
+ metadata.gz: af6fe19e39bd857cdd0f9b437a6699eed00a7d98af68df4d15bc363ee3089d53915e282709b1375f099073ee8cc36e8d6998e2a5630c02004e8abfa9ffe8d76e
7
+ data.tar.gz: 0705cd23f537dd6308917bd43cf52d2e33ca9631c386ddc24aafe93c322ae03ce0a6acdcab611bd1f919166adcfaa6e37f61e810189e509411939571c48742e2
data/README.md CHANGED
@@ -535,8 +535,11 @@ end
535
535
  Note that the hook is evaluated in HookContext object which provides some DSL. We can create
536
536
  new installer option using ```app_option```. These option values can be accessed by using
537
537
  ```app_value(:reset_foreman_db)```. You can modify parameters (if they are already defined)
538
- using ```param('module name', 'parameter name')``` accessor. Last but not least you have
539
- access to logger. For more details, see hook_context.rb.
538
+ using ```param('module name', 'parameter name')``` accessor. You can register your own module
539
+ that is not specified in answer file using ```add_module```. Custom mapping is also supported.
540
+ This is useful if you need to add some module to existing installer based on kafo but you don't
541
+ have control over it's source code. Last but not least you have access to logger.
542
+ For more details, see [hook_context.rb](https://github.com/theforeman/kafo/blob/master/lib/kafo/hook_context.rb).
540
543
 
541
544
  If you don't want to modify you installer script you can place your hooks into
542
545
  hooks directory. By default hooks dir is searched for ruby files in subdirectories
@@ -75,6 +75,19 @@ module Kafo
75
75
  @modules ||= @data.keys.map { |mod| PuppetModule.new(mod).parse }
76
76
  end
77
77
 
78
+ def add_module(name)
79
+ mod = PuppetModule.new(name).parse
80
+ unless modules.map(&:name).include?(mod.name)
81
+ mod.enable
82
+ @modules << mod
83
+ end
84
+ end
85
+
86
+ def add_mapping(module_name, mapping)
87
+ app[:mapping][module_name] = mapping
88
+ save_configuration(app)
89
+ end
90
+
78
91
  def params_default_values
79
92
  @params_default_values ||= begin
80
93
  @logger.debug "Creating tmp dir within #{app[:default_values_dir]}..."
@@ -47,5 +47,18 @@ module Kafo
47
47
  def param(module_name, parameter_name)
48
48
  self.kafo.param(module_name, parameter_name)
49
49
  end
50
+
51
+ # You can add custom modules not explicitly enabled in answer file. This is especially
52
+ # useful if you want to add your plugin to existing installer. This module will become
53
+ # part of answer file so it also preserves parameter values between runs. It also list
54
+ # its options in help output. You can also specify mapping for this module as a second
55
+ # parameter.
56
+ # examples:
57
+ # add_module('my_module')
58
+ # add_module('foreman::plugin::staypuft', {:dir_name => 'foreman', :manifest_name => 'plugin/staypuft'})
59
+ def add_module(module_name, mapping = nil)
60
+ self.kafo.config.add_mapping(module_name, mapping) if mapping
61
+ self.kafo.add_module(module_name)
62
+ end
50
63
  end
51
64
  end
@@ -192,6 +192,17 @@ module Kafo
192
192
  exit(:unknown_module)
193
193
  end
194
194
 
195
+ def reset_params_cache
196
+ @params = nil
197
+ params
198
+ end
199
+
200
+ def add_module(name)
201
+ config.add_module(name)
202
+ reset_params_cache
203
+ self.module(name)
204
+ end
205
+
195
206
  def modules
196
207
  config.modules.sort
197
208
  end
data/lib/kafo/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  module Kafo
3
- VERSION = "0.5.3"
3
+ VERSION = "0.5.4"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kafo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Hulan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-15 00:00:00.000000000 Z
11
+ date: 2014-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler