onceover 3.3.2 → 3.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -3
- data/features/cache.feature +3 -3
- data/features/step_definitions/common.rb +5 -0
- data/lib/onceover/testconfig.rb +23 -2
- data/onceover.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d970b3c7f7f33daa6aa3aaba626ac54553df9f0
|
4
|
+
data.tar.gz: e901a53d75898cd81636686b3f6bde9f91d5ac01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e04cc3d126cfbd43bb1268fed2012cf2d0433872e7f0452e24eeb0ac1f094164e68b6cf02cd52aec18575ea44930a7293dd9ebb7f2fd730dfbe46939015a281
|
7
|
+
data.tar.gz: f9be9848f00ab64058b6a9c755dd00a6c96eb9104c81c04242d294c9cff6ed5fbebe945cf56d9e3e1fa680ea0bdf9e8cc083d0010ba3ff3f1d89f52c4d3c7dab
|
data/README.md
CHANGED
@@ -304,11 +304,23 @@ HOSTS:
|
|
304
304
|
|
305
305
|
### Hiera Data
|
306
306
|
|
307
|
-
If you have hiera data inside your controlrepo (or somewhere else)
|
307
|
+
If you have hiera data inside your controlrepo (or somewhere else) Onceover can be configured to use it. It is however worth noting the the `hiera.yaml` file that you currently use may not be applicable for testing right away. For example; if you are using `hiera-eyaml` I recommend creating a `hiera.yaml` purely for testing that simply uses the `yaml` backend, meaning that you don't need to provide the private keys to the testing machines.
|
308
308
|
|
309
|
-
|
309
|
+
It is also worth noting that any hiera hierarchies that are based on custom facts will not work unless those facts are part of your factsets. Trusted facts will also not work at all as the catalogs are being compiled without the node's certificate. In these instances it may be worth creating a hierarchy level that simply includes dummy data for testing purposes in order to avoid hiera lookup errors.
|
310
310
|
|
311
|
-
|
311
|
+
#### Creating the config file
|
312
|
+
|
313
|
+
If your `hiera.yaml` is version 4 or 5 and lives in the root of the controlrepo (as it should), Onceover will pick this up automatically. If you would like to make changes to this file for testing purposes, create a copy under `spec/hiera.yaml`. Onceover will use this version of the hiera config file first if it exists.
|
314
|
+
|
315
|
+
#### Setting the `datadir`
|
316
|
+
|
317
|
+
| Hiera Version | Config File Location | Required datadir |
|
318
|
+
|---------------|----------------------|------------------|
|
319
|
+
| 3 | `spec` folder | relative to the root of the repo e.g. `data` |
|
320
|
+
| 4 *deprecated* | Root of repo | relative to the root of the repo e.g. `data` |
|
321
|
+
| 4 *deprecated* | `spec` folder | relative to the spec folder e.g. `../data` |
|
322
|
+
| 5 | Root of repo | relative to the root of the repo e.g. `data` |
|
323
|
+
| 5 | `spec` folder | relative to the spec folder e.g. `../data` |
|
312
324
|
|
313
325
|
## Spec testing
|
314
326
|
|
data/features/cache.feature
CHANGED
@@ -15,19 +15,19 @@ Feature: Create and maintain a .onceover cache
|
|
15
15
|
And the cache should contain all controlrepo files
|
16
16
|
|
17
17
|
Scenario: Creating a new file
|
18
|
-
Given control repo "caching"
|
18
|
+
Given existing control repo "caching"
|
19
19
|
When I create a file "example.txt"
|
20
20
|
And I run onceover command "run spec"
|
21
21
|
Then "example.txt" should be cached correctly
|
22
22
|
|
23
23
|
Scenario: Deleting a file
|
24
|
-
Given control repo "caching"
|
24
|
+
Given existing control repo "caching"
|
25
25
|
When I delete a file "deleteme.txt"
|
26
26
|
And I run onceover command "run spec"
|
27
27
|
Then "deleteme.txt" should be deleted from the cache
|
28
28
|
|
29
29
|
Scenario: Caching hidden files
|
30
|
-
Given control repo "caching"
|
30
|
+
Given existing control repo "caching"
|
31
31
|
When I create a file ".hidden/.hiddenfile"
|
32
32
|
And I run onceover command "run spec"
|
33
33
|
Then ".hidden/.hiddenfile" should be cached correctly
|
@@ -10,6 +10,11 @@ Given(/^control repo "([^"]*)"$/) do |controlrepo_name|
|
|
10
10
|
FileUtils.cp_r "spec/fixtures/controlrepos/#{controlrepo_name}", @repo.tmp_folder
|
11
11
|
end
|
12
12
|
|
13
|
+
Given(/^existing control repo "([^"]*)"$/) do |controlrepo_name|
|
14
|
+
@repo = ControlRepo_Helper.new( controlrepo_name )
|
15
|
+
@cmd.controlrepo = @repo
|
16
|
+
end
|
17
|
+
|
13
18
|
Given(/^initialized control repo "([^"]*)"$/) do |controlrepo_name|
|
14
19
|
step %Q(control repo "#{controlrepo_name}")
|
15
20
|
step %Q(I run onceover command "init")
|
data/lib/onceover/testconfig.rb
CHANGED
@@ -210,6 +210,16 @@ class Onceover
|
|
210
210
|
FileUtils.cp(file,"#{temp_controlrepo}/#{(file.relative_path_from(Pathname(repo.root))).to_s}")
|
211
211
|
end
|
212
212
|
|
213
|
+
logger.debug "Writing manifest of copied controlrepo files"
|
214
|
+
require 'json'
|
215
|
+
# Create a manifest of all files that were in the original repo
|
216
|
+
manifest = controlrepo_files.map do |file|
|
217
|
+
# Make sure the paths are relative so they remain relevant when used later
|
218
|
+
file.relative_path_from(Pathname(repo.root)).to_s
|
219
|
+
end
|
220
|
+
# Write all but the first as this is the root and we don't care about that
|
221
|
+
File.write("#{temp_controlrepo}/.onceover_manifest.json",manifest[1..-1].to_json)
|
222
|
+
|
213
223
|
# When using puppetfile vs deploy with r10k, we want to respect the :control_branch
|
214
224
|
# located in the Puppetfile. To accomplish that, we use git and find the current
|
215
225
|
# branch name, then replace strings within the staged puppetfile, prior to copying.
|
@@ -224,11 +234,22 @@ class Onceover
|
|
224
234
|
new_puppetfile_contents = puppetfile_contents.gsub(/:control_branch/, "'#{git_branch}'")
|
225
235
|
File.write("#{temp_controlrepo}/Puppetfile", new_puppetfile_contents)
|
226
236
|
|
227
|
-
|
237
|
+
# Remove all files written by the laste onceover run, but not the ones
|
238
|
+
# added by r10k, because that's what we are trying to cache but we don't
|
239
|
+
# know what they are
|
240
|
+
old_manifest_path = "#{repo.tempdir}/#{repo.environmentpath}/production/.onceover_manifest.json"
|
241
|
+
if File.exist? old_manifest_path
|
242
|
+
logger.debug "Found manifest from previous run, parsing..."
|
243
|
+
old_manifest = JSON.parse(File.read(old_manifest_path))
|
244
|
+
logger.debug "Removing #{old_manifest.count} files"
|
245
|
+
old_manifest.reverse.each do |file|
|
246
|
+
FileUtils.rm_f(File.join("#{repo.tempdir}/#{repo.environmentpath}/production/",file))
|
247
|
+
end
|
248
|
+
end
|
228
249
|
FileUtils.mkdir_p("#{repo.tempdir}/#{repo.environmentpath}")
|
229
250
|
|
230
251
|
logger.debug "Copying #{temp_controlrepo} to #{repo.tempdir}/#{repo.environmentpath}/production"
|
231
|
-
FileUtils.cp_r(temp_controlrepo, "#{repo.tempdir}/#{repo.environmentpath}/production")
|
252
|
+
FileUtils.cp_r("#{temp_controlrepo}/.", "#{repo.tempdir}/#{repo.environmentpath}/production")
|
232
253
|
FileUtils.rm_rf(temp_controlrepo)
|
233
254
|
|
234
255
|
# Pull the trigger! If it's not already been pulled
|
data/onceover.gemspec
CHANGED
@@ -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.3.
|
7
|
+
s.version = "3.3.3"
|
8
8
|
s.authors = ["Dylan Ratcliffe"]
|
9
9
|
s.email = ["dylan.ratcliffe@puppet.com"]
|
10
10
|
s.homepage = "https://github.com/dylanratcliffe/onceover"
|
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.3.
|
4
|
+
version: 3.3.3
|
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-
|
11
|
+
date: 2018-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|