cookbook-omnifetch 0.7.0 → 0.10.0

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 +17 -13
  3. data/lib/cookbook-omnifetch/artifactory.rb +10 -5
  4. data/lib/cookbook-omnifetch/artifactserver.rb +1 -1
  5. data/lib/cookbook-omnifetch/base.rb +1 -1
  6. data/lib/cookbook-omnifetch/chef_server.rb +14 -3
  7. data/lib/cookbook-omnifetch/chef_server_artifact.rb +15 -4
  8. data/lib/cookbook-omnifetch/git.rb +3 -3
  9. data/lib/cookbook-omnifetch/integration.rb +6 -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 -74
  37. data/spec/unit/chef_server_spec.rb +0 -72
  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/.gitignore DELETED
@@ -1,23 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- *.bundle
19
- *.so
20
- *.o
21
- *.a
22
- mkmf.log
23
- .idea/*
data/.rspec DELETED
@@ -1 +0,0 @@
1
- -c -f documentation
@@ -1,11 +0,0 @@
1
- branches:
2
- only:
3
- master
4
-
5
- language: ruby
6
- rvm:
7
- - 2.2
8
- - 2.3.3
9
- - 2.4.1
10
- before_install: gem install bundler -v 1.14.6
11
- script: bundle exec rake ci
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- group :development, :test do
6
- gem "minitar"
7
- gem "chefstyle"
8
- end
data/README.md DELETED
@@ -1,90 +0,0 @@
1
- # CookbookOmnifetch
2
-
3
- `CookbookOmnifetch` provides library code for fetching Chef cookbooks
4
- from an artifact server (usually https://supermarket.chef.io),
5
- git/github, a local path, or a chef-server to a local cache for
6
- developement.
7
-
8
- ## Installation
9
-
10
- Add this line to your application's Gemfile:
11
-
12
- gem 'cookbook-omnifetch'
13
-
14
- And then execute:
15
-
16
- $ bundle
17
-
18
- Or install it yourself as:
19
-
20
- $ gem install cookbook-omnifetch
21
-
22
- ## Usage
23
-
24
- #### Inject Dependencies and Configure
25
-
26
- Cookbook Omnifetch is designed to work with utilities from both the
27
- Berkshelf and Chef Software ecosystems, so you have to configure it
28
- before you can use it. In ChefDK, we do this:
29
-
30
- ```ruby
31
- # Configure CookbookOmnifetch's dependency injection settings to use our classes and config.
32
- CookbookOmnifetch.configure do |c|
33
- c.cache_path = File.expand_path('~/.chefdk/cache')
34
- c.storage_path = Pathname.new(File.expand_path('~/.chefdk/cache/cookbooks'))
35
- c.shell_out_class = ChefDK::ShellOut
36
- c.cached_cookbook_class = ChefDK::CookbookMetadata
37
- end
38
- ```
39
-
40
- #### Fetching Cookbooks
41
-
42
- To download a cookbook:
43
-
44
- ```ruby
45
- fetcher = CookbookOmnifetch.init(dependency, source_options)
46
- fetcher.install
47
- ```
48
-
49
- To specify the cookbook you want, you give CookbookOmnifetch a
50
- dependency object that responds to `#name` and `#version_constraint`,
51
- e.g.:
52
-
53
- ```ruby
54
- require 'semverse'
55
-
56
- Dependency = Struct.new(:name, :version_constraint)
57
-
58
- my_dep = Dependency.new("apache2", Semverse::Constraint.new("~> 1.0"))
59
- ```
60
-
61
- The source options for the cookbook are given as a Hash; the keys and
62
- values vary based on the kind of storage location. As with Bundler's
63
- `gem` options, one key specifies the type of upstream service for the
64
- cookbook while other keys specify other options specific to that type.
65
- For example:
66
-
67
- ```ruby
68
- CookbookOmnifetch.init(dependency, artifact_server: "https://supermarket.chef.io/api/v1/cookbooks/apache2/versions/3.0.1/download")
69
- CookbookOmnifetch.init(dependency, git: "git@github.com:svanzoest/apache2-cookbook.git", tag: "v3.0.1")
70
- CookbookOmnifetch.init(dependency, github: "svanzoest/apache2-cookbook", tag: "v3.0.1")
71
- CookbookOmnifetch.init(dependency, path: "~/chef-cookbooks/apache2")
72
- ```
73
-
74
- ## Contributing
75
-
76
- For information on contributing to this project, see https://github.com/chef/chef/blob/master/CONTRIBUTING.md
77
-
78
- After that:
79
-
80
- 1. Fork it
81
- 2. Create your feature branch (`git checkout -b my-new-feature`)
82
- 3. Commit your changes (`git commit -asm 'Add some feature'`)
83
- 4. Push to the branch (`git push origin my-new-feature`)
84
- 5. Create a new Pull Request
85
-
86
- ## Thanks
87
-
88
- This code was initially extracted from Berkshelf. Thanks to the
89
- Berkshelf core teams and contributors.
90
-
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