chef-sugar 2.0.0 → 2.1.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: 93e0d5081147bfd7cd05eb8091c27da520a831e8
4
- data.tar.gz: ae8139070b27cca2c83659be2d1bf23b14e31157
3
+ metadata.gz: 7a756ffa35fc9de2af5b25d862c38ec8fcd6c67f
4
+ data.tar.gz: f1bcb6ed7a4e85249f2701d7b4f5b31eb088ac2a
5
5
  SHA512:
6
- metadata.gz: 4c2b69db6e0c2ec129c90bb89ba67c48fb65b68cbb83da240ddb22b72d0285b0b019a35733f8f61cb7c32e42ff8f3444a665f259fa04479c088d27a307d40ea9
7
- data.tar.gz: da5c22f889074fd2e7d8c3f46f9429ae95524c521bd50e31c9af446ea14a4471176968da07579d67c1d7c69df5cd415b9e7edbbfa0c71c36b38470d49e18def4
6
+ metadata.gz: ad76496fedb799ce020db9d54fde348478144e24321a58bacdb3853a18d437e893627f9ca416526d6b99f824954b3fef79318c926eb05b37c90d84cbdb1b639d
7
+ data.tar.gz: 4c1c70570f5f5774f9541112f9be14d5ff65282c49d74d3e431c2b28ec8943a5c4d1000b1650ed9f47ad72f153874cbd8c3eafa300d394ba5aa69d4f3e802344
@@ -5,4 +5,4 @@ rvm:
5
5
 
6
6
  bundler_args: --jobs 7
7
7
 
8
- script: bundle exec rspec --color --format progress
8
+ script: bundle exec rake
@@ -2,6 +2,16 @@ 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.1.0 (2014-06-26)
6
+ -------------------
7
+ ### Improvements
8
+ - Add `solaris2?` matcher
9
+ - Add `aix?` matcher
10
+ - Add 'lxc?' matcher
11
+
12
+ ### Bug Fixes
13
+ - Fix a bug in namespace memoization during attribute initialization
14
+
5
15
  v2.0.0 (2014-06-16)
6
16
  -------------------
7
17
  ### Breaking
data/README.md CHANGED
@@ -273,6 +273,8 @@ node.deep_fetch('apache2', 'config', 'root') => node['apache2']['config']['root'
273
273
  - `redhat_enterprise_linux?`
274
274
  - `scientific_linux?`
275
275
  - `ubuntu?`
276
+ - `solaris2?`
277
+ - `aix?`
276
278
 
277
279
  There are also a series of dynamically defined matchers that map named operating system release versions and comparison operators in the form "#{platform}\_#{operator}\_#{name}?". For example:
278
280
 
@@ -374,6 +376,17 @@ http_request 'http://...' do
374
376
  end
375
377
  ```
376
378
 
379
+ ### Virtualization
380
+ - `lxc?`
381
+
382
+ #### Examples
383
+ ```ruby
384
+ service 'ntpd' do
385
+ action [:enable, :start]
386
+ not_if { lxc? }
387
+ end
388
+ ```
389
+
377
390
  ### Filters
378
391
  - `compile_time` - accepts a block of resources to run at compile time
379
392
  - `before` - insert resource in the collection before the given resource
data/Rakefile CHANGED
@@ -1 +1,11 @@
1
1
  require 'bundler/gem_tasks'
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new do |t|
5
+ t.rspec_opts = [
6
+ '--color',
7
+ '--format progress',
8
+ ].join(' ')
9
+ end
10
+
11
+ task default: :spec
@@ -35,6 +35,7 @@ class Chef
35
35
  require_relative 'sugar/shell'
36
36
  require_relative 'sugar/vagrant'
37
37
  require_relative 'sugar/version'
38
+ require_relative 'sugar/virtualization'
38
39
  end
39
40
  end
40
41
 
@@ -130,9 +130,7 @@ EOH
130
130
  # to prevent accidential method chaining if the block isn't closed
131
131
  #
132
132
  def namespace(*args, &block)
133
- @namespace_options = {
134
- precedence: default
135
- }.merge(args.last.is_a?(Hash) ? args.pop : {})
133
+ @namespace_options = namespace_options.merge(args.last.is_a?(Hash) ? args.pop : {})
136
134
 
137
135
  keys = args.map(&:to_s)
138
136
 
@@ -161,6 +159,17 @@ EOH
161
159
 
162
160
  private
163
161
 
162
+ #
163
+ # The namespace options.
164
+ #
165
+ # @return [Hash]
166
+ #
167
+ def namespace_options
168
+ @namespace_options ||= {
169
+ precedence: default
170
+ }
171
+ end
172
+
164
173
  #
165
174
  # The current namespace. This is actually a reverse-ordered array that
166
175
  # vivifies the correct hash.#
@@ -178,7 +187,7 @@ EOH
178
187
  # @return [Hash<String, Hash>]
179
188
  #
180
189
  def vivified
181
- current_namespace.inject(@namespace_options[:precedence]) do |hash, item|
190
+ current_namespace.inject(namespace_options[:precedence]) do |hash, item|
182
191
  hash[item] ||= {}
183
192
  hash[item]
184
193
  end
@@ -161,6 +161,30 @@ class Chef
161
161
  node['platform'] == 'enterprise'
162
162
  end
163
163
  alias_method :redhat_enterprise?, :redhat_enterprise_linux?
164
+
165
+ #
166
+ # Determine if the current node is solaris2
167
+ #
168
+ # @param [Chef::Node] node
169
+ #
170
+ # @return [Boolean]
171
+ #
172
+ def solaris2?(node)
173
+ node['platform'] == 'solaris2'
174
+ end
175
+ alias_method :solaris?, :solaris2?
176
+
177
+ #
178
+ # Determine if the current node is aix
179
+ #
180
+ # @param [Chef::Node] node
181
+ #
182
+ # @return [Boolean]
183
+ #
184
+ def aix?(node)
185
+ node['platform'] == 'aix'
186
+ end
187
+
164
188
  end
165
189
 
166
190
  module DSL
@@ -16,6 +16,6 @@
16
16
 
17
17
  class Chef
18
18
  module Sugar
19
- VERSION = '2.0.0'
19
+ VERSION = '2.1.0'
20
20
  end
21
21
  end
@@ -0,0 +1,41 @@
1
+ #
2
+ # Copyright 2014, Joseph J. Nuspl Jr. <nuspl@nvwls.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 Virtualization
20
+ extend self
21
+
22
+ #
23
+ # Determine if the current node is running in a linux container.
24
+ #
25
+ # @param [Chef::Node] node
26
+ #
27
+ # @return [Boolean]
28
+ # true if the machine is currently running in a container, false
29
+ # otherwise
30
+ #
31
+ def lxc?(node)
32
+ node['virtualization'] && node['virtualization']['system'] == 'lxc'
33
+ end
34
+ end
35
+
36
+ module DSL
37
+ # @see Chef::Sugar::Virtualization#lxc?
38
+ def lxc?; Chef::Sugar::Virtualization.lxc?(node); end
39
+ end
40
+ end
41
+ end
@@ -87,6 +87,30 @@ describe Chef::Sugar::Platform do
87
87
  end
88
88
  end
89
89
 
90
+ describe '#solaris2?' do
91
+ it 'returns true when the platform is solaris2' do
92
+ node = { 'platform' => 'solaris2' }
93
+ expect(described_class.solaris2?(node)).to be_truthy
94
+ end
95
+
96
+ it 'returns false when the platform is not solaris2' do
97
+ node = { 'platform' => 'windows' }
98
+ expect(described_class.solaris2?(node)).to be_falsey
99
+ end
100
+ end
101
+
102
+ describe '#aix?' do
103
+ it 'returns true when the platform is aix' do
104
+ node = { 'platform' => 'aix' }
105
+ expect(described_class.aix?(node)).to be_truthy
106
+ end
107
+
108
+ it 'returns false when the platform is not aix' do
109
+ node = { 'platform' => 'windows' }
110
+ expect(described_class.aix?(node)).to be_falsey
111
+ end
112
+ end
113
+
90
114
  context 'dynamic matchers' do
91
115
  describe '#ubuntu_after_lucid?' do
92
116
  it 'returns true when the version is later than 10.04' do
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chef::Sugar::Virtualization do
4
+ it_behaves_like 'a chef sugar'
5
+
6
+ describe '#lxc?' do
7
+ it 'returns true when the machine is a linux contianer' do
8
+ node = { 'virtualization' => { 'system' => 'lxc' } }
9
+ expect(described_class.lxc?(node)).to be_truthy
10
+ end
11
+
12
+ it 'returns false when the virtual machine is not lxc' do
13
+ node = { 'virtualization' => { 'system' => 'vbox' } }
14
+ expect(described_class.lxc?(node)).to be_falsey
15
+ end
16
+
17
+ it 'returns false when the machine is not virtual' do
18
+ node = {}
19
+ expect(described_class.lxc?(node)).to be_falsey
20
+ end
21
+ end
22
+ 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.0.0
4
+ version: 2.1.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-06-16 00:00:00.000000000 Z
11
+ date: 2014-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -120,6 +120,7 @@ files:
120
120
  - lib/chef/sugar/shell.rb
121
121
  - lib/chef/sugar/vagrant.rb
122
122
  - lib/chef/sugar/version.rb
123
+ - lib/chef/sugar/virtualization.rb
123
124
  - metadata.rb
124
125
  - recipes/default.rb
125
126
  - spec/spec_helper.rb
@@ -140,6 +141,7 @@ files:
140
141
  - spec/unit/chef/sugar/run_context_spec.rb
141
142
  - spec/unit/chef/sugar/shell_spec.rb
142
143
  - spec/unit/chef/sugar/vagrant_spec.rb
144
+ - spec/unit/chef/sugar/virtualization_spec.rb
143
145
  - spec/unit/recipes/default_spec.rb
144
146
  homepage: https://github.com/sethvargo/chef-sugar
145
147
  licenses:
@@ -161,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
163
  version: '0'
162
164
  requirements: []
163
165
  rubyforge_project:
164
- rubygems_version: 2.2.2
166
+ rubygems_version: 2.3.0
165
167
  signing_key:
166
168
  specification_version: 4
167
169
  summary: A collection of helper methods and modules that make working with Chef recipes
@@ -185,5 +187,6 @@ test_files:
185
187
  - spec/unit/chef/sugar/run_context_spec.rb
186
188
  - spec/unit/chef/sugar/shell_spec.rb
187
189
  - spec/unit/chef/sugar/vagrant_spec.rb
190
+ - spec/unit/chef/sugar/virtualization_spec.rb
188
191
  - spec/unit/recipes/default_spec.rb
189
192
  has_rdoc: