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.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.ruby-version +1 -1
  3. data/CONTRIBUTING.md +2 -0
  4. data/LICENSE +1 -1
  5. data/README.md +1 -1
  6. data/Thorfile +2 -2
  7. data/berkshelf.gemspec +3 -3
  8. data/features/install_command.feature +36 -8
  9. data/features/json_formatter.feature +93 -3
  10. data/features/licenses.feature +1 -1
  11. data/features/lockfile.feature +0 -12
  12. data/features/outdated_command.feature +124 -0
  13. data/features/show_command.feature +44 -25
  14. data/features/step_definitions/chef/config_steps.rb +2 -2
  15. data/features/step_definitions/chef_server_steps.rb +9 -1
  16. data/features/step_definitions/config_steps.rb +1 -1
  17. data/features/step_definitions/filesystem_steps.rb +7 -0
  18. data/features/support/env.rb +2 -1
  19. data/features/update_command.feature +11 -21
  20. data/features/upload_command.feature +45 -1
  21. data/features/vendor_command.feature +83 -0
  22. data/lib/berkshelf.rb +5 -4
  23. data/lib/berkshelf/api_client/remote_cookbook.rb +13 -0
  24. data/lib/berkshelf/berksfile.rb +155 -23
  25. data/lib/berkshelf/chef.rb +0 -1
  26. data/lib/berkshelf/cli.rb +40 -31
  27. data/lib/berkshelf/dependency.rb +14 -4
  28. data/lib/berkshelf/errors.rb +74 -3
  29. data/lib/berkshelf/formatters.rb +12 -1
  30. data/lib/berkshelf/formatters/human_readable.rb +44 -5
  31. data/lib/berkshelf/formatters/json.rb +50 -8
  32. data/lib/berkshelf/installer.rb +8 -8
  33. data/lib/berkshelf/location.rb +17 -0
  34. data/lib/berkshelf/locations/git_location.rb +7 -17
  35. data/lib/berkshelf/locations/mercurial_location.rb +112 -0
  36. data/lib/berkshelf/lockfile.rb +1 -1
  37. data/lib/berkshelf/mercurial.rb +146 -0
  38. data/lib/berkshelf/version.rb +1 -1
  39. data/spec/config/knife.rb +2 -4
  40. data/spec/fixtures/lockfiles/default.lock +0 -1
  41. data/spec/support/chef_api.rb +9 -2
  42. data/spec/support/mercurial.rb +122 -0
  43. data/spec/support/path_helpers.rb +2 -2
  44. data/spec/unit/berkshelf/berksfile_spec.rb +34 -8
  45. data/spec/unit/berkshelf/dependency_spec.rb +0 -7
  46. data/spec/unit/berkshelf/formatters/null_spec.rb +1 -1
  47. data/spec/unit/berkshelf/locations/mercurial_location_spec.rb +150 -0
  48. data/spec/unit/berkshelf/lockfile_spec.rb +0 -12
  49. data/spec/unit/berkshelf/mercurial_spec.rb +173 -0
  50. metadata +32 -110
  51. data/lib/berkshelf/chef/config.rb +0 -68
  52. data/lib/berkshelf/mixin/config.rb +0 -172
  53. data/spec/fixtures/cookbooks/example_metadata_name/metadata.rb +0 -2
  54. data/spec/fixtures/cookbooks/example_metadata_no_name/metadata.rb +0 -1
  55. data/spec/fixtures/cookbooks/example_no_metadata/recipes/default.rb +0 -1
  56. data/spec/fixtures/cookbooks/nginx-0.100.5/README.md +0 -77
  57. data/spec/fixtures/cookbooks/nginx-0.100.5/attributes/default.rb +0 -65
  58. data/spec/fixtures/cookbooks/nginx-0.100.5/definitions/nginx_site.rb +0 -35
  59. data/spec/fixtures/cookbooks/nginx-0.100.5/files/default/mime.types +0 -73
  60. data/spec/fixtures/cookbooks/nginx-0.100.5/files/ubuntu/mime.types +0 -73
  61. data/spec/fixtures/cookbooks/nginx-0.100.5/libraries/nginxlib.rb +0 -1
  62. data/spec/fixtures/cookbooks/nginx-0.100.5/metadata.rb +0 -91
  63. data/spec/fixtures/cookbooks/nginx-0.100.5/providers/defprovider.rb +0 -1
  64. data/spec/fixtures/cookbooks/nginx-0.100.5/recipes/default.rb +0 -59
  65. data/spec/fixtures/cookbooks/nginx-0.100.5/resources/defresource.rb +0 -1
  66. data/spec/fixtures/cookbooks/nginx-0.100.5/templates/default/nginx.pill.erb +0 -15
  67. data/spec/fixtures/cookbooks/nginx-0.100.5/templates/default/plugins/nginx.rb.erb +0 -66
  68. data/spec/fixtures/lockfile_spec/with_lock/Berksfile +0 -1
  69. data/spec/fixtures/lockfile_spec/without_lock/.gitkeep +0 -0
  70. data/spec/fixtures/reset.pem +0 -27
  71. data/spec/unit/chef/config_spec.rb +0 -81
