knife-essentials 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/chef/knife/converge_essentials.rb +2 -2
- data/lib/chef/knife/diff_essentials.rb +4 -0
- data/lib/chef/knife/download_essentials.rb +4 -0
- data/lib/chef_fs/config.rb +10 -2
- data/lib/chef_fs/file_system/chef_server_root_dir.rb +3 -1
- data/lib/chef_fs/file_system/cookbook_dir.rb +1 -0
- data/lib/chef_fs/knife.rb +1 -1
- data/lib/chef_fs/version.rb +1 -1
- data/spec/integration/converge_spec.rb +75 -0
- metadata +3 -2
@@ -87,12 +87,12 @@ class Chef
|
|
87
87
|
result << "role[#{entry.name}]"
|
88
88
|
|
89
89
|
else
|
90
|
-
ui.error "arguments must be cookbooks, recipes or roles! #{format_path
|
90
|
+
ui.error "arguments must be cookbooks, recipes or roles! #{format_path(entry)} is not a cookbook, recipe or role."
|
91
91
|
self.exit_code = 1
|
92
92
|
end
|
93
93
|
end
|
94
94
|
rescue ChefFS::FileSystem::OperationFailedError => e
|
95
|
-
"#{
|
95
|
+
"#{format_path(e.entry)} #{e.reason}."
|
96
96
|
self.exit_code = 1
|
97
97
|
rescue ChefFS::FileSystem::NotFoundError => e
|
98
98
|
ui.error "#{format_path(e.entry)}: No such file or directory"
|
@@ -32,6 +32,10 @@ class Chef
|
|
32
32
|
:description => "Select only files that are Added (A), Deleted (D), Modified (M), or have their type (i.e. regular file, directory) changed (T). Any combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all paths are selected if
|
33
33
|
there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected."
|
34
34
|
|
35
|
+
option :cookbook_version,
|
36
|
+
:long => '--cookbook-version VERSION',
|
37
|
+
:description => 'Version of cookbook to download (if there are multiple versions and cookbook_versions is false)'
|
38
|
+
|
35
39
|
def run
|
36
40
|
if config[:name_only]
|
37
41
|
output_mode = :name_only
|
@@ -42,6 +42,10 @@ class Chef
|
|
42
42
|
:default => true,
|
43
43
|
:description => 'Turn off to avoid uploading existing files; only new (and possibly deleted) files with --no-diff'
|
44
44
|
|
45
|
+
option :cookbook_version,
|
46
|
+
:long => '--cookbook-version VERSION',
|
47
|
+
:description => 'Version of cookbook to download (if there are multiple versions and cookbook_versions is false)'
|
48
|
+
|
45
49
|
def run
|
46
50
|
if name_args.length == 0
|
47
51
|
show_usage
|
data/lib/chef_fs/config.rb
CHANGED
@@ -24,12 +24,17 @@ module ChefFS
|
|
24
24
|
# Helpers to take Chef::Config and create chef_fs and local_fs from it
|
25
25
|
#
|
26
26
|
class Config
|
27
|
-
def initialize(chef_config = Chef::Config, cwd = Dir.pwd)
|
27
|
+
def initialize(chef_config = Chef::Config, cwd = Dir.pwd, options = {})
|
28
28
|
@chef_config = chef_config
|
29
29
|
@cwd = cwd
|
30
|
+
@cookbook_version = options[:cookbook_version]
|
30
31
|
configure_repo_paths
|
31
32
|
end
|
32
33
|
|
34
|
+
attr_reader :chef_config
|
35
|
+
attr_reader :cwd
|
36
|
+
attr_reader :cookbook_version
|
37
|
+
|
33
38
|
PATH_VARIABLES = %w(acl_path client_path cookbook_path container_path data_bag_path environment_path group_path node_path role_path user_path)
|
34
39
|
|
35
40
|
def chef_fs
|
@@ -38,7 +43,7 @@ module ChefFS
|
|
38
43
|
|
39
44
|
def create_chef_fs
|
40
45
|
require 'chef_fs/file_system/chef_server_root_dir'
|
41
|
-
ChefFS::FileSystem::ChefServerRootDir.new("remote", @chef_config)
|
46
|
+
ChefFS::FileSystem::ChefServerRootDir.new("remote", @chef_config, :cookbook_version => @cookbook_version)
|
42
47
|
end
|
43
48
|
|
44
49
|
def local_fs
|
@@ -170,6 +175,9 @@ module ChefFS
|
|
170
175
|
if @chef_config[:role_path] == @chef_config.platform_specific_path('/var/chef/roles')
|
171
176
|
@chef_config[:role_path] = nil
|
172
177
|
end
|
178
|
+
if @chef_config[:environment_path] == @chef_config.platform_specific_path('/var/chef/environments')
|
179
|
+
@chef_config[:environment_path] = nil
|
180
|
+
end
|
173
181
|
|
174
182
|
# Infer chef_repo_path from cookbook_path if not speciifed
|
175
183
|
if !@chef_config[:chef_repo_path]
|
@@ -33,7 +33,7 @@ require 'chef_fs/data_handler/container_data_handler'
|
|
33
33
|
module ChefFS
|
34
34
|
module FileSystem
|
35
35
|
class ChefServerRootDir < BaseFSDir
|
36
|
-
def initialize(root_name, chef_config)
|
36
|
+
def initialize(root_name, chef_config, options = {})
|
37
37
|
super("", nil)
|
38
38
|
@chef_server_url = chef_config[:chef_server_url]
|
39
39
|
@chef_username = chef_config[:node_name]
|
@@ -41,6 +41,7 @@ module ChefFS
|
|
41
41
|
@environment = chef_config[:environment]
|
42
42
|
@repo_mode = chef_config[:repo_mode]
|
43
43
|
@root_name = root_name
|
44
|
+
@cookbook_version = options[:cookbook_version] # Used in knife diff and download for server cookbook version
|
44
45
|
end
|
45
46
|
|
46
47
|
attr_reader :chef_server_url
|
@@ -48,6 +49,7 @@ module ChefFS
|
|
48
49
|
attr_reader :chef_private_key
|
49
50
|
attr_reader :environment
|
50
51
|
attr_reader :repo_mode
|
52
|
+
attr_reader :cookbook_version
|
51
53
|
|
52
54
|
def fs_description
|
53
55
|
"Chef server at #{chef_server_url} (user #{chef_username}), repo_mode = #{repo_mode}"
|
data/lib/chef_fs/knife.rb
CHANGED
data/lib/chef_fs/version.rb
CHANGED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'support/integration_helper'
|
2
|
+
require 'chef/knife/converge_essentials'
|
3
|
+
|
4
|
+
describe 'knife converge' do
|
5
|
+
let(:sample_cookbook) do
|
6
|
+
return
|
7
|
+
end
|
8
|
+
|
9
|
+
when_the_repository 'has a cookbook' do
|
10
|
+
file 'cookbooks/x/recipes/default.rb', <<EOM
|
11
|
+
file #{path_to('x.txt')} do
|
12
|
+
content 'x::default'
|
13
|
+
end
|
14
|
+
EOM
|
15
|
+
file 'cookbooks/x/recipes/y.rb', <<EOM
|
16
|
+
file #{path_to('x.txt')} do
|
17
|
+
content 'x::y'
|
18
|
+
end
|
19
|
+
EOM
|
20
|
+
file 'cookbooks/x/recipes/fromrole.rb', <<EOM
|
21
|
+
file #{path_to('x.txt')} do
|
22
|
+
content 'x::fromrole'
|
23
|
+
end
|
24
|
+
EOM
|
25
|
+
file 'roles/r.json', { 'run_list' => [ 'recipe[x::r]' ] }
|
26
|
+
|
27
|
+
context 'and current directory is at the top of the repository' do
|
28
|
+
cwd '.'
|
29
|
+
it 'knife converge creates .chef/knife.rb' do
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'knife converge /cookbooks/x converges x::default' do
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'knife converge recipe[x] converges x::default' do
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'knife converge /cookbooks/x/recipes/y.rb converges x::y' do
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'knife converge recipe[x::y] converges x::y' do
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'knife converge /roles/ converges x::fromrole' do
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'knife converge role[r] converges x::fromrole' do
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'and current directory is cookbooks/x/default' do
|
52
|
+
cwd 'cookbooks/x/default'
|
53
|
+
|
54
|
+
it 'knife converge creates .chef/knife.rb' do
|
55
|
+
end
|
56
|
+
it 'knife converge y.rb converges x::y' do
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'and a .chef/knife.rb' do
|
61
|
+
it 'knife converge converges' do
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
when_the_repository 'has a cookbook' do
|
67
|
+
it 'knife converge with no arguments runs the node\'s run list' do
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
when_the_chef_server 'has cookbooks' do
|
72
|
+
it 'knife converge converges them' do
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
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: 1.5.
|
4
|
+
version: 1.5.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- spec/integration/chef_repo_path_spec.rb
|
198
198
|
- spec/integration/chef_repository_file_system_spec.rb
|
199
199
|
- spec/integration/chefignore_spec.rb
|
200
|
+
- spec/integration/converge_spec.rb
|
200
201
|
- spec/integration/delete_spec.rb
|
201
202
|
- spec/integration/deps_spec.rb
|
202
203
|
- spec/integration/diff_spec.rb
|