kafo 1.0.3 → 1.0.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: 6d72a4ee27bfb7b43960efdca85631bf83423fc0
4
- data.tar.gz: 80f0f06eaf07cabde8a67df2d5e231511fc2d50f
3
+ metadata.gz: d8d91c1c416307f1a338f208ff5eff030d1b848a
4
+ data.tar.gz: c8b4d0291b2ab3afc351ebcd22e12b7326d96d3b
5
5
  SHA512:
6
- metadata.gz: dc3d55c99f389d35e425e5fd9ede4cc09dd559ca84a51c6fea66fe7fef49168240424b6e7d1756404b9fab4e9a9dca16769d612327fe25bbd9a33f626702c9c1
7
- data.tar.gz: 2b6d1cecef96812457b9749e65e1b84b4cba5fa772d489fbdc0a11cb851dcc4dca0287b0f08bd6e861879e8167c15ea4fe0bda09facbbc0d878513ba3c013f45
6
+ metadata.gz: 3ddd5d143247c1a437f6f6ea3afe287f9a53caed1b0a966aabd763184545706e34ac4428b2bff835893e8a6c62507deb8d9292f0ee5906a11e0a667ebb19de3d
7
+ data.tar.gz: d07f78c6a86c1eb71617e127264bb39411ffd8f5077b9963725fd4c59d869f45b8a9edcd66ea8ddfda481b4d81967f84e675783dfe775602d06533ec6decd1fe
data/Rakefile CHANGED
@@ -2,9 +2,18 @@ require 'rake/testtask'
2
2
  require "bundler/gem_tasks"
3
3
  load 'tasks/jenkins.rake'
4
4
 
5
- Rake::TestTask.new do |t|
5
+ Rake::TestTask.new('test:unit') do |t|
6
6
  t.libs << 'lib' << 'test'
7
- t.test_files = FileList['test/**/*_test.rb']
7
+ t.test_files = FileList['test/kafo/**/*_test.rb']
8
8
  t.verbose = true
9
9
  end
10
10
 
11
+ Rake::TestTask.new('test:acceptance') do |t|
12
+ t.libs << 'lib' << 'test'
13
+ t.test_files = FileList['test/acceptance/*_test.rb']
14
+ t.verbose = true
15
+ end
16
+
17
+ CLEAN.include 'test/tmp'
18
+
19
+ task :test => ['test:unit', 'test:acceptance']
@@ -4,6 +4,7 @@ require 'tmpdir'
4
4
  require 'kafo/puppet_module'
5
5
  require 'kafo/password_manager'
6
6
  require 'kafo/color_scheme'
7
+ require 'kafo/data_type_parser'
7
8
 
8
9
  module Kafo
9
10
  class Configuration
@@ -86,7 +87,10 @@ module Kafo
86
87
  end
87
88
 
88
89
  def modules
89
- @modules ||= @data.keys.map { |mod| PuppetModule.new(mod, PuppetModule.find_parser, self).parse }.sort
90
+ @modules ||= begin
91
+ register_data_types
92
+ @data.keys.map { |mod| PuppetModule.new(mod, PuppetModule.find_parser, self).parse }.sort
93
+ end
90
94
  end
91
95
 
92
96
  def module(name)
@@ -303,5 +307,13 @@ module Kafo
303
307
  def load_yaml_file(filename)
304
308
  YAML.load_file(filename)
305
309
  end
310
+
311
+ def register_data_types
312
+ module_dirs.each do |module_dir|
313
+ Dir[File.join(module_dir, '*', 'types', '**', '*.pp')].each do |type_file|
314
+ DataTypeParser.new(File.read(type_file)).register
315
+ end
316
+ end
317
+ end
306
318
  end
307
319
  end
@@ -2,30 +2,25 @@ module Kafo
2
2
  class DataType
3
3
  def self.new_from_string(str)
4
4
  keyword_re = /\A([\w:]+)(?:\[(.*)\])?\z/m.match(str)
5
- if keyword_re
6
- if (type = @keywords[keyword_re[1]])
7
- args = if keyword_re[2]
8
- hash_re = keyword_re[2].match(/\A\s*{(.*)}\s*\z/m)
9
- if hash_re
10
- [parse_hash(hash_re[1])]
11
- else
12
- split_arguments(keyword_re[2])
13
- end
5
+ raise ConfigurationException, "data type not recognized #{str}" unless keyword_re
6
+
7
+ type = @keywords[keyword_re[1]]
8
+ raise ConfigurationException, "unknown data type #{keyword_re[1]}" unless type
9
+
10
+ if type.is_a?(String)
11
+ new_from_string(type)
12
+ else
13
+ args = if keyword_re[2]
14
+ hash_re = keyword_re[2].match(/\A\s*{(.*)}\s*\z/m)
15
+ if hash_re
16
+ [parse_hash(hash_re[1])]
14
17
  else
15
- []
18
+ split_arguments(keyword_re[2])
16
19
  end
17
- type.new(*args)
18
- elsif ['Data'].include?(keyword_re[1])
19
- DataTypes::Any.new
20
- elsif keyword_re[1] == 'Default'
21
- DataTypes::Enum.new('default')
22
- elsif @keywords[keyword_re[1].capitalize] # pre-Puppet 4 data types
23
- DataTypes::Optional.new(keyword_re[1].capitalize)
24
- else
25
- raise ConfigurationException, "unknown data type #{keyword_re[1]}"
26
- end
27
- else
28
- raise ConfigurationException, "data type not recognized #{str}"
20
+ else
21
+ []
22
+ end
23
+ type.new(*args)
29
24
  end
