berkshelf 3.0.0.beta1 → 3.0.0.beta2
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 +7 -0
- data/.ruby-version +1 -1
- data/CONTRIBUTING.md +2 -0
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/Thorfile +2 -2
- data/berkshelf.gemspec +3 -3
- data/features/install_command.feature +36 -8
- data/features/json_formatter.feature +93 -3
- data/features/licenses.feature +1 -1
- data/features/lockfile.feature +0 -12
- data/features/outdated_command.feature +124 -0
- data/features/show_command.feature +44 -25
- data/features/step_definitions/chef/config_steps.rb +2 -2
- data/features/step_definitions/chef_server_steps.rb +9 -1
- data/features/step_definitions/config_steps.rb +1 -1
- data/features/step_definitions/filesystem_steps.rb +7 -0
- data/features/support/env.rb +2 -1
- data/features/update_command.feature +11 -21
- data/features/upload_command.feature +45 -1
- data/features/vendor_command.feature +83 -0
- data/lib/berkshelf.rb +5 -4
- data/lib/berkshelf/api_client/remote_cookbook.rb +13 -0
- data/lib/berkshelf/berksfile.rb +155 -23
- data/lib/berkshelf/chef.rb +0 -1
- data/lib/berkshelf/cli.rb +40 -31
- data/lib/berkshelf/dependency.rb +14 -4
- data/lib/berkshelf/errors.rb +74 -3
- data/lib/berkshelf/formatters.rb +12 -1
- data/lib/berkshelf/formatters/human_readable.rb +44 -5
- data/lib/berkshelf/formatters/json.rb +50 -8
- data/lib/berkshelf/installer.rb +8 -8
- data/lib/berkshelf/location.rb +17 -0
- data/lib/berkshelf/locations/git_location.rb +7 -17
- data/lib/berkshelf/locations/mercurial_location.rb +112 -0
- data/lib/berkshelf/lockfile.rb +1 -1
- data/lib/berkshelf/mercurial.rb +146 -0
- data/lib/berkshelf/version.rb +1 -1
- data/spec/config/knife.rb +2 -4
- data/spec/fixtures/lockfiles/default.lock +0 -1
- data/spec/support/chef_api.rb +9 -2
- data/spec/support/mercurial.rb +122 -0
- data/spec/support/path_helpers.rb +2 -2
- data/spec/unit/berkshelf/berksfile_spec.rb +34 -8
- data/spec/unit/berkshelf/dependency_spec.rb +0 -7
- data/spec/unit/berkshelf/formatters/null_spec.rb +1 -1
- data/spec/unit/berkshelf/locations/mercurial_location_spec.rb +150 -0
- data/spec/unit/berkshelf/lockfile_spec.rb +0 -12
- data/spec/unit/berkshelf/mercurial_spec.rb +173 -0
- metadata +32 -110
- data/lib/berkshelf/chef/config.rb +0 -68
- data/lib/berkshelf/mixin/config.rb +0 -172
- data/spec/fixtures/cookbooks/example_metadata_name/metadata.rb +0 -2
- data/spec/fixtures/cookbooks/example_metadata_no_name/metadata.rb +0 -1
- data/spec/fixtures/cookbooks/example_no_metadata/recipes/default.rb +0 -1
- data/spec/fixtures/cookbooks/nginx-0.100.5/README.md +0 -77
- data/spec/fixtures/cookbooks/nginx-0.100.5/attributes/default.rb +0 -65
- data/spec/fixtures/cookbooks/nginx-0.100.5/definitions/nginx_site.rb +0 -35
- data/spec/fixtures/cookbooks/nginx-0.100.5/files/default/mime.types +0 -73
- data/spec/fixtures/cookbooks/nginx-0.100.5/files/ubuntu/mime.types +0 -73
- data/spec/fixtures/cookbooks/nginx-0.100.5/libraries/nginxlib.rb +0 -1
- data/spec/fixtures/cookbooks/nginx-0.100.5/metadata.rb +0 -91
- data/spec/fixtures/cookbooks/nginx-0.100.5/providers/defprovider.rb +0 -1
- data/spec/fixtures/cookbooks/nginx-0.100.5/recipes/default.rb +0 -59
- data/spec/fixtures/cookbooks/nginx-0.100.5/resources/defresource.rb +0 -1
- data/spec/fixtures/cookbooks/nginx-0.100.5/templates/default/nginx.pill.erb +0 -15
- data/spec/fixtures/cookbooks/nginx-0.100.5/templates/default/plugins/nginx.rb.erb +0 -66
- data/spec/fixtures/lockfile_spec/with_lock/Berksfile +0 -1
- data/spec/fixtures/lockfile_spec/without_lock/.gitkeep +0 -0
- data/spec/fixtures/reset.pem +0 -27
- data/spec/unit/chef/config_spec.rb +0 -81
@@ -1,73 +0,0 @@
|
|
1
|
-
types {
|
2
|
-
text/html html htm shtml;
|
3
|
-
text/css css;
|
4
|
-
text/xml xml;
|
5
|
-
image/gif gif;
|
6
|
-
image/jpeg jpeg jpg;
|
7
|
-
application/x-javascript js;
|
8
|
-
application/json json;
|
9
|
-
application/atom+xml atom;
|
10
|
-
application/rss+xml rss;
|
11
|
-
|
12
|
-
text/mathml mml;
|
13
|
-
text/plain txt;
|
14
|
-
text/vnd.sun.j2me.app-descriptor jad;
|
15
|
-
text/vnd.wap.wml wml;
|
16
|
-
text/x-component htc;
|
17
|
-
|
18
|
-
image/png png;
|
19
|
-
image/tiff tif tiff;
|
20
|
-
image/vnd.wap.wbmp wbmp;
|
21
|
-
image/x-icon ico;
|
22
|
-
image/x-jng jng;
|
23
|
-
image/x-ms-bmp bmp;
|
24
|
-
image/svg+xml svg;
|
25
|
-
|
26
|
-
application/java-archive jar war ear;
|
27
|
-
application/mac-binhex40 hqx;
|
28
|
-
application/msword doc;
|
29
|
-
application/pdf pdf;
|
30
|
-
application/postscript ps eps ai;
|
31
|
-
application/rtf rtf;
|
32
|
-
application/vnd.ms-excel xls;
|
33
|
-
application/vnd.ms-powerpoint ppt;
|
34
|
-
application/vnd.wap.wmlc wmlc;
|
35
|
-
application/vnd.wap.xhtml+xml xhtml;
|
36
|
-
application/vnd.google-earth.kml+xml kml;
|
37
|
-
application/vnd.google-earth.kmz kmz;
|
38
|
-
application/x-cocoa cco;
|
39
|
-
application/x-java-archive-diff jardiff;
|
40
|
-
application/x-java-jnlp-file jnlp;
|
41
|
-
application/x-makeself run;
|
42
|
-
application/x-perl pl pm;
|
43
|
-
application/x-pilot prc pdb;
|
44
|
-
application/x-rar-compressed rar;
|
45
|
-
application/x-redhat-package-manager rpm;
|
46
|
-
application/x-sea sea;
|
47
|
-
application/x-shockwave-flash swf;
|
48
|
-
application/x-stuffit sit;
|
49
|
-
application/x-tcl tcl tk;
|
50
|
-
application/x-x509-ca-cert der pem crt;
|
51
|
-
application/x-xpinstall xpi;
|
52
|
-
application/zip zip;
|
53
|
-
|
54
|
-
application/octet-stream bin exe dll;
|
55
|
-
application/octet-stream deb;
|
56
|
-
application/octet-stream dmg;
|
57
|
-
application/octet-stream eot;
|
58
|
-
application/octet-stream iso img;
|
59
|
-
application/octet-stream msi msp msm;
|
60
|
-
|
61
|
-
audio/midi mid midi kar;
|
62
|
-
audio/mpeg mp3;
|
63
|
-
audio/x-realaudio ra;
|
64
|
-
|
65
|
-
video/3gpp 3gpp 3gp;
|
66
|
-
video/mpeg mpeg mpg;
|
67
|
-
video/quicktime mov;
|
68
|
-
video/x-flv flv;
|
69
|
-
video/x-mng mng;
|
70
|
-
video/x-ms-asf asx asf;
|
71
|
-
video/x-ms-wmv wmv;
|
72
|
-
video/x-msvideo avi;
|
73
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
puts "nginx lib"
|
@@ -1,91 +0,0 @@
|
|
1
|
-
maintainer "Opscode, Inc."
|
2
|
-
maintainer_email "cookbooks@opscode.com"
|
3
|
-
license "Apache 2.0"
|
4
|
-
description "Installs and configures nginx"
|
5
|
-
version "0.100.5"
|
6
|
-
|
7
|
-
recipe "nginx", "Installs nginx package and sets up configuration with Debian apache style with sites-enabled/sites-available"
|
8
|
-
recipe "nginx::source", "Installs nginx from source and sets up configuration with Debian apache style with sites-enabled/sites-available"
|
9
|
-
|
10
|
-
%w{ ubuntu debian centos redhat fedora }.each do |os|
|
11
|
-
supports os
|
12
|
-
end
|
13
|
-
|
14
|
-
%w{ build-essential runit bluepill }.each do |cb|
|
15
|
-
depends cb
|
16
|
-
end
|
17
|
-
|
18
|
-
depends 'ohai', '~> 1.0.2'
|
19
|
-
|
20
|
-
attribute "nginx/dir",
|
21
|
-
:display_name => "Nginx Directory",
|
22
|
-
:description => "Location of nginx configuration files",
|
23
|
-
:default => "/etc/nginx"
|
24
|
-
|
25
|
-
attribute "nginx/log_dir",
|
26
|
-
:display_name => "Nginx Log Directory",
|
27
|
-
:description => "Location for nginx logs",
|
28
|
-
:default => "/var/log/nginx"
|
29
|
-
|
30
|
-
attribute "nginx/user",
|
31
|
-
:display_name => "Nginx User",
|
32
|
-
:description => "User nginx will run as",
|
33
|
-
:default => "www-data"
|
34
|
-
|
35
|
-
attribute "nginx/binary",
|
36
|
-
:display_name => "Nginx Binary",
|
37
|
-
:description => "Location of the nginx server binary",
|
38
|
-
:default => "/usr/sbin/nginx"
|
39
|
-
|
40
|
-
attribute "nginx/gzip",
|
41
|
-
:display_name => "Nginx Gzip",
|
42
|
-
:description => "Whether gzip is enabled",
|
43
|
-
:default => "on"
|
44
|
-
|
45
|
-
attribute "nginx/gzip_http_version",
|
46
|
-
:display_name => "Nginx Gzip HTTP Version",
|
47
|
-
:description => "Version of HTTP Gzip",
|
48
|
-
:default => "1.0"
|
49
|
-
|
50
|
-
attribute "nginx/gzip_comp_level",
|
51
|
-
:display_name => "Nginx Gzip Compression Level",
|
52
|
-
:description => "Amount of compression to use",
|
53
|
-
:default => "2"
|
54
|
-
|
55
|
-
attribute "nginx/gzip_proxied",
|
56
|
-
:display_name => "Nginx Gzip Proxied",
|
57
|
-
:description => "Whether gzip is proxied",
|
58
|
-
:default => "any"
|
59
|
-
|
60
|
-
attribute "nginx/gzip_types",
|
61
|
-
:display_name => "Nginx Gzip Types",
|
62
|
-
:description => "Supported MIME-types for gzip",
|
63
|
-
:type => "array",
|
64
|
-
:default => [ "text/plain", "text/html", "text/css", "application/x-javascript", "text/xml", "application/xml", "application/xml+rss", "text/javascript" ]
|
65
|
-
|
66
|
-
attribute "nginx/keepalive",
|
67
|
-
:display_name => "Nginx Keepalive",
|
68
|
-
:description => "Whether to enable keepalive",
|
69
|
-
:default => "on"
|
70
|
-
|
71
|
-
attribute "nginx/keepalive_timeout",
|
72
|
-
:display_name => "Nginx Keepalive Timeout",
|
73
|
-
:default => "65"
|
74
|
-
|
75
|
-
attribute "nginx/worker_processes",
|
76
|
-
:display_name => "Nginx Worker Processes",
|
77
|
-
:description => "Number of worker processes",
|
78
|
-
:default => "1"
|
79
|
-
|
80
|
-
attribute "nginx/worker_connections",
|
81
|
-
:display_name => "Nginx Worker Connections",
|
82
|
-
:description => "Number of connections per worker",
|
83
|
-
:default => "1024"
|
84
|
-
|
85
|
-
attribute "nginx/server_names_hash_bucket_size",
|
86
|
-
:display_name => "Nginx Server Names Hash Bucket Size",
|
87
|
-
:default => "64"
|
88
|
-
|
89
|
-
attribute "nginx/disable_access_log",
|
90
|
-
:display_name => "Disable Access Log",
|
91
|
-
:default => "false"
|
@@ -1 +0,0 @@
|
|
1
|
-
puts "default provider"
|
@@ -1,59 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Cookbook Name:: nginx
|
3
|
-
# Recipe:: default
|
4
|
-
# Author:: AJ Christensen <aj@junglist.gen.nz>
|
5
|
-
#
|
6
|
-
# Copyright 2008-2009, Opscode, Inc.
|
7
|
-
#
|
8
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
-
# See the License for the specific language governing permissions and
|
18
|
-
# limitations under the License.
|
19
|
-
#
|
20
|
-
|
21
|
-
include_recipe "nginx::ohai_plugin"
|
22
|
-
|
23
|
-
package "nginx"
|
24
|
-
|
25
|
-
directory node[:nginx][:log_dir] do
|
26
|
-
mode 0755
|
27
|
-
owner node[:nginx][:user]
|
28
|
-
action :create
|
29
|
-
end
|
30
|
-
|
31
|
-
%w{nxensite nxdissite}.each do |nxscript|
|
32
|
-
template "/usr/sbin/#{nxscript}" do
|
33
|
-
source "#{nxscript}.erb"
|
34
|
-
mode 0755
|
35
|
-
owner "root"
|
36
|
-
group "root"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
template "nginx.conf" do
|
41
|
-
path "#{node[:nginx][:dir]}/nginx.conf"
|
42
|
-
source "nginx.conf.erb"
|
43
|
-
owner "root"
|
44
|
-
group "root"
|
45
|
-
mode 0644
|
46
|
-
notifies :reload, "service[nginx]"
|
47
|
-
end
|
48
|
-
|
49
|
-
template "#{node[:nginx][:dir]}/sites-available/default" do
|
50
|
-
source "default-site.erb"
|
51
|
-
owner "root"
|
52
|
-
group "root"
|
53
|
-
mode 0644
|
54
|
-
end
|
55
|
-
|
56
|
-
service "nginx" do
|
57
|
-
supports :status => true, :restart => true, :reload => true
|
58
|
-
action [ :enable, :start ]
|
59
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
puts "default resource"
|
@@ -1,15 +0,0 @@
|
|
1
|
-
Bluepill.application("nginx", :log_file => "<%= @log_dir %>/bluepill-nginx.log") do |app|
|
2
|
-
app.process("nginx") do |process|
|
3
|
-
process.pid_file = "<%= @pid %>"
|
4
|
-
process.working_dir = "<%= @working_dir %>"
|
5
|
-
process.start_command = "<%= @src_binary %> -c <%= @nginx_dir %>/nginx.conf"
|
6
|
-
process.stop_command = "kill -QUIT {{PID}}"
|
7
|
-
process.restart_command = "kill -HUP {{PID}}"
|
8
|
-
process.daemonize = true
|
9
|
-
process.stdout = process.stderr = "<%= @log_dir %>/nginx.log"
|
10
|
-
|
11
|
-
process.monitor_children do |child_process|
|
12
|
-
child_process.stop_command = "kill -QUIT {{PID}}"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
|
3
|
-
#
|
4
|
-
# Copyright 2012, Riot Games
|
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
|
-
provides "nginx"
|
20
|
-
provides "nginx/version"
|
21
|
-
provides "nginx/configure_arguments"
|
22
|
-
provides "nginx/prefix"
|
23
|
-
provides "nginx/conf_path"
|
24
|
-
|
25
|
-
def parse_flags(flags)
|
26
|
-
prefix = nil
|
27
|
-
conf_path = nil
|
28
|
-
|
29
|
-
flags.each do |flag|
|
30
|
-
case flag
|
31
|
-
when /^--prefix=(.+)$/
|
32
|
-
prefix = $1
|
33
|
-
when /^--conf-path=(.+)$/
|
34
|
-
conf_path = $1
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
[ prefix, conf_path ]
|
39
|
-
end
|
40
|
-
|
41
|
-
nginx Mash.new unless nginx
|
42
|
-
nginx[:version] = nil unless nginx[:version]
|
43
|
-
nginx[:configure_arguments] = Array.new unless nginx[:configure_arguments]
|
44
|
-
nginx[:prefix] = nil unless nginx[:prefix]
|
45
|
-
nginx[:conf_path] = nil unless nginx[:conf_path]
|
46
|
-
|
47
|
-
status, stdout, stderr = run_command(:no_status_check => true, :command => "<%= @nginx_bin %> -V")
|
48
|
-
|
49
|
-
if status == 0
|
50
|
-
stderr.split("\n").each do |line|
|
51
|
-
case line
|
52
|
-
when /^configure arguments:(.+)/
|
53
|
-
# This could be better: I'm splitting on configure arguments which removes them and also
|
54
|
-
# adds a blank string at index 0 of the array. This is why we drop index 0 and map to
|
55
|
-
# add the '--' prefix back to the configure argument.
|
56
|
-
nginx[:configure_arguments] = $1.split(/\s--/).drop(1).map { |ca| "--#{ca}" }
|
57
|
-
|
58
|
-
prefix, conf_path = parse_flags(nginx[:configure_arguments])
|
59
|
-
|
60
|
-
nginx[:prefix] = prefix
|
61
|
-
nginx[:conf_path] = conf_path
|
62
|
-
when /^nginx version: nginx\/(.+)/
|
63
|
-
nginx[:version] = $1
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
cookbook 'nginx', '= 0.101.0'
|
File without changes
|
data/spec/fixtures/reset.pem
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
-----BEGIN RSA PRIVATE KEY-----
|
2
|
-
MIIEpQIBAAKCAQEAyyUMqrTh1IzKOyE0fvXEWC7m0AdMI8/dr9JJMUKtK9vhhP0w
|
3
|
-
rm6m95GoybFM2IRryukFsAxpcir3M1ungTU3Smq4MshhMJ7H9FbvZVfQoknTbCsR
|
4
|
-
w6scg2fBepxT2+fcGRufr8nAh92M3uUkN9bMMTAkt18D4br6035YvdmvHDJERxYq
|
5
|
-
ByA/720AdI9VNSIvw+x8oqsIkXLEdF6dgT9MpG5iWZT66pbFsnNZpRrd4/bFNWBY
|
6
|
-
+13aOqdmjiTL08/EdgQFKMT5qimpos1TuQhA7mwInOjQgzVu9uCDkMiYejaLbUz0
|
7
|
-
lGyS8y4uxu6z2hA900Jg/z+JJuXymH5QAX3GZQIDAQABAoIBAQCtFXkwbYPI1Nht
|
8
|
-
/wG6du5+8B9K+hy+mppY9wPTy+q+Zs9Ev3Fd/fuXDm1QxBckl9c8AMUO1dR2KPOM
|
9
|
-
t7gFl/DvH/SnmCFvCqp1nijFIUgrLlnMXPn6zG0z7RBlxpKQ2IGohufNIEpBuNwR
|
10
|
-
Ag2U4hgChPGTp4ooJ2cVEh7MS5AupYPDbC62dWEdW68aRTWhh2BCGAWBb6s16yl9
|
11
|
-
aZ7+OcxW2eeRJVbRfLkLQEDutJZi5TfOEn5QPc86ZgxcCmnvwulnpnhpz6QCkgQt
|
12
|
-
OP/+KRqDhWSDVCFREVT30fUIj1EWvK7NFWASZQxueZStuIvMEKeFebYfrbHxRFzJ
|
13
|
-
UmaxJnWVAoGBAPbKLpeky6ClccBaHHrCgjzakoDfGgyNKDQ9g753lJxB8nn7d9X4
|
14
|
-
HQpkWpfqAGFRZp1hI2H+VxyUXLh2Ob5OUeTm0OZJll35vycOaQEtfgIScXTcvzn0
|
15
|
-
16J9eX2YY4wIHEEMh85nKk8BEGgiNP5nuEviHocCeYXoi/Zq3+qj6v63AoGBANK5
|
16
|
-
4nyi6LBQFs1CUc7Sh7vjtOE3ia7KeRmOr7gS6QhS3iK3Oa8FzBLJ6ETjN2a9Bw8N
|
17
|
-
cF7I/+cr4s7DUJjxdb53D/J6TVSYORNNCUVnpF/uB2LqqdXDYmpO0PvFkXFoYTnJ
|
18
|
-
kaLAN8uCoLKr6JH9tq3DfXIfDIHiZ+BOIvI070fDAoGBAMDyzEDFmGruTyRLj66u
|
19
|
-
+rJnVVmqlKwxhLhrS+CTj74nlVOnt0a0KMhiM65IRqnPwcHUG5zXBPaUTHXwAS93
|
20
|
-
/nFPwQ37hLPOupPnoVNJZRZrowbyPBQtCJbDMURv64ylHqoBCQDoCd0hANnZvMMX
|
21
|
-
BrFVhfaaibaXXS542r6SD/27AoGAECadHE5kJTdOOBcwK/jo3Fa8g1J9Y/8yvum3
|
22
|
-
wBT69V9clS6T5j08geglvDnqAh7UzquKBEnFi1NKw+wmXkKLcrivaTdEfApavYb3
|
23
|
-
AfHKoGue907jC3Y5Mcquq81ds2J7qTEwz1eKLzfo1yjj32ShvrmwALIuhDn1GjUC
|
24
|
-
6qtx938CgYEApEqvu0nocR1jmVVlLe5uKQBj949dh6NGq0R5Lztz6xufaTYzMC3d
|
25
|
-
AZG9XPPjRqSLs+ylSXJpwHEwoeyLFDaJcO+GgW1/ut4MC2HppOx6aImwDdXMHUWR
|
26
|
-
KYGIFF4AU/IYoBcanAm4s078EH/Oz01B2c7tR2TqabisPgLYe7PXSCw=
|
27
|
-
-----END RSA PRIVATE KEY-----
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Berkshelf::Chef::Config do
|
4
|
-
describe '.location' do
|
5
|
-
let(:path) { '/fake/path/for/.chef' }
|
6
|
-
let(:config) { File.join(path, 'knife.rb') }
|
7
|
-
let(:location) { Berkshelf::Chef::Config.send(:location) }
|
8
|
-
|
9
|
-
before do
|
10
|
-
ENV.stub(:[]).and_return(nil)
|
11
|
-
|
12
|
-
File.stub(:exists?).with(any_args()).and_return(false)
|
13
|
-
File.stub(:exists?).with(config).and_return(true)
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'uses $BERKSHELF_CHEF_CONFIG' do
|
17
|
-
ENV.stub(:[]).with('BERKSHELF_CHEF_CONFIG').and_return(config)
|
18
|
-
expect(location).to eq(config)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'uses $KNIFE_HOME' do
|
22
|
-
ENV.stub(:[]).with('KNIFE_HOME').and_return(path)
|
23
|
-
expect(location).to eq(config)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'uses ::working_dir' do
|
27
|
-
Berkshelf::Chef::Config.stub(:working_dir).and_return(path)
|
28
|
-
expect(location).to eq(config)
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'an ascending search' do
|
32
|
-
context 'with multiple .chef directories' do
|
33
|
-
let(:path) { '/fake/.chef/path/with/multiple/.chef/directories' }
|
34
|
-
|
35
|
-
before do
|
36
|
-
Berkshelf::Chef::Config.stub(:working_dir).and_return(path)
|
37
|
-
File.stub(:exists?).and_return(false)
|
38
|
-
File.stub(:exists?).with('/fake/.chef/knife.rb').and_return(true)
|
39
|
-
File.stub(:exists?).with('/fake/.chef/path/with/multiple/.chef/knife.rb').and_return(true)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'chooses the closest path' do
|
43
|
-
expect(location).to eq('/fake/.chef/path/with/multiple/.chef/knife.rb')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'with the current directory as .chef' do
|
48
|
-
let(:path) { '/fake/.chef' }
|
49
|
-
|
50
|
-
before do
|
51
|
-
Berkshelf::Chef::Config.stub(:working_dir).and_return(path)
|
52
|
-
File.stub(:exists?).and_return(false)
|
53
|
-
File.stub(:exists?).with('/fake/.chef/knife.rb').and_return(true)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'uses the current directory' do
|
57
|
-
expect(location).to eq('/fake/.chef/knife.rb')
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'with .chef at the top-level' do
|
62
|
-
let(:path) { '/.chef/some/random/sub/directories' }
|
63
|
-
|
64
|
-
before do
|
65
|
-
Berkshelf::Chef::Config.stub(:working_dir).and_return(path)
|
66
|
-
File.stub(:exists?).and_return(false)
|
67
|
-
File.stub(:exists?).with('/.chef/knife.rb').and_return(true)
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'uses the top-level directory' do
|
71
|
-
expect(location).to eq('/.chef/knife.rb')
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'uses $HOME' do
|
77
|
-
ENV.stub(:[]).with('HOME').and_return(File.join(path, '..'))
|
78
|
-
expect(location).to eq(config)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|