hieracles 0.3.5 → 0.3.6

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: fbed104b2e5efb9ab631dc6c92dbcdc15c12c93b
4
- data.tar.gz: 23a3969b635a47856e7e4881b303db9de6080ecd
3
+ metadata.gz: 580fa2b122f177f4e9a901b9dcc6940c721bf45e
4
+ data.tar.gz: c606cd77e93fd4c9d38d84a89f27790d050b8f36
5
5
  SHA512:
6
- metadata.gz: ef265813311aab75f57bc92bbe35cb2526969be6937741f909ea232a2d37bf7b7778e42d72bf255ed6e61afa9f0be6c90a9f02675c43b0578029442c75735273
7
- data.tar.gz: 1c5d72ac972d07fd0e7751796b9be488ff39e91bc2789855d01d6caf96b356ddb50a5a4f3d3ddfb8a9b2b50644b33f2351485d54c957153c4eefe47dc2562cba
6
+ metadata.gz: c1b6c1f4e57844360f5ee2c480d6bcb726f053e30e75fff0f3b18c1e55f6e8e15c4d1bced728554de3fcdf82b1f229d1d6176689b3f5a27897e581bea54926ee
7
+ data.tar.gz: b48b039da054c365cda35829a54f539de888a9192f9f12d934abfeb99596233e18383e96d7b37ce15bee1143c1eca00d9a555433850e5859784d8c7261b2bd16
data/CHANGELOG.md CHANGED
@@ -1,6 +1,9 @@
1
1
  Hieracles Changelog
2
2
  =======================
3
3
 
4
+ ### 0.3.6 - 2016-04-27
5
+ - avoid abusive caching for all farms information
6
+
4
7
  ### 0.3.5 - 2016-02-18
5
8
  - change extraparams separator from ; to , to avoid having to quote argument
6
9
  - fix merge order for extraparams to override configuration and puppetdb values
data/bin/hc CHANGED
@@ -24,7 +24,10 @@ end
24
24
  if Hieracles::Format.method_defined? command
25
25
  begin
26
26
  config = Hieracles::Config.new opt.options
27
- node = Hieracles::Node.new fqdn, config
27
+ if fqdn[/\./]
28
+ node = Hieracles::Node.new fqdn, config
29
+ else
30
+ end
28
31
  rescue Exception => e
29
32
  puts "*** Error: #{e.message}"
30
33
  exit(1)
@@ -0,0 +1,7 @@
1
+ require 'actions/modules'
2
+
3
+ module Hieracles
4
+ module Actions
5
+
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Hieracles
2
+ module Actions
3
+ class Modules
4
+
5
+ end
6
+ end
7
+ end
@@ -22,23 +22,48 @@ module Hieracles
22
22
  end
23
23
  end
24
24
 
25
- def nodes_data(config, env = 'production', reload = false)
26
- @_nodes_data = {} if reload || !@_nodes_data
27
- @_nodes_data[env] ||= Dir.glob(File.join(config.encpath, '*.yaml')).sort.reduce({}) do |a, f|
25
+ def reload_nodes()
26
+ @_nodes_parameters = {}
27
+ @_nodes_modules = {}
28
+ end
29
+
30
+ def nodes_parameters(config, env = 'production')
31
+ @_nodes_parameters ||= {}
32
+ @_nodes_parameters[env] ||= Dir.glob(File.join(config.encpath, '*.yaml')).sort.reduce({}) do |a, f|
33
+ fqdn = File.basename(f, '.yaml')
34
+ a[fqdn] = YAML.load_file(f)['parameters']
35
+ a
36
+ end
37
+ end
38
+
39
+ def nodes_modules(config, env = 'production')
40
+ @_nodes_modules ||= {}
41
+ @_nodes_modules[env] ||= Dir.glob(File.join(config.encpath, '*.yaml')).sort.reduce({}) do |a, f|
42
+ YAML.load_file(f)['classes'].each do |cl|
43
+
44
+ end
28
45
  fqdn = File.basename(f, '.yaml')
29
46
  a[fqdn] = YAML.load_file(f)['parameters']
30
47
  a
31
48
  end
32
49
  end
33
50
 
34
- def farms_counted(config, env = 'production')
51
+ def farms_counted(config, env = 'production', reload = false)
52
+ reload_nodes if reload
35
53
  Dir.glob(format(config.classpath, '*')).sort.reduce({}) do |a, f|
36
54
  sub = Regexp.new(".*#{config.classpath.sub(/%s/,'([^/]*)')}")
37
55
  name = f.sub(sub, "\\1")
38
- a[name] = nodes_data(config, env).select { |k, v| v['farm'] == name }.length
56
+ a[name] = nodes_parameters(config, env).select { |k, v| v['farm'] == name }.length
39
57
  a
40
58
  end
41
59
  end
42
60
 
61
+ def modules_counted(config, env = 'production', reload = false)
62
+ reload_nodes if reload
63
+ Dir.glob(File.join(config.modulepath, '*')).sort.reduce({}) do |acc, mod|
64
+ acc
65
+ end
66
+ end
67
+
43
68
  end
44
69
  end
@@ -79,4 +79,8 @@ describe Hieracles::Options::Hc do
79
79
  end
80
80
 
81
81
  end
82
+
83
+ describe '.usage' do
84
+ it { expect(Hieracles::Options::Hc.usage).to include('Usage')}
85
+ end
82
86
  end
@@ -42,7 +42,7 @@ describe Hieracles::Registry do
42
42
  it { expect(Hieracles::Registry.modules config).to eq expected }
43
43
  end
44
44
 
