cookbook-omnifetch 0.8.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +5 -5
  2. data/lib/cookbook-omnifetch.rb +13 -13
  3. data/lib/cookbook-omnifetch/artifactory.rb +12 -7
  4. data/lib/cookbook-omnifetch/artifactserver.rb +3 -3
  5. data/lib/cookbook-omnifetch/base.rb +1 -1
  6. data/lib/cookbook-omnifetch/chef_server.rb +2 -2
  7. data/lib/cookbook-omnifetch/chef_server_artifact.rb +2 -2
  8. data/lib/cookbook-omnifetch/git.rb +4 -4
  9. data/lib/cookbook-omnifetch/integration.rb +1 -1
  10. data/lib/cookbook-omnifetch/metadata_based_installer.rb +14 -13
  11. data/lib/cookbook-omnifetch/path.rb +1 -1
  12. data/lib/cookbook-omnifetch/threaded_job_queue.rb +1 -1
  13. data/lib/cookbook-omnifetch/version.rb +1 -1
  14. metadata +15 -85
  15. data/.gitignore +0 -23
  16. data/.rspec +0 -1
  17. data/.travis.yml +0 -11
  18. data/Gemfile +0 -8
  19. data/README.md +0 -90
  20. data/Rakefile +0 -19
  21. data/cookbook-omnifetch.gemspec +0 -39
  22. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/README.md +0 -12
  23. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb +0 -3
  24. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/recipes/default.rb +0 -8
  25. data/spec/fixtures/cookbooks/example_cookbook/.gitignore +0 -2
  26. data/spec/fixtures/cookbooks/example_cookbook/.kitchen.yml +0 -26
  27. data/spec/fixtures/cookbooks/example_cookbook/Berksfile +0 -1
  28. data/spec/fixtures/cookbooks/example_cookbook/Berksfile.lock +0 -3
  29. data/spec/fixtures/cookbooks/example_cookbook/README.md +0 -12
  30. data/spec/fixtures/cookbooks/example_cookbook/metadata.rb +0 -3
  31. data/spec/fixtures/cookbooks/example_cookbook/recipes/default.rb +0 -8
  32. data/spec/spec_helper.rb +0 -43
  33. data/spec/unit/artifactory_spec.rb +0 -64
  34. data/spec/unit/artifactserver_spec.rb +0 -116
  35. data/spec/unit/base_spec.rb +0 -87
  36. data/spec/unit/chef_server_artifact_spec.rb +0 -110
  37. data/spec/unit/chef_server_spec.rb +0 -108
  38. data/spec/unit/exceptions_spec.rb +0 -87
  39. data/spec/unit/git_spec.rb +0 -290
  40. data/spec/unit/metadata_based_installer_spec.rb +0 -137
  41. data/spec/unit/path_spec.rb +0 -119
