onceover 3.5.2 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c2ba12fedb743733c215c2b933a3d1aef1febeb
4
- data.tar.gz: 17431981ceab3f6da956ac12cde1a4181efbb14d
3
+ metadata.gz: b526c91a6430b4a442c6c7d905325c0c8e66b980
4
+ data.tar.gz: 69bb0524345dcd1b155cc845e9fa5d2d206f3de3
5
5
  SHA512:
6
- metadata.gz: 170d38c14abf8bcef5c26ea1ca824c8b696c9a87af7719930854a3fab808eae2de46e0be44822cded0fab298883bd98454dc1cc3d3ed26a74c4d86def7d17034
7
- data.tar.gz: e3c3fc3e7daa590ef91794d5cc244d0d32350f313de1f96702b250d7ae011d80f630cf1ca60a78ebe4bc6b3a195c39acca3b08eded9b3946dfd33b14c2f896e1
6
+ metadata.gz: 06ba5f38361ec3eafed75cf81b9d902b8bc9e646c3c4f3da9a9bd66024738af70c1692fb1e7493a2c1321b10bdf9178457c156cadf38503aa529f2ce9da1eed8
7
+ data.tar.gz: 0cea3f35c36f7b99a345bfc8b17b15108adb3bd3e3ddc5e6a9ca9af08a458273191be6b8a22ffe217ad51e3f9c7873d3e41ffb718613e7d233c343dfe2714d88
data/README.md CHANGED
@@ -115,7 +115,7 @@ In the example below we have referred to `centos6a` and `centos7b` in all of our
115
115
  - **type** *statement or rvalue*
116
116
  - **returns** *Optional: A value to return*
117
117
 
118
- **before and after conditions** We can set `before` and `after` blocks before each spec test. These are usually used when the functions to stub are conditional: stub functionx if the OS is windows, stub functiony if the fact java_installed is true. The facts are available through the `node_facts` hash.
118
+ **before and after conditions** We can set `before` and `after` blocks before each spec test. These are usually used when the functions to stub are conditional: stub functionx if the OS is windows, stub functiony if the fact java_installed is true. The facts are available through the `node_facts` hash and the trusted facts as `trusted_facts`.
119
119
 
120
120
  ```yaml
121
121
  before:
@@ -250,6 +250,26 @@ Once we have our factset all we need to do is copy it into `spec/factsets/` insi
250
250
 
251
251
  Would map to a node named `server2008r2` in `onceover.yaml`
252
252
 
253
+ #### Trusted Facts
254
+
255
+ You can add trusted facts to the nodesets by creating a new section called trusted:
256
+
257
+ ```
258
+ {
259
+ "name": "node.puppetlabs.net",
260
+ "trusted": {
261
+ "pp_role": "agent",
262
+ "pp_datacenter": "puppet",
263
+ },
264
+ "values": {
265
+ "aio_agent_build": "1.10.4",
266
+ "aio_agent_version": "1.10.4",
267
+ "architecture": "x86_64",
268
+
269
+ ```
270
+
271
+ Notice that the `extensions` part is implied. The first fact in that example translates to `$trusted['extensions']['pp_role']` in Puppet code.
272
+
253
273
  ### nodesets
254
274
 
255
275
  `spec/acceptance/nodesets/onceover-nodes.yml`
@@ -70,7 +70,11 @@ class Onceover
70
70
  end
71
71
 
72
72
  def self.facts(filter = nil)
73
- @@existing_controlrepo.facts(filter)
73
+ @@existing_controlrepo.facts(filter, 'values')
74
+ end
75
+
76
+ def self.trusted_facts(filter = nil)
77
+ @@existing_controlrepo.facts(filter, 'trusted')
74
78
  end
75
79
 
76
80
  def self.hiera_config_file
@@ -170,12 +174,12 @@ class Onceover
170
174
  classes.flatten
171
175
  end
172
176
 
173
- def facts(filter = nil)
177
+ def facts(filter = nil, key = 'values')
174
178
  # Returns an array facts hashes
175
179
  all_facts = []
176
180
  logger.debug "Reading factsets"
177
181
  @facts_files.each do |file|
178
- all_facts << read_facts(file)['values']
182
+ all_facts << read_facts(file)[key]
179
183
  end
180
184
  if filter
181
185
  # Allow us to pass a hash of facts to filter by
@@ -579,7 +583,7 @@ class Onceover
579
583
  begin
580
584
  result = JSON.parse(file)
581
585
  rescue JSON::ParserError
582
- raise "Could not parse the JSON file, check that it is valid JSON and that the encoding is correct"
586
+ raise "Could not parse the file #{facts_file}, check that it is valid JSON and that the encoding is correct"
583
587
  end
584
588
  result
585
589
  end
@@ -8,6 +8,7 @@ class Onceover
8
8
  attr_accessor :name
9
9
  attr_accessor :beaker_node
10
10
  attr_accessor :fact_set
11
+ attr_accessor :trusted_set
11
12
 
12
13
  def initialize(name)
13
14
  @name = name
@@ -19,9 +20,12 @@ class Onceover
19
20
  File.basename(facts_file, '.json') == name
20
21
  }
21
22
  @fact_set = Onceover::Controlrepo.facts[facts_file_index]
23
+ @trusted_set = Onceover::Controlrepo.trusted_facts[facts_file_index]
22
24
  rescue TypeError
23
25
  @fact_set = nil
26
+ @trusted_set = nil
24
27
  end
28
+
25
29
  @@all << self
26
30
 
27
31
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "onceover"
7
- s.version = "3.5.2"
7
+ s.version = "3.6.0"
8
8
  s.authors = ["Dylan Ratcliffe"]
9
9
  s.email = ["dylan.ratcliffe@puppet.com"]
10
10
  s.homepage = "https://github.com/dylanratcliffe/onceover"
@@ -20,6 +20,10 @@ let!(:<%= function %>) { MockFunction.new('<%= function %>') { |f|
20
20
  context "using fact set <%= node.name %>" do
21
21
  node_facts = <%= node.fact_set %>
22
22
  let(:facts) { node_facts }
23
+ <% if node.trusted_set -%>
24
+ trusted_facts = <%= node.trusted_set %>
25
+ let(:trusted_facts) { trusted_facts }
26
+ <% end -%>
23
27
  <% if @before_conditions -%>
24
28
  before :each do
25
29
  <% @before_conditions.each do |function| -%>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onceover
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.2
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Ratcliffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-15 00:00:00.000000000 Z
11
+ date: 2018-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake