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
@@ -1,137 +0,0 @@
1
- require "spec_helper"
2
- require "cookbook-omnifetch/metadata_based_installer.rb"
3
-
4
- RSpec.shared_context "sample_metadata" do
5
-
6
- let(:raw_metadata) do
7
- {
8
- "recipes" => [
9
- { "name" => "default.rb", "path" => "recipes/default.rb", "checksum" => "a6be794cdd2eb44d38fdf17f792a0d0d", "specificity" => "default", "url" => "https://example.com/recipes/default.rb" },
10
- ],
11
- "root_files" => [
12
- { "name" => "metadata.rb", "path" => "metadata.rb", "checksum" => "5b346119e5e41ab99500608decac8dca", "specificity" => "default", "url" => "https://example.com/metadata.rb" },
13
- ],
14
- }
15
-
16
- end
17
- end
18
-
19
- RSpec.describe CookbookOmnifetch::MetadataBasedInstaller::CookbookMetadata do
20
-
21
- include_context "sample_metadata"
22
-
23
- subject(:cb_metadata) { described_class.new(raw_metadata) }
24
-
25
- it "yields a set of paths and urls" do
26
- expect { |b| cb_metadata.files(&b) }.to yield_successive_args(["https://example.com/recipes/default.rb", "recipes/default.rb"], ["https://example.com/metadata.rb", "metadata.rb"])
27
- end
28
- end
29
-
30
- RSpec.describe CookbookOmnifetch::MetadataBasedInstaller do
31
-
32
- include_context "sample_metadata"
33
-
34
- let(:url_path) { "/cookbooks/example/0.5.0" }
35
-
36
- let(:http_client) do
37
- double("Http Client")
38
- end
39
-
40
- let(:recipe_url) do
41
- raw_metadata["recipes"][0]["url"]
42
- end
43
-
44
- let(:recipe_path) do
45
- raw_metadata["recipes"][0]["path"]
46
- end
47
-
48
- let(:recipe_filehandle) do
49
- File.open(File.join(remote_path, recipe_path))
50
- end
51
-
52
- let(:root_file_url) do
53
- raw_metadata["root_files"][0]["url"]
54
- end
55
-
56
- let(:root_file_path) do
57
- raw_metadata["root_files"][0]["path"]
58
- end
59
-
60
- let(:root_file_filehandle) do
61
- File.open(File.join(remote_path, root_file_path))
62
- end
63
-
64
- let(:cookbook_fixture_path) { fixtures_path.join("cookbooks/example_cookbook") }
65
-
66
- let(:test_root) { Dir.mktmpdir(nil) }
67
-
68
- let(:cache_path) { File.join(test_root, "cache") }
69
-
70
- let(:remote_path) { File.join(test_root, "remote") }
71
-
72
- let(:install_path) { File.join(test_root, "install_path") }
73
-
74
- let(:cookbook_files) { %w{metadata.rb recipes recipes/default.rb} }
75
-
76
- let(:expected_installed_files) do
77
- cookbook_files.map do |file|
78
- File.join(install_path, file)
79
- end
80
- end
81
-
82
- subject(:installer) do
83
- described_class.new(http_client: http_client,
84
- url_path: url_path,
85
- install_path: install_path)
86
- end
87
-
88
- before do
89
- FileUtils.cp_r(cookbook_fixture_path, remote_path)
90
-
91
- allow(CookbookOmnifetch).to receive(:cache_path).and_return(cache_path)
92
- end
93
-
94
- after do
95
- FileUtils.rm_r(test_root)
96
- end
97
-
98
- it "stages the download to a randomized location" do
99
- Kernel.srand(0)
100
- expected_path = Pathname.new(cache_path).join(".cache_tmp/metadata-installer/_cookbooks_example_0_5_0_209652396")
101
-
102
- expect(installer.staging_path).to eq(expected_path)
103
-
104
- next_installer = described_class.new(http_client: http_client,
105
- url_path: url_path,
106
- install_path: install_path)
107
-
108
- next_expected_path = Pathname.new(cache_path).join(".cache_tmp/metadata-installer/_cookbooks_example_0_5_0_398764591")
109
- expect(next_installer.staging_path).to eq(next_expected_path)
110
- end
111
-
112
- describe "installing the cookbook" do
113
-
114
- before do
115
- expect(http_client).to receive(:get).
116
- with(url_path).
117
- and_return(raw_metadata)
118
- expect(http_client).to receive(:streaming_request).
119
- with(recipe_url).
120
- and_yield(recipe_filehandle)
121
- expect(http_client).to receive(:streaming_request).
122
- with(root_file_url).
123
- and_yield(root_file_filehandle)
124
- end
125
-
126
- it "installs the cookbook to the desired install path" do
127
- expect(Dir).to_not exist(install_path)
128
-
129
- installer.install
130
-
131
- expect(Dir).to exist(install_path)
132
- expect(Dir.glob("#{install_path}/**/*")).to match_array(expected_installed_files)
133
- end
134
-
135
- end
136
-
137
- end
@@ -1,119 +0,0 @@
1
- require "spec_helper"
2
- require "cookbook-omnifetch/path"
3
-
4
- module CookbookOmnifetch
5
- describe PathLocation do
6
- let(:relative_paths_root) { File.dirname(__FILE__) }
7
- let(:constraint) { double("constraint", satisfies?: true) }
8
- let(:dependency) do
9
- double("dependency",
10
- name: "nginx",
11
- version_constraint: constraint,
12
- relative_paths_root: relative_paths_root
13
- )
14
- end
15
- let(:path) { fixtures_path.join("cookbooks", "example_cookbook") }
16
- let(:relative_path) { Pathname.new("../fixtures/cookbooks/example_cookbook") }
17
-
18
- subject { described_class.new(dependency, path: path) }
19
-
20
- describe "#installed?" do
21
- it "returns false" do
22
- expect(subject.installed?).to be false
23
- end
24
- end
25
-
26
- describe "#install" do
27
- it "validates the cached cookbook" do
28
- expect(subject).to receive(:validate_cached!).with(path)
29
- subject.install
30
- end
31
- end
32
-
33
- describe "#cached_cookbook" do
34
- it "loads the cached cookbook at the path" do
35
- expect(MockCachedCookbook).to receive(:from_path).with(path)
36
- subject.cached_cookbook
37
- end
38
- end
39
-
40
- describe "#relative_path" do
41
- it "returns the path to the Berksfile" do
42
- expect(subject.relative_path).to eq(relative_path)
43
- end
44
- end
45
-
46
- describe "#expanded_path" do
47
- it "returns the expanded path, relative to the Berksfile" do
48
- absolute_path = Pathname.new(File.expand_path(relative_path, relative_paths_root))
49
- expect(subject.expanded_path).to eq(absolute_path)
50
- end
51
- end
52
-
53
- describe "#==" do
54
- it "is false when compared with a non-PathLocation" do
55
- this = PathLocation.new(dependency, path: ".")
56
- that = "A string"
57
- expect(this).to_not eq(that)
58
- end
59
-
60
- it "is false when the metadata? is not the same" do
61
- this = PathLocation.new(dependency, path: ".")
62
- that = PathLocation.new(dependency, path: ".", metadata: true)
63
- expect(this).to_not eq(that)
64
- end
65
-
66
- it "is false when the expanded paths are different" do
67
- this = PathLocation.new(dependency, path: ".")
68
- that = PathLocation.new(dependency, path: "..")
69
- expect(this).to_not eq(that)
70
- end
71
-
72
- it "is true when they are the same" do
73
- this = PathLocation.new(dependency, path: ".", metadata: true)
74
- that = PathLocation.new(dependency, path: ".", metadata: true)
75
- expect(this).to eq(that)
76
- end
77
- end
78
-
79
- describe "#to_lock" do
80
- it "includes the path relative to the Berksfile" do
81
- expect(subject.to_lock).to eq <<-EOH.gsub(/^ {10}/, "")
82
- path: #{relative_path}
83
- EOH
84
- end
85
-
86
- it "includes the metadata attribute" do
87
- subject.stub(:metadata?).and_return(true)
88
- expect(subject.to_lock).to eq <<-EOH.gsub(/^ {10}/, "")
89
- path: #{relative_path}
90
- metadata: true
91
- EOH
92
- end
93
- end
94
-
95
- describe "#lock_data" do
96
- it "includes the path relative to the Berksfile" do
97
- expect(subject.lock_data).to eq({ "path" => relative_path.to_s })
98
- end
99
-
100
- it "includes the metadata attribute" do
101
- subject.stub(:metadata?).and_return(true)
102
- expect(subject.lock_data).to eq({ "path" => relative_path.to_s, "metadata" => true })
103
- end
104
- end
105
-
106
- describe "#to_s" do
107
- it "uses the relative path" do
108
- expect(subject.to_s).to eq("source at #{relative_path}")
109
- end
110
- end
111
-
112
- describe "#inspect" do
113
- it "includes the right information" do
114
- subject.stub(:metadata?).and_return(true)
115
- expect(subject.inspect).to eq("#<CookbookOmnifetch::PathLocation metadata: true, path: #{relative_path}>")
116
- end
117
- end
118
- end
119
- end