librarian-puppet 5.1.0 → 6.0.0
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/bin/librarian-puppet +2 -1
- data/lib/librarian/puppet/action/install.rb +2 -2
- data/lib/librarian/puppet/action/resolve.rb +8 -5
- data/lib/librarian/puppet/action.rb +4 -2
- data/lib/librarian/puppet/cli.rb +45 -48
- data/lib/librarian/puppet/dependency.rb +3 -5
- data/lib/librarian/puppet/dsl.rb +22 -17
- data/lib/librarian/puppet/environment.rb +9 -8
- data/lib/librarian/puppet/extension.rb +2 -0
- data/lib/librarian/puppet/lockfile.rb +16 -16
- data/lib/librarian/puppet/resolver.rb +3 -2
- data/lib/librarian/puppet/source/forge/repo.rb +20 -19
- data/lib/librarian/puppet/source/forge/repo_v1.rb +20 -14
- data/lib/librarian/puppet/source/forge/repo_v3.rb +10 -10
- data/lib/librarian/puppet/source/forge.rb +20 -21
- data/lib/librarian/puppet/source/git.rb +16 -9
- data/lib/librarian/puppet/source/githubtarball/repo.rb +30 -32
- data/lib/librarian/puppet/source/githubtarball.rb +15 -18
- data/lib/librarian/puppet/source/local.rb +21 -15
- data/lib/librarian/puppet/source/path.rb +2 -0
- data/lib/librarian/puppet/source/repo.rb +2 -2
- data/lib/librarian/puppet/source.rb +2 -0
- data/lib/librarian/puppet/templates/Puppetfile +4 -2
- data/lib/librarian/puppet/util.rb +19 -15
- data/lib/librarian/puppet/version.rb +3 -1
- data/lib/librarian/puppet.rb +2 -0
- metadata +77 -57
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require 'open-uri'
|
3
5
|
require 'librarian/puppet/source/forge/repo'
|
@@ -7,9 +9,8 @@ module Librarian
|
|
7
9
|
module Source
|
8
10
|
class Forge
|
9
11
|
class RepoV1 < Librarian::Puppet::Source::Forge::Repo
|
10
|
-
|
11
12
|
def initialize(source, name)
|
12
|
-
super
|
13
|
+
super
|
13
14
|
# API returned data for this module including all versions and dependencies, indexed by module name
|
14
15
|
# from https://forge.puppetlabs.com/api/v1/releases.json?module=#{name}
|
15
16
|
@api_data = nil
|
@@ -31,14 +32,15 @@ module Librarian
|
|
31
32
|
"#{source}#{info[name].first['file']}"
|
32
33
|
end
|
33
34
|
|
34
|
-
|
35
|
+
private
|
35
36
|
|
36
37
|
# convert organization/modulename to organization-modulename
|
37
38
|
def normalize_dependencies(data)
|
38
39
|
return nil if data.nil?
|
40
|
+
|
39
41
|
# convert organization/modulename to organization-modulename
|
40
42
|
data.keys.each do |m|
|
41
|
-
if
|
43
|
+
if %r{.*/.*}.match?(m)
|
42
44
|
data[normalize_name(m)] = data[m]
|
43
45
|
data.delete(m)
|
44
46
|
end
|
@@ -49,39 +51,43 @@ module Librarian
|
|
49
51
|
# get and cache the API data for a specific module with all its versions and dependencies
|
50
52
|
def api_data(module_name)
|
51
53
|
return @api_data[module_name] if @api_data
|
54
|
+
|
52
55
|
# call API and cache data
|
53
56
|
@api_data = normalize_dependencies(api_call(module_name))
|
54
|
-
if @api_data.nil?
|
55
|
-
|
56
|
-
end
|
57
|
+
raise Error, "Unable to find module '#{name}' on #{source}" if @api_data.nil?
|
58
|
+
|
57
59
|
@api_data[module_name]
|
58
60
|
end
|
59
61
|
|
60
62
|
# get and cache the API data for a specific module and version
|
61
63
|
def api_version_data(module_name, version)
|
62
64
|
# if we already got all the versions, find in cached data
|
63
|
-
return @api_data[module_name].detect{|x| x['version'] == version.to_s} if @api_data
|
65
|
+
return @api_data[module_name].detect { |x| x['version'] == version.to_s } if @api_data
|
66
|
+
|
64
67
|
# otherwise call the api for this version if not cached already
|
65
|
-
|
68
|
+
if @api_version_data[version].nil?
|
69
|
+
@api_version_data[version] =
|
70
|
+
normalize_dependencies(api_call(name, version))
|
71
|
+
end
|
66
72
|
@api_version_data[version]
|
67
73
|
end
|
68
74
|
|
69
|
-
def api_call(module_name, version=nil)
|
75
|
+
def api_call(module_name, version = nil)
|
70
76
|
url = source.uri.clone
|
71
77
|
url.path += "#{'/' if url.path.empty? or url.path[-1] != '/'}api/v1/releases.json"
|
72
|
-
url.query = "module=#{module_name.sub('-','/')}" # v1 API expects "organization/module"
|
78
|
+
url.query = "module=#{module_name.sub('-', '/')}" # v1 API expects "organization/module"
|
73
79
|
url.query += "&version=#{version}" unless version.nil?
|
74
80
|
debug { "Querying Forge API for module #{name}#{" and version #{version}" unless version.nil?}: #{url}" }
|
75
81
|
|
76
82
|
begin
|
77
|
-
data = URI.open(url) {|f| f.read}
|
83
|
+
data = URI.open(url) { |f| f.read }
|
78
84
|
JSON.parse(data)
|
79
85
|
rescue OpenURI::HTTPError => e
|
80
86
|
case e.io.status[0].to_i
|
81
|
-
when 404,410
|
87
|
+
when 404, 410
|
82
88
|
nil
|
83
89
|
else
|
84
|
-
raise e, "Error requesting #{url}: #{e
|
90
|
+
raise e, "Error requesting #{url}: #{e}"
|
85
91
|
end
|
86
92
|
end
|
87
93
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'librarian/puppet/source/forge/repo'
|
2
4
|
require 'puppet_forge'
|
3
5
|
require 'librarian/puppet/version'
|
@@ -7,25 +9,24 @@ module Librarian
|
|
7
9
|
module Source
|
8
10
|
class Forge
|
9
11
|
class RepoV3 < Librarian::Puppet::Source::Forge::Repo
|
10
|
-
|
11
12
|
PuppetForge.user_agent = "librarian-puppet/#{Librarian::Puppet::VERSION}"
|
12
13
|
|
13
14
|
def initialize(source, name)
|
14
15
|
PuppetForge.host = source.uri.clone
|
15
|
-
super
|
16
|
+
super
|
16
17
|
end
|
17
18
|
|
18
19
|
def get_versions
|
19
|
-
get_module.releases.select{|r| r.deleted_at.nil?}.map{|r| r.version}
|
20
|
+
get_module.releases.select { |r| r.deleted_at.nil? }.map { |r| r.version }
|
20
21
|
end
|
21
22
|
|
22
23
|
def dependencies(version)
|
23
|
-
array = get_release(version).metadata[:dependencies].map{|d| [d[:name], d[:version_requirement]]}
|
24
|
+
array = get_release(version).metadata[:dependencies].map { |d| [d[:name], d[:version_requirement]] }
|
24
25
|
Hash[*array.flatten(1)]
|
25
26
|
end
|
26
27
|
|
27
28
|
def url(name, version)
|
28
|
-
if name == "#{get_module
|
29
|
+
if name == "#{get_module.owner.username}/#{get_module.name}"
|
29
30
|
release = get_release(version)
|
30
31
|
else
|
31
32
|
# should never get here as we use one repo object for each module (to be changed in the future)
|
@@ -35,28 +36,27 @@ module Librarian
|
|
35
36
|
"#{source}#{release.file_uri}"
|
36
37
|
end
|
37
38
|
|
38
|
-
|
39
|
+
private
|
39
40
|
|
40
41
|
def get_module
|
41
42
|
begin
|
42
43
|
@module ||= PuppetForge::V3::Module.find(name)
|
43
44
|
# https://github.com/puppetlabs/forge-ruby/pull/104/files starting with version 5, PuppetForge::ModuleNotFound is raised
|
44
45
|
# previous versions raise Faraday::ResourceNotFound
|
45
|
-
rescue Faraday::ResourceNotFound, PuppetForge::ModuleNotFound
|
46
|
+
rescue Faraday::ResourceNotFound, PuppetForge::ModuleNotFound
|
46
47
|
raise(Error, "Unable to find module '#{name}' on #{source}")
|
47
48
|
end
|
48
49
|
@module
|
49
50
|
end
|
50
51
|
|
51
52
|
def get_release(version)
|
52
|
-
release = get_module.releases.find{|r| r.version == version.to_s}
|
53
|
+
release = get_module.releases.find { |r| r.version == version.to_s }
|
53
54
|
if release.nil?
|
54
|
-
versions = get_module.releases.map{|r| r.version}
|
55
|
+
versions = get_module.releases.map { |r| r.version }
|
55
56
|
raise Error, "Unable to find version '#{version}' for module '#{name}' on #{source} amongst #{versions}"
|
56
57
|
end
|
57
58
|
release
|
58
59
|
end
|
59
|
-
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'uri'
|
2
4
|
require 'librarian/puppet/util'
|
3
5
|
require 'librarian/puppet/source/forge/repo_v1'
|
@@ -25,15 +27,13 @@ module Librarian
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def from_lock_options(environment, options)
|
28
|
-
new(environment, options[:remote], options.reject { |k,
|
30
|
+
new(environment, options[:remote], options.reject { |k, _v| k == :remote })
|
29
31
|
end
|
30
32
|
|
31
33
|
def from_spec_args(environment, uri, options)
|
32
34
|
recognised_options = []
|
33
35
|
unrecognised_options = options.keys - recognised_options
|
34
|
-
unless unrecognised_options.empty?
|
35
|
-
raise Error, "unrecognised options: #{unrecognised_options.join(", ")}"
|
36
|
-
end
|
36
|
+
raise Error, "unrecognised options: #{unrecognised_options.join(', ')}" unless unrecognised_options.empty?
|
37
37
|
|
38
38
|
new(environment, uri, options)
|
39
39
|
end
|
@@ -43,10 +43,10 @@ module Librarian
|
|
43
43
|
private :environment=
|
44
44
|
attr_reader :uri
|
45
45
|
|
46
|
-
def initialize(environment, uri,
|
46
|
+
def initialize(environment, uri, _options = {})
|
47
47
|
self.environment = environment
|
48
48
|
|
49
|
-
@uri = URI
|
49
|
+
@uri = URI.parse(uri)
|
50
50
|
@cache_path = nil
|
51
51
|
end
|
52
52
|
|
@@ -56,14 +56,14 @@ module Librarian
|
|
56
56
|
|
57
57
|
def ==(other)
|
58
58
|
other &&
|
59
|
-
|
60
|
-
|
59
|
+
self.class == other.class &&
|
60
|
+
uri == other.uri
|
61
61
|
end
|
62
62
|
|
63
|
-
alias
|
63
|
+
alias eql? ==
|
64
64
|
|
65
65
|
def hash
|
66
|
-
|
66
|
+
to_s.hash
|
67
67
|
end
|
68
68
|
|
69
69
|
def to_spec_args
|
@@ -71,15 +71,14 @@ module Librarian
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def to_lock_options
|
74
|
-
{:
|
74
|
+
{ remote: uri.to_s }
|
75
75
|
end
|
76
76
|
|
77
77
|
def pinned?
|
78
78
|
false
|
79
79
|
end
|
80
80
|
|
81
|
-
def unpin
|
82
|
-
end
|
81
|
+
def unpin!; end
|
83
82
|
|
84
83
|
def install!(manifest)
|
85
84
|
manifest.source == self or raise ArgumentError
|
@@ -121,7 +120,7 @@ module Librarian
|
|
121
120
|
end
|
122
121
|
end
|
123
122
|
|
124
|
-
def fetch_dependencies(name, version,
|
123
|
+
def fetch_dependencies(name, version, _version_uri)
|
125
124
|
repo(name).dependencies(version).map do |k, v|
|
126
125
|
v = Librarian::Dependency::Requirement.new(v).to_gem_requirement
|
127
126
|
Dependency.new(k, v, nil, name)
|
@@ -132,19 +131,19 @@ module Librarian
|
|
132
131
|
repo(name).manifests
|
133
132
|
end
|
134
133
|
|
135
|
-
|
134
|
+
private
|
136
135
|
|
137
136
|
def repo(name)
|
138
137
|
@repo ||= {}
|
139
138
|
|
140
139
|
unless @repo[name]
|
141
|
-
# If we are using the official Forge then use API v3, otherwise use the preferred api
|
140
|
+
# If we are using the official Forge then use API v3, otherwise use the preferred api
|
142
141
|
# as defined by the CLI option use_v1_api
|
143
|
-
if
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
142
|
+
@repo[name] = if environment.use_v1_api
|
143
|
+
RepoV1.new(self, name)
|
144
|
+
else
|
145
|
+
RepoV3.new(self, name)
|
146
|
+
end
|
148
147
|
end
|
149
148
|
@repo[name]
|
150
149
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'librarian/source/git'
|
2
4
|
require 'librarian/puppet/source/local'
|
3
5
|
|
@@ -7,12 +9,10 @@ module Librarian
|
|
7
9
|
class Repository
|
8
10
|
def hash_from(remote, reference)
|
9
11
|
branch_names = remote_branch_names[remote]
|
10
|
-
if branch_names.include?(reference)
|
11
|
-
reference = "#{remote}/#{reference}"
|
12
|
-
end
|
12
|
+
reference = "#{remote}/#{reference}" if branch_names.include?(reference)
|
13
13
|
|
14
|
-
command = %W
|
15
|
-
run!(command, :
|
14
|
+
command = %W[rev-parse #{reference}^{commit} --quiet]
|
15
|
+
run!(command, chdir: true).strip
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -37,6 +37,10 @@ module Librarian
|
|
37
37
|
raise Error, "Could not checkout #{uri}#{" at #{sha}" unless sha.nil?}: #{e}"
|
38
38
|
end
|
39
39
|
|
40
|
+
if strip_dot_git? and repository.git?
|
41
|
+
repository.path.join('.git').rmtree
|
42
|
+
end
|
43
|
+
|
40
44
|
cache_in_vendor(repository.path) if environment.vendor?
|
41
45
|
end
|
42
46
|
|
@@ -54,20 +58,23 @@ module Librarian
|
|
54
58
|
vendor_tgz.exist?
|
55
59
|
end
|
56
60
|
|
61
|
+
def strip_dot_git?
|
62
|
+
environment.config_db.local["install.strip-dot-git"] == '1'
|
63
|
+
end
|
64
|
+
|
57
65
|
def vendor_checkout!
|
58
66
|
repository.path.rmtree if repository.path.exist?
|
59
67
|
repository.path.mkpath
|
60
68
|
|
61
|
-
Librarian::Posix.run!(%W
|
69
|
+
Librarian::Posix.run!(%W[tar xzf #{vendor_tgz}], chdir: repository.path.to_s)
|
62
70
|
|
63
71
|
repository_cached!
|
64
72
|
end
|
65
73
|
|
66
74
|
def cache_in_vendor(tmp_path)
|
67
|
-
Librarian::Posix.run!(%W
|
68
|
-
Librarian::Posix.run!(%W
|
75
|
+
Librarian::Posix.run!(%W[git archive -o #{vendor_tar} #{sha}], chdir: tmp_path.to_s)
|
76
|
+
Librarian::Posix.run!(%W[gzip #{vendor_tar}], chdir: tmp_path.to_s)
|
69
77
|
end
|
70
|
-
|
71
78
|
end
|
72
79
|
end
|
73
80
|
end
|
@@ -17,10 +17,9 @@ module Librarian
|
|
17
17
|
|
18
18
|
def versions
|
19
19
|
return @versions if @versions
|
20
|
+
|
20
21
|
data = api_call("/repos/#{source.uri}/tags")
|
21
|
-
if data.nil?
|
22
|
-
raise Error, "Unable to find module '#{source.uri}' on https://github.com"
|
23
|
-
end
|
22
|
+
raise Error, "Unable to find module '#{source.uri}' on https://github.com" if data.nil?
|
24
23
|
|
25
24
|
all_versions = data.map { |r| r['name'].gsub(/^v/, '') }.sort.reverse
|
26
25
|
|
@@ -29,7 +28,7 @@ module Librarian
|
|
29
28
|
end
|
30
29
|
|
31
30
|
@versions = all_versions.compact
|
32
|
-
debug { " Module #{name} found versions: #{@versions.join(
|
31
|
+
debug { " Module #{name} found versions: #{@versions.join(', ')}" }
|
33
32
|
@versions
|
34
33
|
end
|
35
34
|
|
@@ -48,9 +47,7 @@ module Librarian
|
|
48
47
|
|
49
48
|
cache_version_unpacked! version
|
50
49
|
|
51
|
-
if install_path.exist? && rsync? != true
|
52
|
-
install_path.rmtree
|
53
|
-
end
|
50
|
+
install_path.rmtree if install_path.exist? && rsync? != true
|
54
51
|
|
55
52
|
unpacked_path = version_unpacked_cache_path(version).children.first
|
56
53
|
cp_r(unpacked_path, install_path)
|
@@ -64,7 +61,7 @@ module Librarian
|
|
64
61
|
|
65
62
|
target = vendored?(vendored_name, version) ? vendored_path(vendored_name, version) : name
|
66
63
|
|
67
|
-
Librarian::Posix.run!(%W
|
64
|
+
Librarian::Posix.run!(%W[tar xzf #{target} -C #{path}])
|
68
65
|
end
|
69
66
|
|
70
67
|
def vendor_cache(name, version)
|
@@ -75,17 +72,15 @@ module Librarian
|
|
75
72
|
|
76
73
|
environment.vendor!
|
77
74
|
File.open(vendored_path(vendored_name(name), version).to_s, 'wb') do |f|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
f.write(buffer)
|
84
|
-
end
|
75
|
+
debug { "Downloading <#{url}> to <#{f.path}>" }
|
76
|
+
URI.open(url,
|
77
|
+
'User-Agent' => "librarian-puppet v#{Librarian::Puppet::VERSION}") do |res|
|
78
|
+
while buffer = res.read(8192)
|
79
|
+
f.write(buffer)
|
85
80
|
end
|
86
|
-
rescue OpenURI::HTTPError => e
|
87
|
-
raise e, "Error requesting <#{url}>: #{e.to_s}"
|
88
81
|
end
|
82
|
+
rescue OpenURI::HTTPError => e
|
83
|
+
raise e, "Error requesting <#{url}>: #{e}"
|
89
84
|
end
|
90
85
|
end
|
91
86
|
|
@@ -96,37 +91,38 @@ module Librarian
|
|
96
91
|
end
|
97
92
|
|
98
93
|
def token_key_value
|
99
|
-
ENV
|
94
|
+
ENV.fetch(TOKEN_KEY, nil)
|
100
95
|
end
|
101
96
|
|
102
97
|
def token_key_nil?
|
103
98
|
token_key_value.nil? || token_key_value.empty?
|
104
99
|
end
|
105
100
|
|
106
|
-
def add_api_token_to_url
|
101
|
+
def add_api_token_to_url(url)
|
107
102
|
if token_key_nil?
|
108
103
|
debug { "#{TOKEN_KEY} environment value is empty or missing" }
|
109
|
-
elsif url.include?
|
110
|
-
url << "&access_token=#{ENV
|
104
|
+
elsif url.include? '?'
|
105
|
+
url << "&access_token=#{ENV.fetch(TOKEN_KEY, nil)}"
|
111
106
|
else
|
112
|
-
url << "?access_token=#{ENV
|
107
|
+
url << "?access_token=#{ENV.fetch(TOKEN_KEY, nil)}"
|
113
108
|
end
|
114
109
|
url
|
115
110
|
end
|
116
111
|
|
117
|
-
|
112
|
+
private
|
118
113
|
|
119
114
|
def api_call(path)
|
120
115
|
tags = []
|
121
116
|
url = "https://api.github.com#{path}?page=1&per_page=100"
|
122
|
-
while true
|
117
|
+
while true
|
123
118
|
debug { " Module #{name} getting tags at: #{url}" }
|
124
119
|
add_api_token_to_url(url)
|
125
|
-
response = http_get(url, :
|
126
|
-
|
127
|
-
|
120
|
+
response = http_get(url, headers: {
|
121
|
+
'User-Agent' => "librarian-puppet v#{Librarian::Puppet::VERSION}",
|
122
|
+
})
|
128
123
|
|
129
|
-
code
|
124
|
+
code = response.code.to_i
|
125
|
+
data = response.body
|
130
126
|
|
131
127
|
if code == 200
|
132
128
|
tags.concat JSON.parse(data)
|
@@ -145,12 +141,14 @@ module Librarian
|
|
145
141
|
end
|
146
142
|
|
147
143
|
# next page
|
148
|
-
break if response[
|
149
|
-
|
144
|
+
break if response['link'].nil?
|
145
|
+
|
146
|
+
next_link = response['link'].split(',').select { |l| l.match(/rel=.*next.*/) }
|
150
147
|
break if next_link.empty?
|
148
|
+
|
151
149
|
url = next_link.first.match(/<(.*)>/)[1]
|
152
150
|
end
|
153
|
-
|
151
|
+
tags
|
154
152
|
end
|
155
153
|
|
156
154
|
def http_get(url, options)
|
@@ -163,7 +161,7 @@ module Librarian
|
|
163
161
|
end
|
164
162
|
|
165
163
|
def vendored_name(name = source.uri.to_s)
|
166
|
-
name.sub('/','-')
|
164
|
+
name.sub('/', '-')
|
167
165
|
end
|
168
166
|
end
|
169
167
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'uri'
|
2
4
|
require 'librarian/puppet/util'
|
3
5
|
require 'librarian/puppet/source/githubtarball/repo'
|
@@ -16,15 +18,13 @@ module Librarian
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def from_lock_options(environment, options)
|
19
|
-
new(environment, options[:remote], options.reject { |k,
|
21
|
+
new(environment, options[:remote], options.reject { |k, _v| k == :remote })
|
20
22
|
end
|
21
23
|
|
22
24
|
def from_spec_args(environment, uri, options)
|
23
25
|
recognised_options = []
|
24
26
|
unrecognised_options = options.keys - recognised_options
|
25
|
-
unless unrecognised_options.empty?
|
26
|
-
raise Error, "unrecognised options: #{unrecognised_options.join(", ")}"
|
27
|
-
end
|
27
|
+
raise Error, "unrecognised options: #{unrecognised_options.join(', ')}" unless unrecognised_options.empty?
|
28
28
|
|
29
29
|
new(environment, uri, options)
|
30
30
|
end
|
@@ -34,9 +34,9 @@ module Librarian
|
|
34
34
|
private :environment=
|
35
35
|
attr_reader :uri
|
36
36
|
|
37
|
-
def initialize(environment, uri,
|
37
|
+
def initialize(environment, uri, _options = {})
|
38
38
|
self.environment = environment
|
39
|
-
@uri = URI
|
39
|
+
@uri = URI.parse(uri)
|
40
40
|
@cache_path = nil
|
41
41
|
end
|
42
42
|
|
@@ -46,14 +46,14 @@ module Librarian
|
|
46
46
|
|
47
47
|
def ==(other)
|
48
48
|
other &&
|
49
|
-
|
50
|
-
|
49
|
+
self.class == other.class &&
|
50
|
+
uri == other.uri
|
51
51
|
end
|
52
52
|
|
53
|
-
alias
|
53
|
+
alias eql? ==
|
54
54
|
|
55
55
|
def hash
|
56
|
-
|
56
|
+
to_s.hash
|
57
57
|
end
|
58
58
|
|
59
59
|
def to_spec_args
|
@@ -61,15 +61,14 @@ module Librarian
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def to_lock_options
|
64
|
-
{:
|
64
|
+
{ remote: clean_uri(uri).to_s }
|
65
65
|
end
|
66
66
|
|
67
67
|
def pinned?
|
68
68
|
false
|
69
69
|
end
|
70
70
|
|
71
|
-
def unpin
|
72
|
-
end
|
71
|
+
def unpin!; end
|
73
72
|
|
74
73
|
def install!(manifest)
|
75
74
|
manifest.source == self or raise ArgumentError
|
@@ -92,9 +91,7 @@ module Librarian
|
|
92
91
|
end
|
93
92
|
|
94
93
|
def cache_path
|
95
|
-
@cache_path ||=
|
96
|
-
environment.cache_path.join("source/puppet/githubtarball/#{uri.host}#{uri.path}")
|
97
|
-
end
|
94
|
+
@cache_path ||= environment.cache_path.join("source/puppet/githubtarball/#{uri.host}#{uri.path}")
|
98
95
|
end
|
99
96
|
|
100
97
|
def install_path(name)
|
@@ -110,7 +107,7 @@ module Librarian
|
|
110
107
|
end
|
111
108
|
end
|
112
109
|
|
113
|
-
def fetch_dependencies(
|
110
|
+
def fetch_dependencies(_name, _version, _version_uri)
|
114
111
|
{}
|
115
112
|
end
|
116
113
|
|
@@ -118,7 +115,7 @@ module Librarian
|
|
118
115
|
repo(name).manifests
|
119
116
|
end
|
120
117
|
|
121
|
-
|
118
|
+
private
|
122
119
|
|
123
120
|
def repo(name)
|
124
121
|
@repo ||= {}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'librarian/puppet/util'
|
2
4
|
|
3
5
|
module Librarian
|
@@ -11,12 +13,15 @@ module Librarian
|
|
11
13
|
|
12
14
|
debug { "Installing #{manifest}" }
|
13
15
|
|
14
|
-
name
|
16
|
+
name = manifest.name
|
17
|
+
_ = manifest.version
|
15
18
|
found_path = found_path(name)
|
16
19
|
raise Error, "Path for #{name} doesn't contain a puppet module" if found_path.nil?
|
17
20
|
|
18
21
|
unless name.include? '/' or name.include? '-'
|
19
|
-
warn
|
22
|
+
warn do
|
23
|
+
"Invalid module name '#{name}', you should qualify it with 'ORGANIZATION-#{name}' for resolution to work correctly"
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
install_path = environment.install_path.join(module_name(name))
|
@@ -28,13 +33,13 @@ module Librarian
|
|
28
33
|
install_perform_step_copy!(found_path, install_path)
|
29
34
|
end
|
30
35
|
|
31
|
-
def fetch_version(name,
|
36
|
+
def fetch_version(name, _extra)
|
32
37
|
cache!
|
33
|
-
found_path
|
38
|
+
found_path(name)
|
34
39
|
module_version
|
35
40
|
end
|
36
41
|
|
37
|
-
def fetch_dependencies(name,
|
42
|
+
def fetch_dependencies(name, _version, _extra)
|
38
43
|
dependencies = Set.new
|
39
44
|
|
40
45
|
if specfile?
|
@@ -62,7 +67,7 @@ module Librarian
|
|
62
67
|
if parsed_metadata['version']
|
63
68
|
parsed_metadata['version']
|
64
69
|
else
|
65
|
-
warn { "Module #{
|
70
|
+
warn { "Module #{self} does not have version, defaulting to 0.0.1" }
|
66
71
|
'0.0.1'
|
67
72
|
end
|
68
73
|
end
|
@@ -70,14 +75,14 @@ module Librarian
|
|
70
75
|
def parsed_metadata
|
71
76
|
if @metadata.nil?
|
72
77
|
@metadata = if metadata?
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
begin
|
79
|
+
JSON.parse(File.read(metadata))
|
80
|
+
rescue JSON::ParserError => e
|
81
|
+
raise Error, "Unable to parse json file #{metadata}: #{e}"
|
82
|
+
end
|
83
|
+
else
|
84
|
+
{}
|
85
|
+
end
|
81
86
|
@metadata['dependencies'] ||= []
|
82
87
|
end
|
83
88
|
@metadata
|
@@ -104,10 +109,11 @@ module Librarian
|
|
104
109
|
cp_r(found_path, install_path)
|
105
110
|
end
|
106
111
|
|
107
|
-
def manifest?(
|
112
|
+
def manifest?(_name, path)
|
108
113
|
return true if path.join('manifests').exist?
|
109
114
|
return true if path.join('lib').join('puppet').exist?
|
110
115
|
return true if path.join('lib').join('facter').exist?
|
116
|
+
|
111
117
|
debug { "Could not find manifests, lib/puppet or lib/facter under #{path}, maybe it is not a puppet module" }
|
112
118
|
true
|
113
119
|
end
|
@@ -1,9 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# parent class for githubtarball and forge source Repos
|
2
4
|
module Librarian
|
3
5
|
module Puppet
|
4
6
|
module Source
|
5
7
|
class Repo
|
6
|
-
|
7
8
|
attr_accessor :source, :name
|
8
9
|
private :source=, :name=
|
9
10
|
|
@@ -31,7 +32,6 @@ module Librarian
|
|
31
32
|
def vendored_path(name, version)
|
32
33
|
environment.vendor_cache.join("#{name}-#{version}.tar.gz")
|
33
34
|
end
|
34
|
-
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|