knife-solve 1.0.1 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d332768f80c8c740d920219dac2923499fd432cb
4
- data.tar.gz: cd678a884858bded993e8536a6e6f2a0c53e3429
3
+ metadata.gz: 80174841ace3f60ff00027bc0ce61dab6046edd5
4
+ data.tar.gz: ca1c16978219a2a171591f7940c046c435acef67
5
5
  SHA512:
6
- metadata.gz: aa0acebe839e6408ee7e0352c440e19c2f31ba8c3750186a67afdc9f8c25d342e7d42524beb22f6ee2ae12beca11c541b9bc4d7e46df9e083de3bdfe7d27ecd6
7
- data.tar.gz: c2fe5c24e56ed3419509b75c0c4849718ac2f912e1c5a5675d240e1c43e70b7bd5c3006001c8ed5e3404f673491b2bb3f953639178df2f12e6072e2afded06c7
6
+ metadata.gz: c8c7bf5377c8ea01127faf89bd6dc6fef2b9cb9a786670096691a9dbd56fb3b72db60ea145ab29c5841d4b689bc99ea8fa2676c36982899232a3b777e577d272
7
+ data.tar.gz: f0a2a5498cfb383899026af9cf9b3ba98dd5a6ed41839077bcc86397f4fd1b3aa9581390e42ee1eabc9bf9c474ab080c34e5f4fe63d6316c8ea11e48d84df6eb
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg/
2
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ rvm:
5
+ - "2.2"
6
+ script: bundle exec rake test
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2014-2016, Noah Kantrowitz
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
+ source 'https://rubygems.org'
18
+
19
+ gemspec
data/README.md CHANGED
@@ -22,6 +22,12 @@ As with all knife plugins, just install the gem:
22
22
  gem install knife-solve
