knife-essentials 0.8.1 → 0.8.2

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.
@@ -0,0 +1,95 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'tmpdir'
20
+ require 'fileutils'
21
+ require 'chef_zero/rspec'
22
+ require 'chef/config'
23
+ require 'json'
24
+ require 'support/knife_support'
25
+ require 'support/spec_helper'
26
+
27
+ module IntegrationSupport
28
+ include ChefZero::RSpec
29
+
30
+ def when_the_repository(description, *args, &block)
31
+ context "When the local repository #{description}", *args do
32
+ before :each do
33
+ raise "Can only create one directory per test" if @repository_dir
34
+ @repository_dir = Dir.mktmpdir('chef_repo')
35
+ @old_chef_repo_path = Chef::Config.chef_repo_path
36
+ @old_cookbook_path = Chef::Config.cookbook_path
37
+ Chef::Config.chef_repo_path = @repository_dir
38
+ Chef::Config.cookbook_path = File.join(@repository_dir, 'cookbooks')
39
+ end
40
+
41
+ after :each do
42
+ if @repository_dir
43
+ begin
44
+ Chef::Config.chef_repo_path = @old_chef_repo_path
45
+ Chef::Config.cookbook_path = @old_cookbook_path
46
+ FileUtils.remove_entry_secure(@repository_dir)
47
+ ensure
48
+ @old_chef_repo_path = nil
49
+ @old_cookbook_path = nil
50
+ @repository_dir = nil
51
+ end
52
+ end
53
+ end
54
+
55
+ def directory(relative_path, &block)
56
+ old_parent_path = @parent_path
57
+ @parent_path = path_to(relative_path)
58
+ FileUtils.mkdir_p(@parent_path)
59
+ instance_eval(&block) if block
60
+ @parent_path = old_parent_path
61
+ end
62
+
63
+ def file(relative_path, contents)
64
+ filename = path_to(relative_path)
65
+ dir = File.dirname(filename)
66
+ FileUtils.mkdir_p(dir) unless dir == '.'
67
+ File.open(filename, 'w') do |file|
68
+ if contents.is_a? Hash
69
+ file.write(JSON.pretty_generate(contents))
70
+ else
71
+ file.write(contents)
72
+ end
73
+ end
74
+ end
75
+
76
+ def path_to(relative_path)
77
+ File.expand_path(relative_path, (@parent_path || @repository_dir))
78
+ end
79
+
80
+ def self.directory(relative_path, &block)
81
+ before :each do
82
+ directory(relative_path, &block)
83
+ end
84
+ end
85
+
86
+ def self.file(relative_path, contents)
87
+ before :each do
88
+ file(relative_path, contents)
89
+ end
90
+ end
91
+
92
+ instance_eval(&block)
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,92 @@
1
+ require 'chef/knife'
2
+ require 'chef/application/knife'
3
+
4
+ module KnifeSupport
5
+ def knife(*args, &block)
6
+ # Allow knife('role from file roles/blah.json') rather than requiring the
7
+ # arguments to be split like knife('role', 'from', 'file', 'roles/blah.json')
8
+ # If any argument will have actual spaces in it, the long form is required.
9
+ # (Since knife commands always start with the command name, and command
10
+ # names with spaces are always multiple args, this is safe.)
11
+ if args.length == 1
12
+ args = args[0].split(/\s+/)
13
+ end
14
+
15
+ # This is Chef::Knife.run without load_commands and load_deps--we'll
16
+ # load stuff ourselves, thank you very much
17
+ stdout = StringIO.new
18
+ stderr = StringIO.new
19
+ begin
20
+ subcommand_class = Chef::Knife.subcommand_class_from(args)
21
+ subcommand_class.options = Chef::Application::Knife.options.merge(subcommand_class.options)
22
+ instance = subcommand_class.new(args)
23
+
24
+ # Capture stdout/stderr
25
+ instance.ui = Chef::Knife::UI.new(stdout, stderr, STDIN, {})
26
+
27
+ # Don't print stuff
28
+ Chef::Config[:verbosity] = 0
29
+ instance.configure_chef
30
+ instance.run
31
+
32
+ exit_code = 0
33
+
34
+ # This is how rspec catches exit()
35
+ rescue SystemExit => e
36
+ exit_code = e.status
37
+ end
38
+
39
+ KnifeResult.new(stdout.string, stderr.string, exit_code)
40
+ end
41
+
42
+ private
43
+
44
+ class KnifeResult
45
+ def initialize(stdout, stderr, exit_code)
46
+ @stdout = stdout
47
+ @stderr = stderr
48
+ @exit_code = exit_code
49
+ end
50
+
51
+ def should_fail(*args)
52
+ expected = {}
53
+ args.each do |arg|
54
+ if arg.is_a?(Hash)
55
+ expected.merge!(arg)
56
+ elsif arg.is_a?(Integer)
57
+ expected[:exit_code] = arg
58
+ else
59
+ expected[:stderr] = arg
60
+ end
61
+ end
62
+ expected[:exit_code] = 1 if !expected[:exit_code]
63
+ should_result_in(expected)
64
+ end
65
+
66
+ def should_succeed(*args)
67
+ expected = {}
68
+ args.each do |arg|
69
+ if arg.is_a?(Hash)
70
+ expected.merge!(arg)
71
+ else
72
+ expected[:stdout] = arg
73
+ end
74
+ end
75
+ should_result_in(expected)
76
+ end
77
+
78
+ private
79
+
80
+ def should_result_in(expected)
81
+ expected[:stdout] = '' if !expected[:stdout]
82
+ expected[:stderr] = '' if !expected[:stderr]
83
+ expected[:exit_code] = 0 if !expected[:exit_code]
84
+ # TODO make this go away
85
+ stderr_actual = @stderr.sub(/^WARNING: No knife configuration file found\n/, '')
86
+
87
+ @stdout.should == expected[:stdout]
88
+ stderr_actual.should == expected[:stderr]
89
+ @exit_code.should == expected[:exit_code]
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,27 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIEpAIBAAKCAQEA0sOY9tHvVtLZ6xmVmH8d8LrRrNcWOXbrvvCrai+T3GtRvRSL
3
+ hksLrpOpD0L9EHM6NdThNF/eGA9Oq+UKAe6yXR0hwsKuxKXqQ8SEmlhZZ9GiuggD
4
+ B/zYD3ItB6SGpdkRe7kQqTChQyrIXqbRkJqxo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0Iq1MPsbSrglO1as8MvjB9ldFcvp7gy4Q0Sv6XT0yqJ/S+vo8Df0m+H4UBpU
21
+ f5o6EwBSd/UQxwtZIE0lsQKBgQCswfjX8Eg8KL/lJNpIOOE3j4XXE9ptksmJl2sB
22
+ jxDnQYoiMqVO808saHVquC/vTrpd6tKtNpehWwjeTFuqITWLi8jmmQ+gNTKsC9Gn
23
+ 1Pxf2Gb67PqnEpwQGln+TRtgQ5HBrdHiQIi+5am+gnw89pDrjjO5rZwhanAo6KPJ
24
+ 1zcPNQKBgQDxFu8v4frDmRNCVaZS4f1B6wTrcMrnibIDlnzrK9GG6Hz1U7dDv8s8
25
+ Nf4UmeMzDXjlPWZVOvS5+9HKJPdPj7/onv8B2m18+lcgTTDJBkza7R1mjL1Cje/Z
26
+ KcVGsryKN6cjE7yCDasnA7R2rVBV/7NWeJV77bmzT5O//rW4yIfUIg==
27
+ -----END RSA PRIVATE KEY-----
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-essentials
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-19 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2013-01-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: chef-zero
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  description: Universal knife verbs that work with your Chef repository
15
31
  email: jkeiser@opscode.com
16
32
  executables: []
@@ -34,6 +50,7 @@ files:
34
50
  - lib/chef_fs/file_pattern.rb
35
51
  - lib/chef_fs/file_system/base_fs_dir.rb
36
52
  - lib/chef_fs/file_system/base_fs_object.rb
53
+ - lib/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb
37
54
  - lib/chef_fs/file_system/chef_repository_file_system_entry.rb
38
55
  - lib/chef_fs/file_system/chef_repository_file_system_root_dir.rb
39
56
  - lib/chef_fs/file_system/chef_server_root_dir.rb
@@ -65,8 +82,14 @@ files:
65
82
  - spec/chef_fs/file_system/cookbooks_dir_spec.rb
66
83
  - spec/chef_fs/file_system/data_bags_dir_spec.rb
67
84
  - spec/chef_fs/file_system_spec.rb
85
+ - spec/integration/chef_repository_file_system_spec.rb
86
+ - spec/integration/deps_spec.rb
87
+ - spec/integration/list_spec.rb
68
88
  - spec/support/file_system_support.rb
89
+ - spec/support/integration_helper.rb
90
+ - spec/support/knife_support.rb
69
91
  - spec/support/spec_helper.rb
92
+ - spec/support/stickywicket.pem
70
93
  homepage: http://www.opscode.com
71
94
  licenses: []
72
95
  post_install_message: