cookbook-omnifetch 0.8.1 → 0.11.1
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.
- checksums.yaml +4 -4
- data/lib/cookbook-omnifetch.rb +11 -11
- data/lib/cookbook-omnifetch/artifactory.rb +12 -7
- data/lib/cookbook-omnifetch/artifactserver.rb +3 -3
- data/lib/cookbook-omnifetch/base.rb +1 -1
- data/lib/cookbook-omnifetch/chef_server.rb +4 -3
- data/lib/cookbook-omnifetch/chef_server_artifact.rb +4 -3
- data/lib/cookbook-omnifetch/git.rb +4 -4
- data/lib/cookbook-omnifetch/integration.rb +1 -1
- data/lib/cookbook-omnifetch/metadata_based_installer.rb +58 -48
- data/lib/cookbook-omnifetch/path.rb +1 -1
- data/lib/cookbook-omnifetch/threaded_job_queue.rb +1 -1
- data/lib/cookbook-omnifetch/version.rb +1 -1
- metadata +3 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6b7baff1c908f3ee02466f86ff7225a6a567006ed325313514d429eb07bddaa
|
4
|
+
data.tar.gz: a30c239d1ff4f032738cf9755226aff95e6f7df330c5119b367fa520306a9372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7f11e46181d038e79d55e527ebc743b977ed012ad0630dbfe8f687bdc36c9638a0a7e70eb24feacc1fc2ef960cdd68f4cdbff55eea8d5bdd98c5f29f2b25962
|
7
|
+
data.tar.gz: 5ad4d570c3fe10fa6f30c055d8bb0d73dd24fc1a90c15fe804007bda3b9738780d0e87128ecfae2cb569e5bdba949ad3d2f3e48999e58c27b99dd970f4cae297
|
data/lib/cookbook-omnifetch.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
require_relative "cookbook-omnifetch/version"
|
2
|
+
require_relative "cookbook-omnifetch/integration"
|
3
|
+
|
4
|
+
require_relative "cookbook-omnifetch/base"
|
5
|
+
require_relative "cookbook-omnifetch/git"
|
6
|
+
require_relative "cookbook-omnifetch/github"
|
7
|
+
require_relative "cookbook-omnifetch/path"
|
8
|
+
require_relative "cookbook-omnifetch/artifactserver"
|
9
|
+
require_relative "cookbook-omnifetch/artifactory"
|
10
|
+
require_relative "cookbook-omnifetch/chef_server"
|
11
|
+
require_relative "cookbook-omnifetch/chef_server_artifact"
|
12
12
|
|
13
13
|
module CookbookOmnifetch
|
14
14
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
require_relative "base"
|
2
2
|
|
3
|
-
require "mixlib/archive"
|
4
|
-
require "tmpdir"
|
3
|
+
require "mixlib/archive" unless defined?(Mixlib::Archive)
|
4
|
+
require "tmpdir" unless defined?(Dir.mktmpdir)
|
5
5
|
|
6
6
|
module CookbookOmnifetch
|
7
7
|
|
@@ -15,7 +15,12 @@ module CookbookOmnifetch
|
|
15
15
|
super
|
16
16
|
@uri ||= options[:artifactory]
|
17
17
|
@cookbook_version = options[:version]
|
18
|
-
|
18
|
+
if options[:http_client]
|
19
|
+
@http_client = options[:http_client]
|
20
|
+
else
|
21
|
+
headers = { "X-Jfrog-Art-API" => Chef::Config.artifactory_api_key || ENV["ARTIFACTORY_API_KEY"] }
|
22
|
+
@http_client = Chef::HTTP::Simple.new(uri, headers: headers)
|
23
|
+
end
|
19
24
|
end
|
20
25
|
|
21
26
|
def repo_host
|
@@ -93,13 +98,13 @@ module CookbookOmnifetch
|
|
93
98
|
"#to_lock must be implemented on #{self.class.name}!"
|
94
99
|
end
|
95
100
|
|
96
|
-
# The path where all pristine tarballs from an
|
101
|
+
# The path where all pristine tarballs from an artifactory are held.
|
97
102
|
# Tarballs are moved/swapped into this location once they have been staged
|
98
103
|
# in a co-located staging directory.
|
99
104
|
#
|
100
105
|
# @return [Pathname]
|
101
106
|
def cache_root
|
102
|
-
Pathname.new(CookbookOmnifetch.cache_path).join(".cache", "
|
107
|
+
Pathname.new(CookbookOmnifetch.cache_path).join(".cache", "artifactory")
|
103
108
|
end
|
104
109
|
|
105
110
|
# The path where tarballs are downloaded to and unzipped. On certain platforms
|
@@ -113,7 +118,7 @@ module CookbookOmnifetch
|
|
113
118
|
#
|
114
119
|
# @return [Pathname]
|
115
120
|
def staging_root
|
116
|
-
Pathname.new(CookbookOmnifetch.cache_path).join(".cache_tmp", "
|
121
|
+
Pathname.new(CookbookOmnifetch.cache_path).join(".cache_tmp", "artifactory")
|
117
122
|
end
|
118
123
|
|
119
124
|
# The path where the pristine tarball is cached
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative "base"
|
2
|
+
require_relative "metadata_based_installer"
|
3
3
|
|
4
4
|
module CookbookOmnifetch
|
5
5
|
class ChefServerLocation < BaseLocation
|
@@ -34,7 +34,8 @@ module CookbookOmnifetch
|
|
34
34
|
#
|
35
35
|
# @return [Boolean]
|
36
36
|
def installed?
|
37
|
-
|
37
|
+
# Always force a refresh of cache
|
38
|
+
false
|
38
39
|
end
|
39
40
|
|
40
41
|
def http_client
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative "base"
|
2
|
+
require_relative "metadata_based_installer"
|
3
3
|
|
4
4
|
module CookbookOmnifetch
|
5
5
|
# This location allows fetching from the `cookbook_artifacts/` API where Chef
|
@@ -45,7 +45,8 @@ module CookbookOmnifetch
|
|
45
45
|
#
|
46
46
|
# @return [Boolean]
|
47
47
|
def installed?
|
48
|
-
|
48
|
+
# Always force a refresh of cache
|
49
|
+
false
|
49
50
|
end
|
50
51
|
|
51
52
|
def http_client
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require "tmpdir"
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require "tmpdir" unless defined?(Dir.mktmpdir)
|
2
|
+
require_relative "../cookbook-omnifetch"
|
3
|
+
require_relative "base"
|
4
|
+
require_relative "exceptions"
|
5
5
|
|
6
6
|
module CookbookOmnifetch
|
7
7
|
class GitLocation < BaseLocation
|
@@ -1,21 +1,23 @@
|
|
1
|
-
|
1
|
+
require_relative "threaded_job_queue"
|
2
|
+
require "digest/md5"
|
2
3
|
|
3
4
|
module CookbookOmnifetch
|
4
5
|
|
5
6
|
class MetadataBasedInstaller
|
6
7
|
class CookbookMetadata
|
7
8
|
|
8
|
-
FILE_TYPES =
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
FILE_TYPES = %i{
|
10
|
+
resources
|
11
|
+
providers
|
12
|
+
recipes
|
13
|
+
definitions
|
14
|
+
libraries
|
15
|
+
attributes
|
16
|
+
files
|
17
|
+
templates
|
18
|
+
root_files
|
19
|
+
all_files
|
20
|
+
}.freeze
|
19
21
|
|
20
22
|
def initialize(metadata)
|
21
23
|
@metadata = metadata
|
@@ -26,7 +28,7 @@ module CookbookOmnifetch
|
|
26
28
|
next unless @metadata.key?(type.to_s)
|
27
29
|
|
28
30
|
@metadata[type.to_s].each do |file|
|
29
|
-
yield file["url"], file["path"]
|
31
|
+
yield file["url"], file["path"], file["checksum"]
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -45,50 +47,58 @@ module CookbookOmnifetch
|
|
45
47
|
end
|
46
48
|
|
47
49
|
def install
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
queue = ThreadedJobQueue.new
|
50
|
+
metadata = http_client.get(url_path)
|
51
|
+
clean_cache(metadata)
|
52
|
+
sync_cache(metadata)
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
# Removes files from cache that are not supposed to be there, based on
|
56
|
+
# files in metadata.
|
57
|
+
def clean_cache(metadata)
|
58
|
+
actual_file_list = Dir.glob(File.join(install_path, "**/*"))
|
59
|
+
expected_file_list = []
|
60
|
+
CookbookMetadata.new(metadata).files { |_, path, _| expected_file_list << File.join(install_path, path) }
|
61
|
+
|
62
|
+
extra_files = actual_file_list - expected_file_list
|
63
|
+
extra_files.each do |path|
|
64
|
+
if File.file?(path)
|
65
|
+
FileUtils.rm(path)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
57
69
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
70
|
+
# Downloads any out-of-date files into installer cache, overwriting
|
71
|
+
# those that don't match the checksum provided the metadata @ url_path
|
72
|
+
def sync_cache(metadata)
|
73
|
+
queue = ThreadedJobQueue.new
|
74
|
+
CookbookMetadata.new(metadata).files do |url, path, checksum|
|
75
|
+
dest_path = File.join(install_path, path)
|
76
|
+
FileUtils.mkdir_p(File.dirname(dest_path))
|
77
|
+
if file_outdated?(dest_path, checksum)
|
78
|
+
queue << lambda do |_lock|
|
79
|
+
http_client.streaming_request(url) do |tempfile|
|
80
|
+
tempfile.close
|
81
|
+
FileUtils.mv(tempfile.path, dest_path)
|
82
|
+
end
|
62
83
|
end
|
63
84
|
end
|
64
85
|
end
|
65
|
-
|
66
86
|
queue.process(CookbookOmnifetch.chef_server_download_concurrency)
|
67
|
-
|
68
|
-
FileUtils.mv(staging_path, install_path)
|
69
87
|
end
|
70
88
|
|
71
|
-
#
|
72
|
-
# better chance of getting an atomic move if your temporary working
|
73
|
-
# directory is on the same device/volume as the destination. To support
|
74
|
-
# this, we use a staging directory located under the cache path under the
|
75
|
-
# rather mild assumption that everything under the cache path is going to
|
76
|
-
# be on one device.
|
89
|
+
# Check if a given file (at absolute path) is missing or does has a mismatched md5sum
|
77
90
|
#
|
78
|
-
# @return [
|
79
|
-
def
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
# processes installing the same cookbook at the same time.
|
90
|
-
def staging_cache_key
|
91
|
-
"#{url_path.gsub(/[^[:alnum:]]/, "_")}_#{slug}"
|
91
|
+
# @return [TrueClass, FalseClass]
|
92
|
+
def file_outdated?(path, expected_md5sum)
|
93
|
+
return true unless File.exist?(path)
|
94
|
+
|
95
|
+
md5 = Digest::MD5.new
|
96
|
+
File.open(path, "r") do |file|
|
97
|
+
while (chunk = file.read(1024))
|
98
|
+
md5.update chunk
|
99
|
+
end
|
100
|
+
end
|
101
|
+
md5.to_s != expected_md5sum
|
92
102
|
end
|
93
103
|
end
|
94
104
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cookbook-omnifetch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Winsor
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2020-08-31 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: mixlib-archive
|
@@ -35,34 +35,6 @@ dependencies:
|
|
35
35
|
- - "<"
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '2.0'
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: rake
|
40
|
-
requirement: !ruby/object:Gem::Requirement
|
41
|
-
requirements:
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: '0'
|
45
|
-
type: :development
|
46
|
-
prerelease: false
|
47
|
-
version_requirements: !ruby/object:Gem::Requirement
|
48
|
-
requirements:
|
49
|
-
- - ">="
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: '0'
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: rspec
|
54
|
-
requirement: !ruby/object:Gem::Requirement
|
55
|
-
requirements:
|
56
|
-
- - "~>"
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
version: '3.0'
|
59
|
-
type: :development
|
60
|
-
prerelease: false
|
61
|
-
version_requirements: !ruby/object:Gem::Requirement
|
62
|
-
requirements:
|
63
|
-
- - "~>"
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: '3.0'
|
66
38
|
description:
|
67
39
|
email:
|
68
40
|
- jamie@vialstudios.com
|
@@ -102,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
74
|
requirements:
|
103
75
|
- - ">="
|
104
76
|
- !ruby/object:Gem::Version
|
105
|
-
version: '
|
77
|
+
version: '2.5'
|
106
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
79
|
requirements:
|
108
80
|
- - ">="
|