23
23
  ```
24
24
 
25
+ Or if you use ChefDK:
26
+
27
+ ```
28
+ chef gem install knife-solve
29
+ ```
30
+
25
31
  Usage
26
32
  -----
27
33
 
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014, Noah Kantrowitz
2
+ # Copyright 2014-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -14,18 +14,20 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'bundler'
18
- require 'rubygems'
19
- require 'rubygems/package_task'
20
- require 'rspec/core/rake_task'
21
-
22
- Bundler::GemHelper.install_tasks
23
-
24
- task :default => :spec
17
+ require 'bundler/gem_tasks'
25
18
 
26
- desc 'Run specs'
27
- RSpec::Core::RakeTask.new(:spec) do |spec|
28
- spec.pattern = 'spec/**/*_spec.rb'
19
+ require 'rspec/core/rake_task'
20
+ RSpec::Core::RakeTask.new(:spec, :tag) do |t, args|
21
+ t.rspec_opts = [].tap do |a|
22
+ a << '--color'
23
+ a << "--format #{ENV['CI'] ? 'documentation' : 'Fuubar'}"
24
+ a << '--backtrace' if ENV['DEBUG']
25
+ a << "--seed #{ENV['SEED']}" if ENV['SEED']
26
+ a << "--tag #{args[:tag]}" if args[:tag]
27
+ end.join(' ')
29
28
  end
30
29
 
31
- gem_spec = eval(File.read('knife-solve.gemspec'))
30
+ desc 'Run all tests'
31
+ task :test => [:spec]
32
+
33
+ task :default => [:test]
@@ -0,0 +1,42 @@
1
+ #
2
+ # Copyright 2014-2016, Noah Kantrowitz
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
+ $:.unshift(File.dirname(__FILE__) + '/lib')
18
+ require 'knife-solve/version'
19
+
20
+ Gem::Specification.new do |spec|
21
+ spec.name = 'knife-solve'
22
+ spec.version = KnifeSolve::VERSION
23
+ spec.authors = ['Noah Kantrowitz']
24
+ spec.email = %w{noah@coderanger.net}
25
+ spec.description = 'A knife plugin to display cookbook version solutions.'
26
+ spec.summary = spec.description
27
+ spec.homepage = 'https://github.com/coderanger/knife-solve'
28
+ spec.license = 'Apache 2.0'
29
+
30
+ spec.files = `git ls-files`.split($/)
31
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
32
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
33
+ spec.require_paths = %w{lib}
34
+
35
+ spec.add_dependency 'chef', '>= 11.0'
36
+
37
+ spec.add_development_dependency 'rspec', '~> 3.2'
38
+ spec.add_development_dependency 'rspec-its', '~> 1.2'
39
+ spec.add_development_dependency 'chefspec', '~> 4.2'
40
+ spec.add_development_dependency 'fuubar', '~> 2.0'
41
+ spec.add_development_dependency 'simplecov', '~> 0.9'
42
+ end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014, Noah Kantrowitz
2
+ # Copyright 2014-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
16
16
 
17
17
  require 'chef/knife'
18
18
  require 'chef/run_list/run_list_expansion'
19
+ require 'chef/run_list/run_list_item'
19
20
 
20
21
  class Chef
21
22
  class Knife
@@ -32,7 +33,8 @@ class Chef
32
33
 
33
34
  def run
34
35
  environment = config[:environment]
35
- cookbooks = name_args
36
+ cookbooks = name_args.map {|item| item.to_s.split(/,/) }.flatten.each{|item| item.strip! }
37
+ cookbooks.delete_if {|item| item.empty? }
36
38
  if config[:node]
37
39
  node = Chef::Node.load(config[:node])
38
40
  environment ||= node.chef_environment
data/lib/knife-solve.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014, Noah Kantrowitz
2
+ # Copyright 2014-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2014, Noah Kantrowitz
2
+ # Copyright 2014-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -15,5 +15,5 @@
15
15
  #
16
16
 
17
17
  module KnifeSolve
18
- VERSION = '1.0.1'
18
+ VERSION = '1.1.0'
19
19
  end
@@ -0,0 +1,85 @@
1
+ #
2
+ # Copyright 2016, Noah Kantrowitz
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
+ require 'spec_helper'
18
+ require 'chef/knife/solve'
19
+
20
+ describe Chef::Knife::Solve do
21
+ ROLES = {'web' => %w{httpd python}, 'db' => %w{}}
22
+
23
+ let(:argv) { [] }
24
+ let(:rest) { double('Chef::ServerApi') }
25
+ subject { described_class.new(argv) }
26
+ before do
27
+ allow(subject).to receive(:rest).and_return(rest)
28
+ allow(subject).to receive(:msg)
29
+ allow(subject).to receive(:ui).and_return(double(info: nil))
30
+ allow(Chef::RunList::RunListExpansionFromAPI).to receive(:new) do |_envirionment, run_list, _rest|
31
+ recipes = run_list.map do |item|
32
+ case item.type
33
+ when :role
34
+ ROLES[item.name] || begin
35
+ raise "unknown role #{item.name}"
36
+ end
37
+ when :recipe
38
+ item.name
39
+ else
40
+ raise "unknown run list item #{item}"
41
+ end
42
+ end.flatten
43
+ double('RunListExpansionFromAPI', expand: nil, recipes: recipes)
44
+ end
45
+ end
46
+ def expect_post(cookbooks, environment)
47
+ expect(rest).to receive(:post_rest).with("/environments/#{environment}/cookbook_versions", 'run_list' => cookbooks).and_return([])
48
+ subject.run
49
+ end
50
+
51
+ context 'with a single argument' do
52
+ let(:argv) { %w{foo} }
53
+ it { expect_post(%w{foo}, '_default') }
54
+ end # /context with a single argument
55
+
56
+ context 'with a two arguments' do
57
+ let(:argv) { %w{foo bar} }
58
+ it { expect_post(%w{foo bar}, '_default') }
59
+ end # /context with a two arguments
60
+
61
+ context 'with a recipe' do
62
+ let(:argv) { %w{recipe[foo]} }
63
+ it { expect_post(%w{foo}, '_default') }
64
+ end # /context with a recipe
65
+
66
+ context 'with a role' do
67
+ let(:argv) { %w{role[web]} }
68
+ it { expect_post(%w{httpd python}, '_default') }
69
+ end # /context with a role
70
+
71
+ context 'with comma-separated arguments' do
72
+ let(:argv) { %w{foo,bar} }
73
+ it { expect_post(%w{foo bar}, '_default') }
74
+ end # /context with comma-separated arguments
75
+
76
+ context 'with a role and a recipe' do
77
+ let(:argv) { %w{role[web] recipe[other]} }
78
+ it { expect_post(%w{httpd python other}, '_default') }
79
+ end # /context with a role and a recipe
80
+
81
+ context 'with a single comma-separated argument' do
82
+ let(:argv) { ['foo, bar'] }
83
+ it { expect_post(%w{foo bar}, '_default') }
84
+ end # /context with a single comma-separated argument'
85
+ end
@@ -0,0 +1,31 @@
1
+ #
2
+ # Copyright 2016, Noah Kantrowitz
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
+ require 'rake'
18
+ require 'rspec'
19
+ require 'rspec/its'
20
+
21
+ RSpec.configure do |config|
22
+ # Basic configuraiton
23
+ config.run_all_when_everything_filtered = true
24
+ config.filter_run(:focus)
25
+
26
+ # Run specs in random order to surface order dependencies. If you find an
27
+ # order dependency and want to debug it, you can fix the order by providing
28
+ # the seed, which is printed after each run.
29
+ # --seed 1234
30
+ config.order = 'random'
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-solve
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Kantrowitz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-26 00:00:00.000000000 Z
11
+ date: 2016-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
@@ -16,55 +16,103 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '11.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '11.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '3.2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '3.2'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: rspec-its
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.2'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: chefspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: fuubar
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.9'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
53
95
  - !ruby/object:Gem::Version
54
- version: '0'
96
+ version: '0.9'
55
97
  description: A knife plugin to display cookbook version solutions.
56
- email: noah@coderanger.net
98
+ email:
99
+ - noah@coderanger.net
57
100
  executables: []
58
101
  extensions: []
59
- extra_rdoc_files:
60
- - LICENSE
102
+ extra_rdoc_files: []
61
103
  files:
104
+ - ".gitignore"
105
+ - ".travis.yml"
106
+ - Gemfile
62
107
  - LICENSE
63
108
  - README.md
64
109
  - Rakefile
110
+ - knife-solve.gemspec
65
111
  - lib/chef/knife/solve.rb
66
112
  - lib/knife-solve.rb
67
113
  - lib/knife-solve/version.rb
114
+ - spec/solve_spec.rb
115
+ - spec/spec_helper.rb
68
116
  homepage: https://github.com/coderanger/knife-solve
69
117
  licenses:
70
118
  - Apache 2.0
@@ -85,8 +133,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
133
  version: '0'
86
134
  requirements: []
87
135
  rubyforge_project:
88
- rubygems_version: 2.2.2
136
+ rubygems_version: 2.4.8
89
137
  signing_key:
90
138
  specification_version: 4
91
139
  summary: A knife plugin to display cookbook version solutions.
92
- test_files: []
140
+ test_files:
141
+ - spec/solve_spec.rb
142
+ - spec/spec_helper.rb