chef-sugar 2.3.2 → 2.4.0

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: 29b7d7e12e7d9ae4b0723f877983a5d42505ae3e
4
- data.tar.gz: 1e16639547341f9b8e873e84866c5dc040003a48
3
+ metadata.gz: acce8120b89eabad574e8afe880736aa6572ab29
4
+ data.tar.gz: b4dd4b9ceefc85177ffd4145fbd2115d57ccf7ad
5
5
  SHA512:
6
- metadata.gz: 7f3cc8734d0598fc2647b67f8e3d98660a8fa7f0c303697bf60c2dce5afcbfeca15a9952a6b535882ca59156b26ad3432f40710e8e46edac2ee29d9d614b1b20
7
- data.tar.gz: 0e117f83f0dbd560a9bb16c5bfea6a61a01f99bc544d27aa267bddd008680aa02ff5a51557c50c407d9a380b4d374117f4fa203b8c31c28d88d941a8a6f58458
6
+ metadata.gz: 9af75355be12499e6b7093fa8fe1151a698586b9e57cabdeb50549850cef5c1e6e2b76d578434be87d66c4624a9e0eb7336be42abff62349fc926e35d6a31e46
7
+ data.tar.gz: ef252c8288b7b6e54ea777651f661e4c3e3f733fc790c4820719f912cdc303e9df58951ba1cd44028a55690ccee30cd2f6611a9eb4ea0190e17ebcce7b4eb2cc
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@ Chef Sugar Changelog
2
2
  =========================
3
3
  This file is used to list changes made in each version of the chef-sugar cookbook and gem.
4
4
 
5
+ v2.4.0 (2014-10-12)
6
+ -------------------
7
+ ### Improvements
8
+ - Add `docker?` matcher
9
+
5
10
  v2.3.2 (2014-10-07)
6
11
  -------------------
7
12
  ### Big Fixues
data/README.md CHANGED
@@ -152,6 +152,18 @@ encrypted_data_bag_item('accounts', 'hipchat')
152
152
  encrypted_data_bag_item_for_environment('accounts', 'github')