data/Rakefile DELETED
@@ -1,19 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
7
-
8
- desc "Run tests for Travis CI"
9
- task ci: [:style, :spec]
10
-
11
- begin
12
- require "chefstyle"
13
- require "rubocop/rake_task"
14
- RuboCop::RakeTask.new(:style) do |task|
15
- task.options += ["--display-cop-names", "--no-color"]
16
- end
17
- rescue LoadError
18
- puts "chefstyle/rubocop is not available. gem install chefstyle to do style checking."
19
- end
@@ -1,39 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "cookbook-omnifetch/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "cookbook-omnifetch"
8
- spec.version = CookbookOmnifetch::VERSION
9
- spec.authors = [
10
- "Jamie Winsor",
11
- "Josiah Kiehl",
12
- "Michael Ivey",
13
- "Justin Campbell",
14
- "Seth Vargo",
15
- "Daniel DeLeo",
16
- ]
17
- spec.email = [
18
- "jamie@vialstudios.com",
19
- "jkiehl@riotgames.com",
20
- "michael.ivey@riotgames.com",
21
- "justin@justincampbell.me",
22
- "sethvargo@gmail.com",
23
- "dan@getchef.com",
24
- ]
25
- spec.summary = %q{Library code to fetch Chef cookbooks from a variety of sources to a local cache}
26
- spec.homepage = "http://www.getchef.com/"
27
- spec.license = "Apache 2.0"
28
-
29
- spec.files = `git ls-files -z`.split("\x0")
30
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
31
- spec.test_files = spec.files.grep(%r{^spec/})
32
- spec.require_paths = ["lib"]
33
-
34
- spec.add_dependency "mixlib-archive", "~> 0.4"
35
-
36
- spec.add_development_dependency "rake"
37
- spec.add_development_dependency "rspec", "~> 3.0"
38
-
39
- end
@@ -1,12 +0,0 @@
1
- Description
2
- ===========
3
-
4
- Requirements
5
- ============
6
-
7
- Attributes
8
- ==========
9
-
10
- Usage
11
- =====
12
-
@@ -1,3 +0,0 @@
1
- name "example_cookbook"
2
- maintainer "Berkshelf Core"
3
- version "0.5.0"
@@ -1,8 +0,0 @@
1
- #
2
- # Cookbook Name:: example_cookbook
3
- # Recipe:: default
4
- #
5
- # Copyright 2012, YOUR_COMPANY_NAME
6
- #
7
- # All rights reserved - Do Not Redistribute
8
- #
@@ -1,2 +0,0 @@
1
- .kitchen/
2
- .kitchen.local.yml
@@ -1,26 +0,0 @@
1
- ---
2
- driver_plugin: vagrant
3
-
4
- platforms:
5
- - name: ubuntu-12.04
6
- driver_config:
7
- box: canonical-ubuntu-12.04
8
- box_url: http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box
9
- require_chef_omnibus: true
10
- - name: ubuntu-10.04
11
- driver_config:
12
- box: opscode-ubuntu-10.04
13
- box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_chef-11.2.0.box
14
- - name: centos-6.3
15
- driver_config:
16
- box: opscode-centos-6.3
17
- box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.3_chef-11.2.0.box
18
- - name: centos-5.8
19
- driver_config:
20
- box: opscode-centos-5.8
21
- box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-5.8_chef-11.2.0.box
22
-
23
- suites:
24
- - name: default
25
- run_list: []
26
- attributes: {}
@@ -1 +0,0 @@
1
- site :opscode
@@ -1,3 +0,0 @@
1
- DEPENDENCIES
2
-
3
- GRAPH
@@ -1,12 +0,0 @@
1
- Description
2
- ===========
3
-
4
- Requirements
5
- ============
6
-
7
- Attributes
8
- ==========
9
-
10
- Usage
11
- =====
12
-
@@ -1,3 +0,0 @@
1
- name "example_cookbook"
2
- maintainer "Berkshelf Core"
3
- version "0.5.0"
@@ -1,8 +0,0 @@
1
- #
2
- # Cookbook Name:: example_cookbook
3
- # Recipe:: default
4
- #
5
- # Copyright 2012, YOUR_COMPANY_NAME
6
- #
7
- # All rights reserved - Do Not Redistribute
8
- #
@@ -1,43 +0,0 @@
1
- require "cookbook-omnifetch"
2
-
3
- module Fixtures
4
-
5
- def fixtures_path
6
- spec_root.join("fixtures")
7
- end
8
-
9
- def spec_root
10
- Pathname.new(File.expand_path(File.dirname(__FILE__)))
11
- end
12
-
13
- end
14
-
15
- module MockShellOut; end
16
- module MockCachedCookbook; end
17
-
18
- RSpec.configure do |config|
19
-
20
- config.raise_errors_for_deprecations!
21
-
22
- config.include Fixtures
23
-
24
- config.expect_with :rspec do |c|
25
- c.syntax = [:expect]
26
- end
27
- config.mock_with :rspec do |c|
28
- c.syntax = [:expect, :should]
29
- end
30
-
31
- config.filter_run :focus => true
32
-
33
- config.run_all_when_everything_filtered = true
34
-
35
- config.before(:suite) do
36
- CookbookOmnifetch.configure do |c|
37
- c.cache_path = File.expand_path("~/.berkshelf")
38
- c.storage_path = Pathname.new(File.expand_path("~/.berkshelf/cookbooks"))
39
- c.shell_out_class = MockShellOut
40
- c.cached_cookbook_class = MockCachedCookbook
41
- end
42
- end
43
- end
@@ -1,64 +0,0 @@
1
- require "spec_helper"
2
- require "cookbook-omnifetch/artifactory"
3
- require "zlib"
4
- require "archive/tar/minitar"
5
-
6
- module CookbookOmnifetch
7
- describe ArtifactoryLocation do
8
-
9
- let(:cookbook_name) { "nginx" }
10
-
11
- let(:cookbook_version) { "1.5.23" }
12
-
13
- let(:http_client) { double("Chef::HTTP::Simple") }
14
-
15
- let(:constraint) { double("Constraint") }
16
-
17
- let(:dependency) { double("Dependency", name: cookbook_name, constraint: constraint) }
18
-
19
- let(:url) { "https://artifactory.example.com/api/v1/cookbooks/nginx/versions/1.5.23/download" }
20
-
21
- let(:options) { { artifactory: url, version: cookbook_version, http_client: http_client } }
22
-
23
- subject(:public_repo_location) { described_class.new(dependency, options) }
24
-
25
- it "has a URI" do
26
- expect(public_repo_location.uri).to eq(url)
27
- end
28
-
29
- it "has a repo host" do
30
- expect(public_repo_location.repo_host).to eq("artifactory.example.com")
31
- end
32
-
33
- it "has an exact version" do
34
- expect(public_repo_location.cookbook_version).to eq("1.5.23")
35
- end
36
-
37
- it "has a cache key containing the site URI and version" do
38
- expect(public_repo_location.cache_key).to eq("nginx-1.5.23-artifactory.example.com")
39
- end
40
-
41
- it "sets the install location as the cache path plus cache key" do
42
- expected_install_path = Pathname.new("~/.berkshelf/cookbooks").expand_path.join("nginx-1.5.23-artifactory.example.com")
43
- expect(public_repo_location.install_path).to eq(expected_install_path)
44
- end
45
-
46
- it "considers the cookbook installed if it exists in the main cache" do
47
- expect(public_repo_location.install_path).to receive(:exist?).and_return(true)
48
- expect(public_repo_location.installed?).to be true
49
- end
50
-
51
- it "considers the cookbook not installed if it doesn't exist in the main cache" do
52
- expect(public_repo_location.install_path).to receive(:exist?).and_return(false)
53
- expect(public_repo_location.installed?).to be false
54
- end
55
-
56
- it "provides lock data as a Hash" do
57
- expected_data = {
58
- "artifactory" => url,
59
- "version" => "1.5.23",
60
- }
61
- expect(public_repo_location.lock_data).to eq(expected_data)
62
- end
63
- end
64
- end
@@ -1,116 +0,0 @@
1
- require "spec_helper"
2
- require "cookbook-omnifetch/artifactserver"
3
- require "zlib"
4
- require "archive/tar/minitar"
5
-
6
- module CookbookOmnifetch
7
- describe ArtifactserverLocation do
8
-
9
- let(:cookbook_name) { "nginx" }
10
-
11
- let(:cookbook_version) { "1.5.23" }
12
-
13
- let(:constraint) { double("Constraint") }
14
-
15
- let(:dependency) { double("Dependency", name: cookbook_name, constraint: constraint) }
16
-
17
- let(:url) { "https://supermarket.getchef.com/api/v1/cookbooks/nginx/versions/1.5.23/download" }
18
-
19
- let(:options) { { artifactserver: url, version: cookbook_version } }
20
-
21
- subject(:public_repo_location) { described_class.new(dependency, options) }
22
-
23
- it "has a URI" do
24
- expect(public_repo_location.uri).to eq(url)
25
- end
26
-
27
- it "has a repo host" do
28
- expect(public_repo_location.repo_host).to eq("supermarket.getchef.com")
29
- end
30
-
31
- it "has an exact version" do
32
- expect(public_repo_location.cookbook_version).to eq("1.5.23")
33
- end
34
-
35
- it "has a cache key containing the site URI and version" do
36
- expect(public_repo_location.cache_key).to eq("nginx-1.5.23-supermarket.getchef.com")
37
- end
38
-
39
- it "sets the install location as the cache path plus cache key" do
40
- expected_install_path = Pathname.new("~/.berkshelf/cookbooks").expand_path.join("nginx-1.5.23-supermarket.getchef.com")
41
- expect(public_repo_location.install_path).to eq(expected_install_path)
42
- end
43
-
44
- it "considers the cookbook installed if it exists in the main cache" do
45
- expect(public_repo_location.install_path).to receive(:exist?).and_return(true)
46
- expect(public_repo_location.installed?).to be true
47
- end
48
-
49
- it "considers the cookbook not installed if it doesn't exist in the main cache" do
50
- expect(public_repo_location.install_path).to receive(:exist?).and_return(false)
51
- expect(public_repo_location.installed?).to be false
52
- end
53
-
54
- it "provides lock data as a Hash" do
55
- expected_data = {
56
- "artifactserver" => url,
57
- "version" => "1.5.23",
58
- }
59
- expect(public_repo_location.lock_data).to eq(expected_data)
60
- end
61
-
62
- context "when asked to install a new cookbook" do
63
-
64
- let(:http_client) { double("Http Client") }
65
-
66
- let(:test_root) { Dir.mktmpdir(nil) }
67
-
68
- let(:storage_path) { File.join(test_root, "storage") }
69
-
70
- let(:cache_path) { File.join(test_root, "cache") }
71
-
72
- let(:cookbook_fixtures_path) { fixtures_path.join("cookbooks") }
73
-
74
- let(:cookbook_name) { "example_cookbook" }
75
-
76
- let(:cookbook_version) { "0.5.0" }
77
-
78
- let(:cookbook_tarball_handle) do
79
- gz_file_name = File.join(test_root, "input.gz")
80
- Zlib::GzipWriter.open(gz_file_name) do |gz|
81
- # Minitar writes the full paths provided and doesn't seem to have a way to
82
- # remove prefixes. So we chdir like barbarians.
83
- Dir.chdir(cookbook_fixtures_path) do
84
- Archive::Tar::Minitar.pack(cookbook_name, gz)
85
- end
86
- end
87
- File.open(gz_file_name)
88
- end
89
-
90
- let(:cookbook_files) { %w{. .. .gitignore .kitchen.yml Berksfile Berksfile.lock metadata.rb README.md recipes} }
91
-
92
- before do
93
- allow(CookbookOmnifetch).to receive(:storage_path).and_return(Pathname.new(storage_path))
94
- allow(CookbookOmnifetch).to receive(:cache_path).and_return(cache_path)
95
- FileUtils.mkdir_p(storage_path)
96
- end
97
-
98
- after do
99
- FileUtils.rm_r(test_root)
100
- end
101
-
102
- it "installs the cookbook to the desired install path" do
103
- expect(public_repo_location).to receive(:http_client).and_return(http_client)
104
- expect(cookbook_tarball_handle).to receive(:close).and_call_original
105
- expect(http_client).to receive(:streaming_request).with(nil).and_yield(cookbook_tarball_handle)
106
- expect(public_repo_location).to receive(:validate_cached!)
107
-
108
- public_repo_location.install
109
-
110
- expect(File).to exist(public_repo_location.cache_path)
111
- expect(Dir).to exist(public_repo_location.install_path)
112
- expect(Dir.entries(public_repo_location.install_path)).to match_array(cookbook_files)
113
- end
114
- end
115
- end
116
- end
@@ -1,87 +0,0 @@
1
- require "spec_helper"
2
- require "cookbook-omnifetch/base"
3
-
4
- module CookbookOmnifetch
5
- describe BaseLocation do
6
- let(:constraint) { double("constraint") }
7
- let(:dependency) { double("dependency", name: "cookbook", version_constraint: constraint) }
8
-
9
- subject { described_class.new(dependency) }
10
-
11
- describe "#installed?" do
12
- it "is an abstract function" do
13
- expect { subject.installed? }.to raise_error(AbstractFunction)
14
- end
15
- end
16
-
17
- describe "#install" do
18
- it "is an abstract function" do
19
- expect { subject.install }.to raise_error(AbstractFunction)
20
- end
21
- end
22
-
23
- describe "#cached_cookbook" do
24
- it "is an abstract function" do
25
- expect { subject.cached_cookbook }.to raise_error(AbstractFunction)
26
- end
27
- end
28
-
29
- describe "#to_lock" do
30
- it "is an abstract function" do
31
- expect { subject.to_lock }.to raise_error(AbstractFunction)
32
- end
33
- end
34
-
35
- describe "#lock_data" do
36
- it "is an abstract function" do
37
- expect { subject.lock_data }.to raise_error(AbstractFunction)
38
- end
39
- end
40
-
41
- describe "#validate_cached!" do
42
- context "when the path is not a cookbook" do
43
- before { CookbookOmnifetch.stub(:cookbook?).and_return(false) }
44
-
45
- it "raises an error" do
46
- expect do
47
- subject.validate_cached!("/foo/bar")
48
- end.to raise_error(NotACookbook)
49
- end
50
- end
51
-
52
- context "when the path is a cookbook" do
53
- let(:cookbook) do
54
- double("cookbook",
55
- cookbook_name: "cookbook",
56
- version: "0.1.0"
57
- )
58
- end
59
-
60
- before do
61
- CookbookOmnifetch.stub(:cookbook?).and_return(true)
62
- MockCachedCookbook.stub(:from_path).and_return(cookbook)
63
- end
64
-
65
- it "raises an error if the constraint does not satisfy" do
66
- constraint.stub(:satisfies?).with("0.1.0").and_return(false)
67
- expect do
68
- subject.validate_cached!(cookbook)
69
- end.to raise_error(CookbookValidationFailure)
70
- end
71
-
72
- it "raises an error if the names do not match" do
73
- constraint.stub(:satisfies?).with("0.1.0").and_return(true)
74
- cookbook.stub(:cookbook_name).and_return("different_name")
75
- expect do
76
- subject.validate_cached!(cookbook)
77
- end.to raise_error(MismatchedCookbookName)
78
- end
79
-
80
- it "returns true when the validation succeeds" do
81
- constraint.stub(:satisfies?).with("0.1.0").and_return(true)
82
- expect(subject.validate_cached!(cookbook)).to be true
83
- end
84
- end
85
- end
86
- end
87
- end