45
- describe '.nodes_data' do
45
+ describe '.nodes_parameters' do
46
46
  let(:expected) {
47
47
  {
48
48
  'server.example.com' => {
@@ -68,7 +68,7 @@ describe Hieracles::Registry do
68
68
  }
69
69
  }
70
70
  let(:config) { Hieracles::Config.new options }
71
- it { expect(Hieracles::Registry.nodes_data config).to eq expected }
71
+ it { expect(Hieracles::Registry.nodes_parameters config).to eq expected }
72
72
  end
73
73
 
74
74
  describe '.farms_counted' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hieracles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - mose
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-18 00:00:00.000000000 Z
11
+ date: 2016-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -153,6 +153,8 @@ files:
153
153
  - bin/ppdb
154
154
  - hc.1
155
155
  - lib/hieracles.rb
156
+ - lib/hieracles/actions.rb
157
+ - lib/hieracles/actions/modules.rb
156
158
  - lib/hieracles/config.rb
157
159
  - lib/hieracles/format.rb
158
160
  - lib/hieracles/formats/console.rb
@@ -263,61 +265,61 @@ signing_key:
263
265
  specification_version: 4
264
266
  summary: CLI tool for Hiera parameters visualization.
265
267
  test_files:
266
- - spec/files/hiera_deeper.yaml
267
- - spec/files/facts.json
268
- - spec/files/farm_modules/dev4.pp
269
- - spec/files/farm_modules/dev2.pp
270
- - spec/files/farm_modules/dev.pp
271
- - spec/files/enc/server2.example.com.yaml
272
- - spec/files/enc/server.example.com.yaml
273
- - spec/files/enc/server3.example.com.yaml
274
- - spec/files/enc/server4.example.com.yaml
275
- - spec/files/config.yml
276
- - spec/files/hiera_deep.yaml
277
- - spec/files/params/nodes/server.example.com.yaml
278
- - spec/files/params/farm/dev.yaml
279
- - spec/files/params/common/common.yml
280
- - spec/files/params/farm_datacenter/dev_dc1.yaml
281
- - spec/files/params/farm_datacenter/dev_dc2.yaml
268
+ - spec/spec_helper.rb
282
269
  - spec/files/hiera_no_yamlbackend.yaml
283
- - spec/files/ssl/key.pem
284
- - spec/files/ssl/bad-cert.crt
270
+ - spec/files/facts.json
271
+ - spec/files/hiera_columns.yaml
272
+ - spec/files/ssl/ca.crt
285
273
  - spec/files/ssl/bad-ca.crt
286
274
  - spec/files/ssl/key-pass.pem
287
275
  - spec/files/ssl/cert.crt
288
- - spec/files/ssl/ca.crt
276
+ - spec/files/ssl/bad-cert.crt
289
277
  - spec/files/ssl/bad-key.pem
278
+ - spec/files/ssl/key.pem
290
279
  - spec/files/config_withdb.yml
291
- - spec/files/hiera.yaml
280
+ - spec/files/params/common/common.yml
281
+ - spec/files/params/farm_datacenter/dev_dc1.yaml
282
+ - spec/files/params/farm_datacenter/dev_dc2.yaml
283
+ - spec/files/params/farm/dev.yaml
284
+ - spec/files/params/nodes/server.example.com.yaml
285
+ - spec/files/enc/server2.example.com.yaml
286
+ - spec/files/enc/server.example.com.yaml
287
+ - spec/files/enc/server4.example.com.yaml
288
+ - spec/files/enc/server3.example.com.yaml
289
+ - spec/files/farm_modules/dev4.pp
290
+ - spec/files/farm_modules/dev.pp
291
+ - spec/files/farm_modules/dev2.pp
292
292
  - spec/files/hiera_yamlbackend_notfound.yaml
293
- - spec/files/modules/faux_module2/manifests/init.pp
294
- - spec/files/modules/fake_module/manifests/init.pp
293
+ - spec/files/hiera.yaml
295
294
  - spec/files/modules/fake_module3/manifests/init.pp
296
- - spec/files/modules/faux_module1/manifests/init.pp
295
+ - spec/files/modules/fake_module/manifests/init.pp
297
296
  - spec/files/modules/fake_module2/manifests/init.pp
298
- - spec/files/hiera_columns.yaml
297
+ - spec/files/modules/faux_module2/manifests/init.pp
298
+ - spec/files/modules/faux_module1/manifests/init.pp
299
299
  - spec/files/facts.yaml
300
- - spec/spec_helper.rb
301
- - spec/lib/hieracles_spec.rb
302
- - spec/lib/utils_spec.rb
303
- - spec/lib/config_spec.rb
304
- - spec/lib/registry_spec.rb
305
- - spec/lib/notification_spec.rb
306
- - spec/lib/puppetdb/fixsslconnectionadapter_spec.rb
300
+ - spec/files/config.yml
301
+ - spec/files/hiera_deep.yaml
302
+ - spec/files/hiera_deeper.yaml
303
+ - spec/lib/node_spec.rb
307
304
  - spec/lib/puppetdb/client_spec.rb
308
- - spec/lib/puppetdb/apierror_spec.rb
305
+ - spec/lib/puppetdb/fixsslconnectionadapter_spec.rb
309
306
  - spec/lib/puppetdb/response_spec.rb
310
- - spec/lib/puppetdb/query_spec.rb
311
307
  - spec/lib/puppetdb/request_spec.rb
312
- - spec/lib/interpolate_spec.rb
308
+ - spec/lib/puppetdb/apierror_spec.rb
309
+ - spec/lib/puppetdb/query_spec.rb
310
+ - spec/lib/hieracles_spec.rb
311
+ - spec/lib/notification_spec.rb
312
+ - spec/lib/utils_spec.rb
313
313
  - spec/lib/format_spec.rb
314
- - spec/lib/optparse_spec.rb
315
- - spec/lib/options/hc_spec.rb
316
- - spec/lib/node_spec.rb
317
- - spec/lib/hiera_spec.rb
318
- - spec/lib/formats/csv_spec.rb
314
+ - spec/lib/config_spec.rb
315
+ - spec/lib/interpolate_spec.rb
319
316
  - spec/lib/formats/rawyaml_spec.rb
320
317
  - spec/lib/formats/plain_spec.rb
321
- - spec/lib/formats/console_spec.rb
322
- - spec/lib/formats/yaml_spec.rb
323
318
  - spec/lib/formats/json_spec.rb
319
+ - spec/lib/formats/yaml_spec.rb
320
+ - spec/lib/formats/csv_spec.rb
321
+ - spec/lib/formats/console_spec.rb
322
+ - spec/lib/options/hc_spec.rb
323
+ - spec/lib/optparse_spec.rb
324
+ - spec/lib/registry_spec.rb
325
+ - spec/lib/hiera_spec.rb