-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into mikkergp/allow_custom_templates_in_control…
…_repo
- Loading branch information
Showing
28 changed files
with
419 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ rvm: | |
- 2.3.4 | ||
- 2.4.0 | ||
- 2.4.1 | ||
- 2.4.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@cache | ||
Feature: Create and maintain a .onceover cache | ||
Onceover should be able to cache things in the .onceover directory for speed | ||
increases and debugging of external modules. This cache should remain | ||
up-to-date and should exactly mirror what would be created on the Puppet | ||
master. | ||
|
||
Background: | ||
Given onceover executable | ||
|
||
Scenario: Creating a cache | ||
Given control repo "caching" | ||
When I run onceover command "run spec" | ||
Then the cache should exist | ||
And the cache should contain all controlrepo files | ||
|
||
Scenario: Creating a new file | ||
Given existing control repo "caching" | ||
When I create a file "example.txt" | ||
And I run onceover command "run spec" | ||
Then "example.txt" should be cached correctly | ||
|
||
Scenario: Deleting a file | ||
Given existing control repo "caching" | ||
When I delete a file "deleteme.txt" | ||
And I run onceover command "run spec" | ||
Then "deleteme.txt" should be deleted from the cache | ||
|
||
Scenario: Caching hidden files | ||
Given existing control repo "caching" | ||
When I create a file ".hidden/.hiddenfile" | ||
And I run onceover command "run spec" | ||
Then ".hidden/.hiddenfile" should be cached correctly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Then(/^the cache should exist$/) do | ||
cache_dir = File.join(@repo.root_folder,'.onceover') | ||
expect(File.directory?(cache_dir)).to be true | ||
end | ||
|
||
Then(/^the cache should contain all controlrepo files/) do | ||
# Get all root files | ||
puts "Calculating MD5 hashes in repo" | ||
repo_digest = Cache_Helper.digest(@repo.root_folder) | ||
puts "#{repo_digest.count} MD5 hashes calculated" | ||
puts "Calculating MD5 hashes in cache" | ||
cache_digest = Cache_Helper.digest(File.join(@repo.root_folder,'.onceover/etc/puppetlabs/code/environments/production/')) | ||
puts "#{cache_digest.count} MD5 hashes calculated" | ||
expect(cache_digest).to include(repo_digest) | ||
end | ||
|
||
When(/^I (\w+) a file "(.*)"$/) do |action,file| | ||
require 'securerandom' | ||
actual_file = Pathname.new(File.join(@repo.root_folder,file)) | ||
case action | ||
when "create" | ||
FileUtils.mkdir_p(actual_file.dirname) | ||
File.write(actual_file,SecureRandom.hex) | ||
when "delete" | ||
FileUtils.rm(actual_file) | ||
end | ||
end | ||
|
||
Then(/^"(.*)" should be cached correctly$/) do |file| | ||
original_digest = Cache_Helper.digest(File.join(@repo.root_folder,file)) | ||
cache_digest = Cache_Helper.digest(File.join(@repo.root_folder,'.onceover/etc/puppetlabs/code/environments/production/',file)) | ||
expect(original_digest).to include(cache_digest) | ||
end | ||
|
||
Then(/^"([^"]*)" should be deleted from the cache$/) do |file| | ||
deleted_file = Pathname.new(File.join(@repo.root_folder,'.onceover/etc/puppetlabs/code/environments/production/',file)) | ||
expect(deleted_file.exist?).to be false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require 'pathname' | ||
|
||
class Cache_Helper | ||
|
||
def cache_exists? | ||
File.directory?(dir + '/.onceover') | ||
end | ||
|
||
def self.digest(path, opts = { | ||
exceptions: ['.','..','.onceover'] | ||
}) | ||
if File.directory?(path) | ||
# Get the list of files | ||
children = Cache_Helper.get_children(path, opts[:exceptions]) | ||
else | ||
children = [File.expand_path(path)] | ||
end | ||
|
||
# Calculate hashes | ||
hashes = children.map do |child_path| | ||
if File.directory? child_path | ||
:directory | ||
else | ||
Digest::MD5.file(child_path) | ||
end | ||
end | ||
|
||
root = Pathname.new(File.expand_path(path)) | ||
# Move pathnames back to relative | ||
children.map! do |child_path| | ||
Pathname.new(child_path).relative_path_from root | ||
end | ||
Hash[children.zip(hashes)] | ||
end | ||
|
||
def self.get_children(dir, exclusions) | ||
root_files = [] | ||
files = [] | ||
Dir.chdir(dir) do | ||
# Get all root files | ||
root_files = Dir.glob('*',File::FNM_DOTMATCH) | ||
root_files = root_files - exclusions | ||
root_files.each do |file| | ||
files << file | ||
files << Dir.glob("#{file}/**/*",File::FNM_DOTMATCH) | ||
end | ||
files.flatten! | ||
# Calculate absolue paths | ||
files.map! do |file| | ||
File.expand_path(file) | ||
end | ||
end | ||
files | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__) | |
|
||
Gem::Specification.new do |s| | ||
s.name = "onceover" | ||
s.version = "3.3.1" | ||
s.version = "3.4.0" | ||
s.authors = ["Dylan Ratcliffe"] | ||
s.email = ["[email protected]"] | ||
s.homepage = "https://github.com/dylanratcliffe/onceover" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.onceover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
some: stuff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'onceover' | ||
gem 'beaker', '~> 2.0' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
forge "http://forge.puppetlabs.com" | ||
# | ||
# I want to download some modules to check if r10k feature in Onceover works correctly. | ||
# | ||
|
||
# Versions should be updated to be the latest at the time you start | ||
mod "puppetlabs/stdlib", '4.11.0' | ||
|
||
# Modules from Git | ||
# Examples: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#examples | ||
mod 'apache', | ||
:git => 'https://github.com/puppetlabs/puppetlabs-apache', | ||
:commit => '83401079053dca11d61945bd9beef9ecf7576cbf' | ||
|
||
#mod 'apache', | ||
# :git => 'https://github.com/puppetlabs/puppetlabs-apache', | ||
# :branch => 'docs_experiment' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'onceover/rake_tasks' |
Empty file.
Oops, something went wrong.