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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +12 -0
- data/chef-sugar-2.3.2.gem +0 -0
- data/lib/chef/sugar.rb +1 -0
- data/lib/chef/sugar/docker.rb +40 -0
- data/lib/chef/sugar/version.rb +1 -1
- data/metadata.rb +2 -1
- data/recipes/default.rb +3 -1
- data/spec/unit/chef/sugar/docker_spec.rb +39 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acce8120b89eabad574e8afe880736aa6572ab29
|
4
|
+
data.tar.gz: b4dd4b9ceefc85177ffd4145fbd2115d57ccf7ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
@@ -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
|
data/lib/chef/sugar/version.rb
CHANGED
data/metadata.rb
CHANGED
data/recipes/default.rb
CHANGED
@@ -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.
|
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-
|
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
|