@@ -1,68 +0,0 @@
1
- require 'socket'
2
-
3
- module Berkshelf
4
- module Chef
5
- class Config
6
- require 'berkshelf/mixin/config'
7
- include Berkshelf::Mixin::Config
8
-
9
- class << self
10
- private
11
-
12
- # Return the most sensible path to the Chef configuration file. This can
13
- # be configured by setting a value for the 'BERKSHELF_CHEF_CONFIG' environment
14
- # variable.
15
- #
16
- # @return [String, nil]
17
- def location
18
- possibles = []
19
-
20
- possibles << ENV['BERKSHELF_CHEF_CONFIG'] if ENV['BERKSHELF_CHEF_CONFIG']
21
- possibles << File.join(ENV['KNIFE_HOME'], 'knife.rb') if ENV['KNIFE_HOME']
22
- possibles << File.join(working_dir, 'knife.rb') if working_dir
23
-
24
- # Ascending search for .chef directory siblings
25
- Pathname.new(working_dir).ascend do |file|
26
- sibling_chef = File.join(file, '.chef')
27
- possibles << File.join(sibling_chef, 'knife.rb')
28
- end if working_dir
29
-
30
- possibles << File.join(ENV['HOME'], '.chef', 'knife.rb') if ENV['HOME']
31
- possibles.compact!
32
-
33
- location = possibles.find { |loc| File.exists?(File.expand_path(loc)) }
34
-
35
- File.expand_path(location) unless location.nil?
36
- end
37
-
38
- # The current working directory
39
- #
40
- # @return [String]
41
- def working_dir
42
- ENV['PWD'] || Dir.pwd
43
- end
44
- end
45
-
46
- default_option(:node_name, Socket.gethostname)
47
- default_option(:chef_server_url, 'http://localhost:4000')
48
- default_option(:client_key, platform_specific_path('/etc/chef/client.pem'))
49
- default_option(:validation_key, platform_specific_path('/etc/chef/validation.pem'))
50
- default_option(:validation_client_name, 'chef-validator')
51
-
52
- default_option(:cookbook_copyright, 'YOUR_NAME')
53
- default_option(:cookbook_email, 'YOUR_EMAIL')
54
- default_option(:cookbook_license, 'reserved')
55
-
56
- default_option(:knife, {})
57
-
58
- # Prior to Chef 11, the cache implementation was based on
59
- # moneta and configured via cache_options[:path]. Knife configs
60
- # generated with Chef 11 will have `syntax_check_cache_path`, but older
61
- # configs will have `cache_options[:path]`. `cache_options` is marked
62
- # deprecated in chef/config.rb but doesn't currently trigger a warning.
63
- # See also: CHEF-3715
64
- default_option(:syntax_check_cache_path, Dir.mktmpdir)
65
- default_option(:cache_options, { path: defined?(syntax_check_cache_path) ? syntax_check_cache_path : Dir.mktmpdir })
66
- end
67
- end
68
- end
@@ -1,172 +0,0 @@
1
- module Berkshelf
2
- module Mixin
3
- module Config
4
- def self.included(base)
5
- base.send(:extend, ClassMethods)
6
- end
7
-
8
- module ClassMethods
9
- # @return [String, nil]
10
- attr_reader :default_location
11
-
12
- # Load a Chef configuration from the given path.
13
- #
14
- # @raise [Berkshelf::ConfigNotFound]
15
- # if the specified path does not exist on the system
16
- def from_file(filepath)
17
- self.new(filepath)
18
- rescue Errno::ENOENT => e
19
- raise Berkshelf::ConfigNotFound.new(self.class.name, filepath)
20
- end
21
-
22
- # @return [Berkshelf::Mixin::Config]
23
- def instance
24
- @instance ||= load
25
- end
26
-
27
- # Load the contents of the most probable Chef config. See {location}
28
- # for more information on how this logic is decided.
29
- def load
30
- new(location)
31
- end
32
-
33
- # Class method for defining a default option.
34
- #
35
- # @param [#to_sym] option
36
- # the symbol to store as the key
37
- # @param [Object] value
38
- # the return value
39
- def default_option(option, value)
40
- default_options[option.to_sym] = value
41
- end
42
-
43
- # A list of all the default options set by this class.
44
- #
45
- # @return [Hash]
46
- def default_options
47
- @default_options ||= {}
48
- end
49
-
50
- # The default location of the configuration file.
51
- #
52
- # @param [#to_s] path
53
- # the path to the default location of the configuration file
54
- def default_location(path)
55
- @default_location = File.expand_path(path)
56
- end
57
-
58
- # Converts a path to a path usable for your current platform
59
- #
60
- # @param [String] path
61
- #
62
- # @return [String]
63
- def platform_specific_path(path)
64
- if RUBY_PLATFORM =~ /mswin|mingw|windows/
65
- system_drive = ENV['SYSTEMDRIVE'] ? ENV['SYSTEMDRIVE'] : ""
66
- path = win_slashify File.join(system_drive, path.split('/')[2..-1])
67
- end
68
-
69
- path
70
- end
71
-
72
- # @return [Berkshelf::Mixin::Config]
73
- def reload
74
- @instance = nil
75
- instance
76
- end
77
-
78
- # @param [Berkshelf::Mixin::Config]
79
- def set_config(config)
80
- @instance = config
81
- end
82
-
83
- private
84
-
85
- # @abstract
86
- # include and override {location} in your class to define the
87
- # default location logic
88
- def location
89
- default_location || raise(AbstractFunction, "You must implement #{self.class}#location to define default location logic!")
90
- end
91
-
92
- # Convert a unixy filepath to a windowsy filepath. Swaps forward slashes for
93
- # double backslashes
94
- #
95
- # @param [String] path
96
- # filepath to convert
97
- #
98
- # @return [String]
99
- # converted filepath
100
- def win_slashify(path)
101
- path.gsub(File::SEPARATOR, (File::ALT_SEPARATOR || '\\'))
102
- end
103
- end
104
-
105
- # The path to the file.
106
- #
107
- # @return [String, nil]
108
- attr_reader :path
109
-
110
- # Create a new configuration file from the given path.
111
- #
112
- # @param [#to_s, nil] filepath
113
- # the filepath to read
114
- def initialize(filepath = nil)
115
- @path = filepath ? File.expand_path(filepath.to_s) : nil
116
- load
117
- end
118
-
119
- # Read and evaluate the contents of the filepath, if one was given at the
120
- # start.
121
- #
122
- # @return [Berkshelf::Mixin::Config]
123
- def load
124
- configuration # Need to call this to make sure it's populated
125
- self.instance_eval(IO.read(path), path, 1) if path && File.exists?(path)
126
- self
127
- end
128
-
129
- # Force a reload the contents of this file from disk.
130
- #
131
- # @return [Berkshelf::Mixin::Config]
132
- def reload!
133
- @configuration = nil
134
- load
135
- self
136
- end
137
-
138
- # Return the configuration value for the given key.
139
- #
140
- # @param [#to_sym] key
141
- # they key to find a configuration value for
142
- def [](key)
143
- configuration[key.to_sym]
144
- end
145
-
146
- def method_missing(m, *args, &block)
147
- if args.length > 0
148
- configuration[m.to_sym] = (args.length == 1) ? args[0] : args
149
- else
150
- configuration[m.to_sym]
151
- end
152
- end
153
-
154
- # Save the contents of the file to the originally-supplied path.
155
- def save
156
- File.open(path, 'w+') { |f| f.write(to_rb + "\n") }
157
- end
158
-
159
- # Convert the file back to Ruby.
160
- #
161
- # @return [String]
162
- def to_rb
163
- configuration.map { |k,v| "#{k}(#{v.inspect})" }.join("\n")
164
- end
165
-
166
- private
167
- def configuration
168
- @configuration ||= self.class.default_options.dup
169
- end
170
- end
171
- end
172
- end
@@ -1,2 +0,0 @@
1
- name "has_metadata"
2
- version "1.0.0"
@@ -1,77 +0,0 @@
1
- Description
2
- ===========
3
-
4
- Installs nginx from package OR source code and sets up configuration handling similar to Debian's Apache2 scripts.
5
-
6
- Requirements
7
- ============
8
-
9
- Cookbooks
10
- ---------
11
-
12
- * build-essential (for nginx::source)
13
- * runit (for nginx::source)
14
-
15
- Platform
16
- --------
17
-
18
- Debian or Ubuntu though may work where 'build-essential' works, but other platforms are untested.
19
-
20
- Attributes
21
- ==========
22
-
23
- All node attributes are set under the `nginx` namespace.
24
-
25
- * version - sets the version to install.
26
- * dir - configuration dir.
27
- * `log_dir` - where logs go.
28
- * user - user to run as.
29
- * binary - path to nginx binary.
30
- * gzip - all attributes under the `gzip` namespace configure the gzip module.
31
- * keepalive - whether to use keepalive.
32
- * `keepalive_timeout` - set the keepalive timeout.
33
- * `worker_processes` - number of workers to spawn.
34
- * `worker_connections` - number of connections per worker.
35
- * `server_names_hash_bucket_size`
36
- * `url` - URL where to download the nginx source tarball
37
-
38
- The following attributes are set at the 'normal' node level via the `nginx::source` recipe.
39
-
40
- * `install_path` - for nginx::source, sets the --prefix installation.
41
- * `src_binary` - for nginx::source, sets the binary location.
42
- * `configure_flags` - for nginx::source, an array of flags to use for compilation.
43
-
44
- Usage
45
- =====
46
-
47
- Provides two ways to install and configure nginx.
48
-
49
- * Install via native package (nginx::default)
50
- * Install via compiled source (nginx::source)
51
-
52
- Both recipes implement configuration handling similar to the Debian Apache2 site enable/disable.
53
-
54
- There's some redundancy in that the config handling hasn't been separated from the installation method (yet), so use only one of the recipes.
55
-
56
- Some of the attributes mentioned above are only set in the `nginx::source` recipe. They can be overridden by setting them via a role in `override_attributes`.
57
-
58
- License and Author
59
- ==================
60
-
61
- Author:: Joshua Timberman (<joshua@opscode.com>)
62
- Author:: Adam Jacob (<adam@opscode.com>)
63
- Author:: AJ Christensen (<aj@opscode.com>)
64
-
65
- Copyright:: 2008-2011, Opscode, Inc
66
-
67
- Licensed under the Apache License, Version 2.0 (the "License");
68
- you may not use this file except in compliance with the License.
69
- You may obtain a copy of the License at
70
-
71
- http://www.apache.org/licenses/LICENSE-2.0
72
-
73
- Unless required by applicable law or agreed to in writing, software
74
- distributed under the License is distributed on an "AS IS" BASIS,
75
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76
- See the License for the specific language governing permissions and
77
- limitations under the License.
@@ -1,65 +0,0 @@
1
- #
2
- # Cookbook Name:: nginx
3
- # Attributes:: default
4
- #
5
- # Author:: Adam Jacob (<adam@opscode.com>)
6
- # Author:: Joshua Timberman (<joshua@opscode.com>)
7
- #
8
- # Copyright 2009-2011, Opscode, Inc.
9
- #
10
- # Licensed under the Apache License, Version 2.0 (the "License");
11
- # you may not use this file except in compliance with the License.
12
- # You may obtain a copy of the License at
13
- #
14
- # http://www.apache.org/licenses/LICENSE-2.0
15
- #
16
- # Unless required by applicable law or agreed to in writing, software
17
- # distributed under the License is distributed on an "AS IS" BASIS,
18
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
- # See the License for the specific language governing permissions and
20
- # limitations under the License.
21
- #
22
-
23
- default[:nginx][:version] = "1.0.14"
24
-
25
- case platform
26
- when "debian","ubuntu"
27
- default[:nginx][:dir] = "/etc/nginx"
28
- default[:nginx][:log_dir] = "/var/log/nginx"
29
- default[:nginx][:user] = "www-data"
30
- default[:nginx][:binary] = "/usr/sbin/nginx"
31
- default[:nginx][:init_style] = "runit"
32
- else
33
- default[:nginx][:dir] = "/etc/nginx"
34
- default[:nginx][:log_dir] = "/var/log/nginx"
35
- default[:nginx][:user] = "www-data"
36
- default[:nginx][:binary] = "/usr/sbin/nginx"
37
- default[:nginx][:init_style] = "init"
38
- end
39
-
40
- default[:nginx][:pid] = "/var/run/nginx.pid"
41
-
42
- default[:nginx][:gzip] = "on"
43
- default[:nginx][:gzip_http_version] = "1.0"
44
- default[:nginx][:gzip_comp_level] = "2"
45
- default[:nginx][:gzip_proxied] = "any"
46
- default[:nginx][:gzip_types] = [
47
- "text/plain",
48
- "text/html",
49
- "text/css",
50
- "application/x-javascript",
51
- "text/xml",
52
- "application/xml",
53
- "application/xml+rss",
54
- "text/javascript",
55
- "application/javascript",
56
- "application/json"
57
- ]
58
-
59
- default[:nginx][:keepalive] = "on"
60
- default[:nginx][:keepalive_timeout] = 65
61
- default[:nginx][:worker_processes] = cpu[:total]
62
- default[:nginx][:worker_connections] = 1024
63
- default[:nginx][:server_names_hash_bucket_size] = 64
64
-
65
- default[:nginx][:disable_access_log] = false
@@ -1,35 +0,0 @@
1
- #
2
- # Cookbook Name:: nginx
3
- # Definition:: nginx_site
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
- define :nginx_site, :enable => true do
22
- if params[:enable]
23
- execute "nxensite #{params[:name]}" do
24
- command "/usr/sbin/nxensite #{params[:name]}"
25
- notifies :reload, resources(:service => "nginx")
26
- not_if do ::File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end
27
- end
28
- else
29
- execute "nxdissite #{params[:name]}" do
30
- command "/usr/sbin/nxdissite #{params[:name]}"
31
- notifies :reload, resources(:service => "nginx")
32
- only_if do ::File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end
33
- end
34
- end
35
- end
@@ -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
- }