30
25
  end
31
26
 
@@ -79,6 +74,7 @@ module Kafo
79
74
  end
80
75
  end
81
76
 
77
+ require 'kafo/data_types/aliases'
82
78
  require 'kafo/data_types/any'
83
79
  require 'kafo/data_types/array'
84
80
  require 'kafo/data_types/boolean'
@@ -0,0 +1,26 @@
1
+ require 'kafo/data_type'
2
+
3
+ module Kafo
4
+ class DataTypeParser
5
+ TYPE_DEFINITION = /^type\s+([^\s=]+)\s*=\s*(.+?)(\s+#.*)?\s*$/
6
+
7
+ attr_reader :types
8
+
9
+ def initialize(manifest)
10
+ @logger = KafoConfigure.logger
11
+ @types = {}
12
+ manifest.each_line do |line|
13
+ if (type = TYPE_DEFINITION.match(line))
14
+ @types[type[1]] = type[2]
15
+ end
16
+ end
17
+ end
18
+
19
+ def register
20
+ @types.each do |name,target|
21
+ @logger.debug("Registering extended data type #{name}")
22
+ DataType.register_type(name, target)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,14 @@
1
+ require 'kafo/data_type'
2
+
3
+ module Kafo
4
+ DataType.register_type('Data', 'Any')
5
+ DataType.register_type('Default', 'Enum["default"]')
6
+
7
+ # pre-Puppet 4 Kafo data types
8
+ DataType.register_type('array', 'Optional[Array]')
9
+ DataType.register_type('boolean', 'Optional[Boolean]')
10
+ DataType.register_type('hash', 'Optional[Hash]')
11
+ DataType.register_type('integer', 'Optional[Integer]')
12
+ DataType.register_type('password', 'Optional[String]')
13
+ DataType.register_type('string', 'Optional[String]')
14
+ end
@@ -91,7 +91,7 @@ module Kafo
91
91
  (available_scenarios.keys.count == 1 && available_scenarios.keys.first) ||
92
92
  select_scenario_interactively
93
93
  if scenario.nil?
94
- fail_now("No installation scenario was selected, the installer can not continue.\n" +
94
+ fail_now("No installation scenario was selected, the installer cannot continue.\n" +
95
95
  " Even --help content is dependent on selected scenario.\n" +
96
96
  " Select scenario with --scenario SCENARIO or list available scenarios with --list-scenarios.", :unset_scenario)
97
97
  elsif !scenario_enabled?(scenario)
@@ -148,7 +148,7 @@ module Kafo
148
148
  show_scenario_diff(@previous_scenario, new_scenario)
149
149
 
150
150
  wizard = KafoWizards.wizard(:cli, 'Confirm installation scenario selection',
151
- :description => "You are trying to replace existing installation with different scenario. This may lead to unpredictable states. Please confirm that you want to proceed.")
151
+ :description => "You are trying to replace an existing installation with a different scenario. This may lead to unpredictable states. Please confirm that you want to proceed.")
152
152
  wizard.entries << wizard.factory.button(:proceed, :label => 'Proceed with selected installation scenario', :default => false)
153
153
  wizard.entries << wizard.factory.button(:cancel, :label => 'Cancel Installation', :default => true)
154
154
  result = wizard.run
@@ -198,8 +198,8 @@ module Kafo
198
198
  def link_last_scenario(config_file)
199
199
  link_path = last_scenario_link
200
200
  if last_scenario_link
201
- File.delete(last_scenario_link) if File.exist?(last_scenario_link)
202
- File.symlink(config_file, last_scenario_link)
201
+ File.delete(last_scenario_link) if File.symlink?(last_scenario_link)
202
+ File.symlink(File.basename(config_file), last_scenario_link)
203
203
  end
204
204
  end
205
205
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Kafo
4
4
  class SystemChecker
5
+ attr_reader :checkers
6
+
5
7
  def self.check
6
8
  KafoConfigure.check_dirs.all? do |dir|
7
9
  new(File.join(dir, '*')).check
@@ -9,7 +11,7 @@ module Kafo
9
11
  end
10
12
 
11
13
  def initialize(path)
12
- @checkers = Dir.glob(path)
14
+ @checkers = Dir.glob(path).sort
13
15
  end
14
16
 
15
17
  def logger
data/lib/kafo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
  module Kafo
3
3
  PARSER_CACHE_VERSION = 1
4
- VERSION = "1.0.3"
4
+ VERSION = "1.0.4"
5
5
  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: 1.0.3
4
+ version: 1.0.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: 2016-10-12 00:00:00.000000000 Z
11
+ date: 2016-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -207,6 +207,8 @@ files:
207
207
  - lib/kafo/condition.rb
208
208
  - lib/kafo/configuration.rb
209
209
  - lib/kafo/data_type.rb
210
+ - lib/kafo/data_type_parser.rb
211
+ - lib/kafo/data_types/aliases.rb
210
212
  - lib/kafo/data_types/any.rb
211
213
  - lib/kafo/data_types/array.rb
212
214
  - lib/kafo/data_types/boolean.rb