kitchen-chef_zero_berks_env 0.0.1
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 +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE +22 -0
- data/README.md +3 -0
- data/lib/kitchen-chef_zero_berks_env.rb +1 -0
- data/lib/kitchen/provisioner/chef_zero_berks_env.rb +68 -0
- metadata +95 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 1783b25f34c1019072530c1d1054d715fdf4128d
|
|
4
|
+
data.tar.gz: 22cc6843ad7997c77d783dd5ddda6705a8b0fa4c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7b377e9d35cf7c9c5e110e4318179658e31c64b74fd9a16986ef607355074690b9eb422bd209b8ad24238276de0fb0b23e8ba19f4145b0a28f9cb0036fc1d007
|
|
7
|
+
data.tar.gz: 5ec23b509085b994245291024172416baa4ed5036ada5f6b814cc8947cc049e5365345df8793bb020d87f6568152b5d8f4e63f40c7aa99687796d49840e711af
|
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Mário Santos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
data/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'kitchen/provisioner/chef_zero_berks_env'
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require "kitchen/provisioner/chef_zero"
|
|
4
|
+
|
|
5
|
+
module Kitchen
|
|
6
|
+
|
|
7
|
+
module Provisioner
|
|
8
|
+
|
|
9
|
+
# Tweaked Chef Zero provisioner that enables Berkshelf to load cookbook restrictions from Chef environments.
|
|
10
|
+
#
|
|
11
|
+
# @author Mário Santos <mario.rf.santos@gmail.com>
|
|
12
|
+
class ChefZeroBerksEnv < ChefZero
|
|
13
|
+
|
|
14
|
+
# Performs a Berkshelf cookbook resolution inside a common mutex.
|
|
15
|
+
#
|
|
16
|
+
# @api private
|
|
17
|
+
def resolve_with_berkshelf
|
|
18
|
+
|
|
19
|
+
# Load Berksfile
|
|
20
|
+
berks = ::Berkshelf::Berksfile.from_file(berksfile)
|
|
21
|
+
|
|
22
|
+
chef_environment = config[:client_rb][:environment]
|
|
23
|
+
|
|
24
|
+
# skip if the environment was not specified
|
|
25
|
+
unless chef_environment.nil?
|
|
26
|
+
info("Loading chef environment '#{chef_environment}'...")
|
|
27
|
+
debug("Using environment from '#{config[:environments_path]}/#{chef_environment}.json'")
|
|
28
|
+
|
|
29
|
+
environment_json = JSON.parse(File.read("#{config[:environments_path]}/#{chef_environment}.json"))
|
|
30
|
+
|
|
31
|
+
::Berkshelf.ui.mute do
|
|
32
|
+
info("Resolving dependency graph with Berkshelf #{::Berkshelf::VERSION}...")
|
|
33
|
+
berks.install
|
|
34
|
+
info("Locking the versions fetched from the chef environment '#{chef_environment}'...")
|
|
35
|
+
unless environment_json["cookbook_versions"].nil?
|
|
36
|
+
berks.lockfile.graph.each do | graphitem |
|
|
37
|
+
version = environment_json["cookbook_versions"][graphitem.name]
|
|
38
|
+
unless version.nil? or berks.has_dependency?(graphitem.name)
|
|
39
|
+
info("Adding Berkshelf dependency: #{graphitem.name} (#{version})")
|
|
40
|
+
berks.add_dependency(graphitem.name, version)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
# update the lockfile
|
|
44
|
+
berks.update
|
|
45
|
+
berks.lockfile.graph.update(berks.install)
|
|
46
|
+
berks.lockfile.update(berks.dependencies)
|
|
47
|
+
berks.lockfile.save
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
Kitchen.mutex.synchronize do
|
|
52
|
+
info("Resolving cookbook dependencies with Berkshelf #{::Berkshelf::VERSION}...")
|
|
53
|
+
debug("Using Berksfile from #{berksfile}")
|
|
54
|
+
|
|
55
|
+
::Berkshelf.ui.mute do
|
|
56
|
+
if ::Berkshelf::Berksfile.method_defined?(:vendor)
|
|
57
|
+
# Berkshelf 3.0 requires the directory to not exist
|
|
58
|
+
FileUtils.rm_rf(tmpbooks_dir)
|
|
59
|
+
berks.vendor(tmpbooks_dir)
|
|
60
|
+
else
|
|
61
|
+
berks.install(:path => tmpbooks_dir)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: kitchen-chef_zero_berks_env
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mário Santos
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-09-20 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: test-kitchen
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.3'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.3'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: pry
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: berkshelf
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.2'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.2'
|
|
55
|
+
description: "Plugin for test-kitchen that extends the chef_zero provisioner allowing\n
|
|
56
|
+
\ berkshelf to use cookbook restrictions loaded from chef environment
|
|
57
|
+
files.\n This way, Berkshelf will allways vendor the cookbook
|
|
58
|
+
versions specified \n in the chef environment."
|
|
59
|
+
email:
|
|
60
|
+
- mario.rf.santos@gmail.com
|
|
61
|
+
executables: []
|
|
62
|
+
extensions: []
|
|
63
|
+
extra_rdoc_files: []
|
|
64
|
+
files:
|
|
65
|
+
- CHANGELOG.md
|
|
66
|
+
- LICENSE
|
|
67
|
+
- README.md
|
|
68
|
+
- lib/kitchen-chef_zero_berks_env.rb
|
|
69
|
+
- lib/kitchen/provisioner/chef_zero_berks_env.rb
|
|
70
|
+
homepage: https://github.com/ruizink/kitchen-chef_zero_berks_env
|
|
71
|
+
licenses:
|
|
72
|
+
- MIT
|
|
73
|
+
metadata: {}
|
|
74
|
+
post_install_message:
|
|
75
|
+
rdoc_options: []
|
|
76
|
+
require_paths:
|
|
77
|
+
- lib
|
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - ">="
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '0'
|
|
88
|
+
requirements: []
|
|
89
|
+
rubyforge_project:
|
|
90
|
+
rubygems_version: 2.4.5
|
|
91
|
+
signing_key:
|
|
92
|
+
specification_version: 4
|
|
93
|
+
summary: Chef Zero provider for Test Kitchen that enables Berkshelf to vendor the
|
|
94
|
+
cookbook versions specified by a given chef environment.
|
|
95
|
+
test_files: []
|