berkshelf 1.2.0.rc1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/CHANGELOG.md +8 -0
  2. data/Gemfile +1 -1
  3. data/README.md +2 -0
  4. data/berkshelf.gemspec +4 -3
  5. data/features/step_definitions/filesystem_steps.rb +0 -1
  6. data/generator_files/Gemfile.erb +0 -3
  7. data/generator_files/Vagrantfile.erb +13 -1
  8. data/lib/berkshelf.rb +0 -1
  9. data/lib/berkshelf/berksfile.rb +11 -4
  10. data/lib/berkshelf/cached_cookbook.rb +2 -257
  11. data/lib/berkshelf/chef.rb +0 -1
  12. data/lib/berkshelf/chef/config.rb +3 -0
  13. data/lib/berkshelf/chef/cookbook.rb +0 -2
  14. data/lib/berkshelf/community_rest.rb +31 -6
  15. data/lib/berkshelf/cookbook_source.rb +5 -1
  16. data/lib/berkshelf/errors.rb +24 -0
  17. data/lib/berkshelf/git.rb +49 -1
  18. data/lib/berkshelf/init_generator.rb +1 -1
  19. data/lib/berkshelf/locations/chef_api_location.rb +6 -3
  20. data/lib/berkshelf/locations/path_location.rb +2 -0
  21. data/lib/berkshelf/version.rb +1 -1
  22. data/spec/spec_helper.rb +9 -2
  23. data/spec/support/chef_api.rb +1 -10
  24. data/spec/unit/berkshelf/cached_cookbook_spec.rb +37 -458
  25. data/spec/unit/berkshelf/git_spec.rb +119 -9
  26. data/spec/unit/berkshelf/init_generator_spec.rb +0 -1
  27. metadata +30 -24
  28. data/lib/berkshelf/chef/cookbook/metadata.rb +0 -556
  29. data/lib/berkshelf/chef/cookbook/syntax_check.rb +0 -158
  30. data/lib/berkshelf/chef/digester.rb +0 -67
  31. data/lib/berkshelf/mixin/checksum.rb +0 -16
  32. data/lib/berkshelf/mixin/params_validate.rb +0 -218
  33. data/lib/berkshelf/mixin/shell_out.rb +0 -23
  34. data/lib/berkshelf/uploader.rb +0 -80
  35. data/spec/unit/berkshelf/uploader_spec.rb +0 -27
  36. data/spec/unit/chef/cookbook/metadata_spec.rb +0 -5
  37. data/spec/unit/chef/digester_spec.rb +0 -41
@@ -1,23 +0,0 @@
1
- require 'mixlib/shellout'
2
-
3
- module Berkshelf::Mixin
4
- # @author Jamie Winsor <reset@riotgames.com>
5
- module ShellOut
6
- # @return [Mixlib::ShellOut]
7
- def shell_out(*command_args)
8
- cmd = Mixlib::ShellOut.new(*command_args)
9
- if STDOUT.tty?
10
- cmd.live_stream = STDOUT
11
- end
12
- cmd.run_command
13
- cmd
14
- end
15
-
16
- # @return [Mixlib::ShellOut]
17
- def shell_out!(*command_args)
18
- cmd = shell_out(*command_args)
19
- cmd.error!
20
- cmd
21
- end
22
- end
23
- end
@@ -1,80 +0,0 @@
1
- module Berkshelf
2
- # @author Jamie Winsor <reset@riotgames.com>
3
- class Uploader
4
- class << self
5
- def finalize
6
- conn.terminate if conn.alive?
7
- end
8
- end
9
-
10
- extend Forwardable
11
-
12
- def_delegator :conn, :client_name
13
- def_delegator :conn, :client_key
14
- def_delegator :conn, :organization
15
-
16
- # @option options [String] :server_url
17
- # URL to the Chef API
18
- # @option options [String] :client_name
19
- # name of the client used to authenticate with the Chef API
20
- # @option options [String] :client_key
21
- # filepath to the client's private key used to authenticate with
22
- # the Chef API
23
- # @option options [String] :organization
24
- # the Organization to connect to. This is only used if you are connecting to
25
- # private Chef or hosted Chef
26
- # @option options [Hash] :params
27
- # URI query unencoded key/value pairs
28
- # @option options [Hash] :headers
29
- # unencoded HTTP header key/value pairs
30
- # @option options [Hash] :request
31
- # request options
32
- # @option options [Hash] :ssl
33
- # SSL options
34
- # @option options [URI, String, Hash] :proxy
35
- # URI, String, or Hash of HTTP proxy options
36
- def initialize(options = {})
37
- @conn = Ridley.new(options)
38
-
39
- ObjectSpace.define_finalizer(self, self.class.method(:finalize).to_proc)
40
- end
41
-
42
- # Uploads a CachedCookbook from a CookbookStore to this instances Chef Server URL
43
- #
44
- # @param [CachedCookbook] cookbook
45
- # a cached cookbook to upload
46
- #
47
- # @option options [Boolean] :force
48
- # Upload the Cookbook even if the version already exists and is frozen on
49
- # the target Chef Server
50
- # @option options [Boolean] :freeze
51
- # Freeze the uploaded Cookbook on the Chef Server so that it cannot be
52
- # overwritten
53
- # @option options [Boolean] :skip_syntax_check
54
- # Skip syntax checking of the Cookbook to reduce the overall upload time
55
- #
56
- # @raise [CookbookNotFound]
57
- # @raise [CookbookSyntaxError]
58
- #
59
- # @return [Boolean]
60
- def upload(cookbook, options = {})
61
- cookbook.validate! unless options[:skip_syntax_check]
62
- checksums = cookbook.checksums.dup
63
- sandbox = conn.sandbox.create(checksums.keys)
64
-
65
- sandbox.upload(checksums)
66
- sandbox.commit
67
-
68
- conn.cookbook.save(
69
- cookbook.cookbook_name,
70
- cookbook.version,
71
- cookbook.to_json,
72
- options
73
- )
74
- end
75
-
76
- private
77
-
78
- attr_reader :conn
79
- end
80
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Berkshelf::Uploader, :chef_server do
4
- let(:chef_config) { Berkshelf::Chef::Config }
5
-
6
- subject do
7
- Berkshelf::Uploader.new(
8
- server_url: chef_config[:chef_server_url],
9
- client_key: chef_config[:client_key],
10
- client_name: chef_config[:node_name]
11
- )
12
- end
13
-
14
- describe "#upload" do
15
- let(:cookbook) { double('nginx', name: "nginx-0.101.2", cookbook_name: "nginx", version: "0.101.2") }
16
-
17
- context "when cookbook is invalid" do
18
- before(:each) { cookbook.should_receive(:validate!).and_raise(Berkshelf::CookbookSyntaxError) }
19
-
20
- it "raises a CookbookSyntaxError error" do
21
- lambda {
22
- subject.upload(cookbook)
23
- }.should raise_error(Berkshelf::CookbookSyntaxError)
24
- end
25
- end
26
- end
27
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Berkshelf::Chef::Cookbook::Metadata do
4
- describe ""
5
- end
@@ -1,41 +0,0 @@
1
- # Borrowed and modified from: {https://github.com/opscode/chef/blob/11.4.0/spec/unit/digester_spec.rb}
2
- #
3
- # Author:: Adam Jacob (<adam@opscode.com>)
4
- # Author:: Daniel DeLeo (<dan@kallistec.com>)
5
- # Copyright:: Copyright (c) 2009 Opscode, Inc.
6
- # Copyright:: Copyright (c) 2009 Daniel DeLeo
7
- # License:: Apache License, Version 2.0
8
- #
9
- # Licensed under the Apache License, Version 2.0 (the "License");
10
- # you may not use this file except in compliance with the License.
11
- # You may obtain a copy of the License at
12
- #
13
- # http://www.apache.org/licenses/LICENSE-2.0
14
- #
15
- # Unless required by applicable law or agreed to in writing, software
16
- # distributed under the License is distributed on an "AS IS" BASIS,
17
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- # See the License for the specific language governing permissions and
19
- # limitations under the License.
20
- #
21
-
22
- require 'spec_helper'
23
-
24
- describe Berkshelf::Chef::Digester do
25
- before(:each) do
26
- @cache = described_class.instance
27
- end
28
-
29
- describe "when computing checksums of cookbook files and templates" do
30
- it "proxies the class method checksum_for_file to the instance" do
31
- @cache.should_receive(:checksum_for_file).with("a_file_or_a_fail")
32
- described_class.checksum_for_file("a_file_or_a_fail")
33
- end
34
-
35
- it "generates a checksum from a non-file IO object" do
36
- io = StringIO.new("riseofthemachines\nriseofthechefs\n")
37
- expected_md5 = '0e157ac1e2dd73191b76067fb6b4bceb'
38
- @cache.generate_md5_checksum(io).should == expected_md5
39
- end
40
- end
41
- end