153
153
  ```
154
154
 
155
+ ### Docker
156
+ Chef Sugar looks for hints to see if the node being converged is a Docker container. When [Ohai supports checking other nodes](https://github.com/opscode/ohai/pull/428), Chef Sugar will automatically pick up the information.
157
+
158
+ - `docker?`
159
+
160
+ #### Examples
161
+ ```ruby
162
+ template '/runme' do
163
+ only_if { docker?(node) }
164
+ end
165
+ ```
166
+
155
167
  ### Attributes
156
168
  Chef Sugar adds more Chef-like DSL to attribute definitions. Instead of using the Ruby hash syntax, you can define attributes using nested namespaces. This DSL may be more friendly to non-Ruby developers. It can safely be mixed-and-matched with the standard syntax.
157
169
 
Binary file
data/lib/chef/sugar.rb CHANGED
@@ -24,6 +24,7 @@ class Chef
24
24
  require_relative 'sugar/cloud'
25
25
  require_relative 'sugar/constraints'
26
26
  require_relative 'sugar/data_bag'
27
+ require_relative 'sugar/docker'
27
28
  require_relative 'sugar/filters'
28
29
  require_relative 'sugar/ip'
29
30
  require_relative 'sugar/kernel'
@@ -0,0 +1,40 @@
1
+ #
2
+ # Copyright 2013-2014, Seth Vargo <sethvargo@gmail.com>
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ class Chef
18
+ module Sugar
19
+ module Docker
20
+ extend self
21
+
22
+ #
23
+ # Returns true if the current node is a docker container.
24
+ #
25
+ # @param [Chef::Node] node
26
+ # the node to check
27
+ #
28
+ # @return [Boolean]
29
+ #
30
+ def docker?(node)
31
+ File.exist?('/.dockerinit') || File.exist?('/.dockerenv')
32
+ end
33
+ end
34
+
35
+ module DSL
36
+ # @see Chef::Sugar::Docker#docker?
37
+ def docker?; Chef::Sugar::Docker.docker?(node); end
38
+ end
39
+ end
40
+ end
@@ -16,6 +16,6 @@
16
16
 
17
17
  class Chef
18
18
  module Sugar
19
- VERSION = '2.3.2'
19
+ VERSION = '2.4.0'
20
20
  end
21
21
  end
data/metadata.rb CHANGED
@@ -14,4 +14,5 @@ For the most up-to-date information and documentation, please visit the [Chef
14
14
  Sugar project page on GitHub](https://github.com/sethvargo/chef-sugar).
15
15
  EOH
16
16
 
17
- version '2.3.2'
17
+ require_relative 'lib/chef/sugar/version'
18
+ version Chef::Sugar::VERSION
data/recipes/default.rb CHANGED
@@ -17,8 +17,10 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
+ gem_version = run_context.cookbook_collection[cookbook_name].metadata.version
21
+
20
22
  chef_gem('chef-sugar') do
21
- version '2.3.2'
23
+ version gem_version
22
24
  action :nothing
23
25
  end.run_action(:install)
24
26
 
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chef::Sugar::Docker do
4
+ it_behaves_like 'a chef sugar'
5
+
6
+ before(:each) do
7
+ allow(File).to receive(:exist?)
8
+ .with("/.dockerenv")
9
+ .and_return(false)
10
+ allow(File).to receive(:exist?)
11
+ .with("/.dockerinit")
12
+ .and_return(false)
13
+ end
14
+
15
+ describe '#docker?' do
16
+ it 'is true when the file /.dockerenv is present' do
17
+ allow(File).to receive(:exist?)
18
+ .with("/.dockerenv")
19
+ .and_return(true)
20
+
21
+ node = { 'docker' => nil }
22
+ expect(described_class.docker?(node)).to be true
23
+ end
24
+
25
+ it 'is true when the file /.dockerinit is present' do
26
+ allow(File).to receive(:exist?)
27
+ .with("/.dockerinit")
28
+ .and_return(true)
29
+
30
+ node = { 'docker' => nil }
31
+ expect(described_class.docker?(node)).to be true
32
+ end
33
+
34
+ it 'is false when the node is not on cloud' do
35
+ node = { 'docker' => nil }
36
+ expect(described_class.docker?(node)).to be false
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-sugar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Vargo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-07 00:00:00.000000000 Z
11
+ date: 2014-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,6 +99,7 @@ files:
99
99
  - LICENSE
100
100
  - README.md
101
101
  - Rakefile
102
+ - chef-sugar-2.3.2.gem
102
103
  - chef-sugar.gemspec
103
104
  - lib/chef/sugar.rb
104
105
  - lib/chef/sugar/architecture.rb
@@ -109,6 +110,7 @@ files:
109
110
  - lib/chef/sugar/core_extensions/object.rb
110
111
  - lib/chef/sugar/core_extensions/string.rb
111
112
  - lib/chef/sugar/data_bag.rb
113
+ - lib/chef/sugar/docker.rb
112
114
  - lib/chef/sugar/filters.rb
113
115
  - lib/chef/sugar/ip.rb
114
116
  - lib/chef/sugar/kernel.rb
@@ -132,6 +134,7 @@ files:
132
134
  - spec/unit/chef/sugar/core_extensions/object_spec.rb
133
135
  - spec/unit/chef/sugar/core_extensions/string_spec.rb
134
136
  - spec/unit/chef/sugar/data_bag_spec.rb
137
+ - spec/unit/chef/sugar/docker_spec.rb
135
138
  - spec/unit/chef/sugar/ip_spec.rb
136
139
  - spec/unit/chef/sugar/kernel_spec.rb
137
140
  - spec/unit/chef/sugar/node_spec.rb
@@ -178,6 +181,7 @@ test_files:
178
181
  - spec/unit/chef/sugar/core_extensions/object_spec.rb
179
182
  - spec/unit/chef/sugar/core_extensions/string_spec.rb
180
183
  - spec/unit/chef/sugar/data_bag_spec.rb
184
+ - spec/unit/chef/sugar/docker_spec.rb
181
185
  - spec/unit/chef/sugar/ip_spec.rb
182
186
  - spec/unit/chef/sugar/kernel_spec.rb
183
187
  - spec/unit/chef/sugar/node_spec.rb