kpm 0.8.0 → 0.10.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 +5 -5
- data/.gitignore +2 -0
- data/.rubocop.yml +80 -8
- data/README.adoc +37 -2
- data/docker/docker-compose.ci.mysql.yml +21 -0
- data/kpm.gemspec +4 -3
- data/lib/kpm/account.rb +4 -3
- data/lib/kpm/coordinates.rb +4 -3
- data/lib/kpm/database.rb +8 -3
- data/lib/kpm/formatter.rb +2 -2
- data/lib/kpm/inspector.rb +2 -2
- data/lib/kpm/migrations.rb +18 -4
- data/lib/kpm/nexus_helper/actions.rb +9 -5
- data/lib/kpm/nexus_helper/cloudsmith_api_calls.rb +85 -0
- data/lib/kpm/nexus_helper/github_api_calls.rb +70 -0
- data/lib/kpm/nexus_helper/nexus_api_calls_v2.rb +79 -50
- data/lib/kpm/plugins_directory.yml +14 -6
- data/lib/kpm/system.rb +1 -1
- data/lib/kpm/tasks.rb +23 -7
- data/lib/kpm/tenant_config.rb +1 -1
- data/lib/kpm/tomcat_manager.rb +1 -0
- data/lib/kpm/version.rb +1 -1
- data/pom.xml +211 -40
- data/spec/kpm/remote/base_artifact_spec.rb +15 -13
- data/spec/kpm/remote/base_installer_spec.rb +13 -13
- data/spec/kpm/remote/cloudsmith_api_calls_spec.rb +109 -0
- data/spec/kpm/remote/github_api_calls_spec.rb +40 -0
- data/spec/kpm/remote/installer_spec.rb +38 -37
- data/spec/kpm/remote/kaui_artifact_spec.rb +4 -4
- data/spec/kpm/remote/killbill_plugin_artifact_spec.rb +19 -19
- data/spec/kpm/remote/killbill_server_artifact_spec.rb +13 -13
- data/spec/kpm/remote/migrations_spec.rb +9 -9
- data/spec/kpm/remote/nexus_facade_spec.rb +2 -2
- data/spec/kpm/remote/tenant_config_spec.rb +3 -3
- data/spec/kpm/remote/tomcat_manager_spec.rb +2 -2
- data/spec/kpm/unit/actions_spec.rb +2 -2
- data/spec/kpm/unit/base_artifact_spec.rb +14 -14
- data/spec/kpm/unit/inspector_spec.rb +28 -28
- data/spec/kpm/unit/installer_spec.rb +4 -4
- data/spec/kpm/unit/plugins_directory_spec.rb +31 -31
- data/spec/kpm/unit/plugins_manager_spec.rb +54 -54
- data/spec/kpm/unit/sha1_checker_spec.rb +2 -2
- data/spec/kpm/unit/uninstaller_spec.rb +21 -21
- data/spec/kpm/unit_mysql/account_spec.rb +13 -13
- data/spec/spec_helper.rb +1 -1
- metadata +28 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d052b9c73fbb831cf7469a3f57ae21dfe733ededd65541f7b693117b857d4f7c
|
4
|
+
data.tar.gz: a76a44cac1de427a83183be0d1d271f8f79e35f0945d9722576363a5644be690
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8c51c778cd35a93b2416c8eed3ba9e43d9307ab1df9b6d066ca67384b17c17b32f612445ce102433b261057a137fe5b95b13be5366ec73a79eeb40cedd588ba
|
7
|
+
data.tar.gz: b634baf2edc85f1f0f0880dc4d1c81deb434affe7ee4065825f31fcffa53fe9f6a62fc5849e93b00d44cf9da64952a3e9c0431d89e73e6edd58541bd47175619
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -4,6 +4,15 @@
|
|
4
4
|
Gemspec/RequiredRubyVersion:
|
5
5
|
Enabled: false
|
6
6
|
|
7
|
+
Layout/LineLength:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
11
|
+
Enabled: true
|
12
|
+
|
13
|
+
Layout/SpaceAroundMethodCallOperator:
|
14
|
+
Enabled: true
|
15
|
+
|
7
16
|
# Alternative?
|
8
17
|
Gemspec/RubyVersionGlobalsUsage:
|
9
18
|
Enabled: false
|
@@ -11,7 +20,22 @@ Gemspec/RubyVersionGlobalsUsage:
|
|
11
20
|
Layout/DefEndAlignment:
|
12
21
|
AutoCorrect: true
|
13
22
|
|
14
|
-
Lint/
|
23
|
+
Lint/DeprecatedOpenSSLConstant:
|
24
|
+
Enabled: true
|
25
|
+
|
26
|
+
Lint/DuplicateElsifCondition:
|
27
|
+
Enabled: true
|
28
|
+
|
29
|
+
Lint/MixedRegexpCaptureTypes:
|
30
|
+
Enabled: true
|
31
|
+
|
32
|
+
Lint/RaiseException:
|
33
|
+
Enabled: true
|
34
|
+
|
35
|
+
Lint/StructNewOverride:
|
36
|
+
Enabled: true
|
37
|
+
|
38
|
+
Lint/SuppressedException:
|
15
39
|
AllowComments: true
|
16
40
|
|
17
41
|
Metrics/AbcSize:
|
@@ -29,9 +53,6 @@ Metrics/ClassLength:
|
|
29
53
|
Metrics/CyclomaticComplexity:
|
30
54
|
Enabled: false
|
31
55
|
|
32
|
-
Metrics/LineLength:
|
33
|
-
Enabled: false
|
34
|
-
|
35
56
|
Metrics/MethodLength:
|
36
57
|
Enabled: false
|
37
58
|
|
@@ -47,10 +68,6 @@ Metrics/PerceivedComplexity:
|
|
47
68
|
Security/YAMLLoad:
|
48
69
|
Enabled: false
|
49
70
|
|
50
|
-
# We must support old Rubies
|
51
|
-
Style/BracesAroundHashParameters:
|
52
|
-
Enabled: false
|
53
|
-
|
54
71
|
Style/Documentation:
|
55
72
|
Enabled: false
|
56
73
|
|
@@ -61,6 +78,61 @@ Style/EmptyElse:
|
|
61
78
|
Style/HashSyntax:
|
62
79
|
Enabled: false
|
63
80
|
|
81
|
+
# Ruby 2.3+ only
|
82
|
+
Style/NumericPredicate:
|
83
|
+
Enabled: false
|
84
|
+
|
64
85
|
# Ruby 2.3+ only
|
65
86
|
Style/SafeNavigation:
|
66
87
|
Enabled: false
|
88
|
+
|
89
|
+
Style/GuardClause:
|
90
|
+
Enabled: false
|
91
|
+
|
92
|
+
Style/AccessorGrouping:
|
93
|
+
Enabled: true
|
94
|
+
|
95
|
+
Style/ArrayCoercion:
|
96
|
+
Enabled: true
|
97
|
+
|
98
|
+
Style/BisectedAttrAccessor:
|
99
|
+
Enabled: true
|
100
|
+
|
101
|
+
Style/CaseLikeIf:
|
102
|
+
Enabled: true
|
103
|
+
|
104
|
+
Style/ExponentialNotation:
|
105
|
+
Enabled: true
|
106
|
+
|
107
|
+
Style/HashAsLastArrayItem:
|
108
|
+
Enabled: true
|
109
|
+
|
110
|
+
Style/HashEachMethods:
|
111
|
+
Enabled: true
|
112
|
+
|
113
|
+
Style/HashLikeCase:
|
114
|
+
Enabled: true
|
115
|
+
|
116
|
+
Style/HashTransformKeys:
|
117
|
+
Enabled: true
|
118
|
+
|
119
|
+
Style/HashTransformValues:
|
120
|
+
Enabled: true
|
121
|
+
|
122
|
+
Style/RedundantAssignment:
|
123
|
+
Enabled: true
|
124
|
+
|
125
|
+
Style/RedundantFetchBlock:
|
126
|
+
Enabled: true
|
127
|
+
|
128
|
+
Style/RedundantFileExtensionInRequire:
|
129
|
+
Enabled: true
|
130
|
+
|
131
|
+
Style/RedundantRegexpCharacterClass:
|
132
|
+
Enabled: true
|
133
|
+
|
134
|
+
Style/RedundantRegexpEscape:
|
135
|
+
Enabled: true
|
136
|
+
|
137
|
+
Style/SlicingWithRange:
|
138
|
+
Enabled: true
|
data/README.adoc
CHANGED
@@ -14,8 +14,9 @@ toc::[]
|
|
14
14
|
|
15
15
|
[[pre-built-binaries-recommended]]
|
16
16
|
=== Pre-built binaries (recommended)
|
17
|
+
image:https://img.shields.io/maven-central/v/org.kill-bill.billing.installer/kpm?color=blue&label=kpm[kpm]
|
17
18
|
|
18
|
-
KPM self-contained builds are available on http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.kill-bill.billing.installer%22%20AND%20a%3A%22kpm%22[Maven Central] with coordinates `org.kill-bill.billing.installer:kpm`.
|
19
|
+
On Linux and MacOS, you can use the pre-built binaries. KPM self-contained builds are available on http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.kill-bill.billing.installer%22%20AND%20a%3A%22kpm%22[Maven Central] with coordinates `org.kill-bill.billing.installer:kpm`.
|
19
20
|
|
20
21
|
Download the `.tar.gz` package matching your architecture (Linux and MacOS only).
|
21
22
|
|
@@ -23,8 +24,13 @@ Note that this installation method assumes `/bin/bash` to be available on your s
|
|
23
24
|
|
24
25
|
[[through-rubygems]]
|
25
26
|
=== Through Rubygems
|
27
|
+
image:https://img.shields.io/gem/v/kpm?color=blue&label=kpm[kpm]
|
28
|
+
|
29
|
+
On Windows, you can install KPM via https://rubygems.org/gems/kpm[RubyGems.org]. For this, you need to first install Ruby. Ruby can be installed via https://rubyinstaller.org/[RubyInstaller]. Once installed, you can run the following command to install KPM:
|
30
|
+
[source,bash]
|
31
|
+
gem install kpm
|
32
|
+
|
26
33
|
|
27
|
-
KPM is also available on https://rubygems.org/gems/kpm[RubyGems.org].
|
28
34
|
|
29
35
|
[[kpm-commands]]
|
30
36
|
== KPM Commands
|
@@ -245,3 +251,32 @@ Notes:
|
|
245
251
|
|
246
252
|
* You can override that behavior with the `--force-download` switch
|
247
253
|
* When `--force-download` is specified (`false` by default), network access to a Nexus instance is required. Otherwise, downloads are idempotent even if no outbound networking is allowed (on initial download, the Nexus metadata is cached in the `sha1.yml` file which is re-used on subsequent installation if no outbound networking is allowed -- by default, KPM will try to get the latest metadata from Nexus though)
|
254
|
+
|
255
|
+
[[gh-packages]]
|
256
|
+
### GitHub Packages
|
257
|
+
|
258
|
+
Starting with version 0.9.0, experimental support for GitHub packages has been added:
|
259
|
+
|
260
|
+
....
|
261
|
+
kpm install_java_plugin acme:plugin \
|
262
|
+
--overrides url:https://maven.pkg.github.com/acme/plugin token:<TOKEN> \
|
263
|
+
--group-id com.acme \
|
264
|
+
--artifact-id plugin \
|
265
|
+
--version 0.0.1
|
266
|
+
....
|
267
|
+
|
268
|
+
Replace `TOKEN` with a GitHub personal access token.
|
269
|
+
|
270
|
+
[[cloudsmith]]
|
271
|
+
### Cloudsmith
|
272
|
+
|
273
|
+
Starting with version 0.10.0, experimental support for Cloudsmith has been added:
|
274
|
+
|
275
|
+
....
|
276
|
+
kpm pull_kb_server_war 0.22.21-SNAPSHOT \
|
277
|
+
--overrides url:https://dl.cloudsmith.io/<TOKEN>/<ORG>/<REPO>/maven \
|
278
|
+
--group-id org.kill-bill.billing \
|
279
|
+
--artifact-id killbill-profiles-killbill
|
280
|
+
....
|
281
|
+
|
282
|
+
Replace `TOKEN` with a Cloudsmith entitlement token, and specify the right `ORG` and `REPO`.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
version: '3.8'
|
2
|
+
|
3
|
+
services:
|
4
|
+
killbill:
|
5
|
+
network_mode: host
|
6
|
+
image: killbill/killbill:0.22.1
|
7
|
+
environment:
|
8
|
+
- KILLBILL_CATALOG_URI=SpyCarAdvanced.xml
|
9
|
+
- KILLBILL_DAO_URL=jdbc:mysql://0.0.0.0:3306/killbill
|
10
|
+
- KILLBILL_DAO_USER=root
|
11
|
+
- KILLBILL_DAO_PASSWORD=root
|
12
|
+
- KILLBILL_SERVER_TEST_MODE=true
|
13
|
+
- KILLBILL_INVOICE_SANITY_SAFETY_BOUND_ENABLED=false
|
14
|
+
- KILLBILL_INVOICE_MAX_DAILY_NUMBER_OF_ITEMS_SAFETY_BOUND=-1
|
15
|
+
depends_on:
|
16
|
+
- db
|
17
|
+
db:
|
18
|
+
network_mode: host
|
19
|
+
image: killbill/mariadb:0.22
|
20
|
+
environment:
|
21
|
+
- MYSQL_ROOT_PASSWORD=root
|
data/kpm.gemspec
CHANGED
@@ -46,7 +46,8 @@ Gem::Specification.new do |s|
|
|
46
46
|
s.add_dependency 'rubyzip', '~>1.2.0'
|
47
47
|
s.add_dependency 'thor', '~> 0.19.1'
|
48
48
|
|
49
|
-
s.add_development_dependency '
|
50
|
-
s.add_development_dependency '
|
51
|
-
s.add_development_dependency '
|
49
|
+
s.add_development_dependency 'gem-release', '~> 2.2'
|
50
|
+
s.add_development_dependency 'rake', '~> 13.0'
|
51
|
+
s.add_development_dependency 'rspec', '~> 3.9'
|
52
|
+
s.add_development_dependency 'rubocop', '~> 0.88.0' if RUBY_VERSION >= '2.4'
|
52
53
|
end
|
data/lib/kpm/account.rb
CHANGED
@@ -194,7 +194,7 @@ module KPM
|
|
194
194
|
tables = {}
|
195
195
|
error_importing_data = false
|
196
196
|
|
197
|
-
File.open(source_file, 'r') do |data|
|
197
|
+
File.open(source_file, 'r:UTF-8') do |data|
|
198
198
|
rows = nil
|
199
199
|
table_name = nil
|
200
200
|
cols_names = nil
|
@@ -316,9 +316,10 @@ module KPM
|
|
316
316
|
end
|
317
317
|
|
318
318
|
def replace_boolean(value)
|
319
|
-
|
319
|
+
case value.to_s
|
320
|
+
when 'true'
|
320
321
|
1
|
321
|
-
|
322
|
+
when 'false'
|
322
323
|
0
|
323
324
|
else
|
324
325
|
value
|
data/lib/kpm/coordinates.rb
CHANGED
@@ -24,11 +24,12 @@ module KPM
|
|
24
24
|
def get_coordinate_map(entry)
|
25
25
|
parts = entry.split(':')
|
26
26
|
length = parts.size
|
27
|
-
|
27
|
+
case length
|
28
|
+
when 3
|
28
29
|
{ group_id: parts[0], artifact_id: parts[1], packaging: parts[2] }
|
29
|
-
|
30
|
+
when 4
|
30
31
|
{ group_id: parts[0], artifact_id: parts[1], packaging: parts[2], version: parts[3] }
|
31
|
-
|
32
|
+
when 5
|
32
33
|
{ group_id: parts[0], artifact_id: parts[1], packaging: parts[2], classifier: parts[3], version: parts[4] }
|
33
34
|
end
|
34
35
|
end
|
data/lib/kpm/database.rb
CHANGED
@@ -44,7 +44,11 @@ module KPM
|
|
44
44
|
@logger.error "\e[91;1mTransaction that fails to be executed (first 1,000 chars)\e[0m"
|
45
45
|
# Queries can be really big (bulk imports)
|
46
46
|
@logger.error "\e[91m#{query[0..1000]}\e[0m"
|
47
|
-
|
47
|
+
if response.include?('Table') && response.include?('doesn\'t exist')
|
48
|
+
@logger.warn "Skipping unknown table #{table_name}...."
|
49
|
+
else
|
50
|
+
raise Interrupt, "Importing table #{table_name}...... \e[91;1m#{response}\e[0m"
|
51
|
+
end
|
48
52
|
end
|
49
53
|
|
50
54
|
if response.include? 'LAST_INSERT_ID'
|
@@ -82,9 +86,10 @@ module KPM
|
|
82
86
|
rows = []
|
83
87
|
table[:rows].each do |row|
|
84
88
|
rows << row.map do |value|
|
85
|
-
|
89
|
+
case value
|
90
|
+
when Symbol
|
86
91
|
value.to_s
|
87
|
-
|
92
|
+
when Blob
|
88
93
|
value.value
|
89
94
|
else
|
90
95
|
escaped_value = value.to_s.gsub(/['"]/, "'" => "\\'", '"' => '\\"')
|
data/lib/kpm/formatter.rb
CHANGED
@@ -97,7 +97,7 @@ module KPM
|
|
97
97
|
formatted += Kernel.format("#{format_string}\n", *labels_format_argument)
|
98
98
|
formatted += "#{border}\n"
|
99
99
|
|
100
|
-
data.
|
100
|
+
data.each_key do |key|
|
101
101
|
v = data[key]
|
102
102
|
|
103
103
|
arguments = []
|
@@ -131,7 +131,7 @@ module KPM
|
|
131
131
|
seen_labels = Set.new
|
132
132
|
|
133
133
|
labels_format_argument = []
|
134
|
-
data.
|
134
|
+
data.each_key do |key|
|
135
135
|
v = data[key]
|
136
136
|
labels.each do |e|
|
137
137
|
# sanitize entry at the same time
|
data/lib/kpm/inspector.rb
CHANGED
@@ -33,7 +33,7 @@ module KPM
|
|
33
33
|
sha1_file = "#{bundles_dir}/#{sha1_filename}"
|
34
34
|
sha1_checker = Sha1Checker.from_file(sha1_file)
|
35
35
|
|
36
|
-
all_plugins.
|
36
|
+
all_plugins.each_key do |cur_plugin_name|
|
37
37
|
cur = all_plugins[cur_plugin_name]
|
38
38
|
|
39
39
|
sha1_checker.all_sha1.each do |e|
|
@@ -52,7 +52,7 @@ module KPM
|
|
52
52
|
|
53
53
|
def add_plugin_identifier_info(plugins, all_plugins)
|
54
54
|
plugins_manager = PluginsManager.new(plugins, @logger)
|
55
|
-
all_plugins.
|
55
|
+
all_plugins.each_key do |cur|
|
56
56
|
plugin_key, entry = plugins_manager.get_identifier_key_and_entry(cur)
|
57
57
|
all_plugins[cur][:plugin_key] = plugin_key
|
58
58
|
all_plugins[cur][:group_id] = entry ? entry['group_id'] : nil
|
data/lib/kpm/migrations.rb
CHANGED
@@ -54,7 +54,7 @@ module KPM
|
|
54
54
|
|
55
55
|
def for_version(version = @from_version, name_only = false, migrations_to_skip = Set.new)
|
56
56
|
@logger.info("Looking for migrations repository=#{@repository}, version=#{version}")
|
57
|
-
metadata = get_as_json("https://api.github.com/repos/#{@repository}/git/trees/#{version}?recursive=1
|
57
|
+
metadata = get_as_json("https://api.github.com/repos/#{@repository}/git/trees/#{version}?recursive=1")
|
58
58
|
|
59
59
|
migrations = []
|
60
60
|
metadata['tree'].each do |entry|
|
@@ -67,7 +67,7 @@ module KPM
|
|
67
67
|
|
68
68
|
sql = nil
|
69
69
|
unless name_only
|
70
|
-
blob_metadata = get_as_json(
|
70
|
+
blob_metadata = get_as_json((entry['url']).to_s)
|
71
71
|
sql = decode(blob_metadata['content'], blob_metadata['encoding'])
|
72
72
|
end
|
73
73
|
|
@@ -81,8 +81,22 @@ module KPM
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def get_as_json(url)
|
84
|
-
|
85
|
-
|
84
|
+
uri = URI.parse(url)
|
85
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
86
|
+
http.use_ssl = uri.scheme == 'https'
|
87
|
+
|
88
|
+
path = uri.path || '/'
|
89
|
+
path = "#{path}?#{uri.query}" unless uri.query.nil?
|
90
|
+
request = Net::HTTP::Get.new(path)
|
91
|
+
request['Authorization'] = "token #{@oauth_token}" unless @oauth_token.nil?
|
92
|
+
|
93
|
+
response = http.request(request)
|
94
|
+
case response.code
|
95
|
+
when '200'
|
96
|
+
JSON.parse(response.body)
|
97
|
+
else
|
98
|
+
raise "Unable to download #{url}: #{response.code}"
|
99
|
+
end
|
86
100
|
end
|
87
101
|
|
88
102
|
def decode(content, encoding)
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'nexus_api_calls_v2'
|
4
|
-
|
4
|
+
require_relative 'github_api_calls'
|
5
|
+
require_relative 'cloudsmith_api_calls'
|
5
6
|
|
6
7
|
module KPM
|
7
8
|
module NexusFacade
|
@@ -29,10 +30,13 @@ module KPM
|
|
29
30
|
|
30
31
|
@logger = logger
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
@nexus_api_call = if overrides[:url].start_with?('https://maven.pkg.github.com')
|
34
|
+
GithubApiCalls.new(overrides, ssl_verify, logger)
|
35
|
+
elsif overrides[:url].start_with?('https://dl.cloudsmith.io')
|
36
|
+
CloudsmithApiCalls.new(overrides, ssl_verify, logger)
|
37
|
+
else
|
38
|
+
NexusApiCallsV2.new(overrides, ssl_verify, logger)
|
39
|
+
end
|
36
40
|
end
|
37
41
|
|
38
42
|
def pull_artifact(coordinates, destination = nil)
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require 'uri'
|
5
|
+
require 'rexml/document'
|
6
|
+
require 'openssl'
|
7
|
+
|
8
|
+
module KPM
|
9
|
+
module NexusFacade
|
10
|
+
class CloudsmithApiCalls < NexusApiCallsV2
|
11
|
+
def pull_artifact_endpoint(coordinates)
|
12
|
+
version_artifact_details = begin
|
13
|
+
parent_get_artifact_info(coordinates)
|
14
|
+
rescue StandardError
|
15
|
+
''
|
16
|
+
end
|
17
|
+
|
18
|
+
# For SNAPSHOTs, we need to figure out the version used as part of the filename
|
19
|
+
filename_version = begin
|
20
|
+
REXML::Document.new(version_artifact_details).elements['//versioning/snapshotVersions/snapshotVersion[1]/value'].text
|
21
|
+
rescue StandardError
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
coords = parse_coordinates(coordinates)
|
25
|
+
coords[:version] = filename_version unless filename_version.nil?
|
26
|
+
new_coordinates = coords.values.compact.join(':')
|
27
|
+
|
28
|
+
base_path, versioned_artifact, = build_base_path_and_coords(new_coordinates)
|
29
|
+
"#{base_path}/#{versioned_artifact}"
|
30
|
+
end
|
31
|
+
|
32
|
+
alias parent_get_artifact_info get_artifact_info
|
33
|
+
def get_artifact_info(coordinates)
|
34
|
+
_, versioned_artifact, coords = build_base_path_and_coords(coordinates)
|
35
|
+
sha1 = get_sha1(coordinates)
|
36
|
+
"<artifact-resolution>
|
37
|
+
<data>
|
38
|
+
<presentLocally>true</presentLocally>
|
39
|
+
<groupId>#{coords[:group_id]}</groupId>
|
40
|
+
<artifactId>#{coords[:artifact_id]}</artifactId>
|
41
|
+
<version>#{coords[:version]}</version>
|
42
|
+
<extension>#{coords[:packaging]}</extension>
|
43
|
+
<snapshot>#{!(coords[:version] =~ /-SNAPSHOT$/).nil?}</snapshot>
|
44
|
+
<sha1>#{sha1}</sha1>
|
45
|
+
<repositoryPath>/#{coords[:group_id].gsub('.', '/')}/#{versioned_artifact}</repositoryPath>
|
46
|
+
</data>
|
47
|
+
</artifact-resolution>"
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_artifact_info_endpoint(coordinates)
|
51
|
+
base_path, _, coords = build_base_path_and_coords(coordinates)
|
52
|
+
# Note: we must retrieve the XML for the version, to support SNAPSHOTs
|
53
|
+
"#{base_path}/#{coords[:version]}/maven-metadata.xml"
|
54
|
+
end
|
55
|
+
|
56
|
+
def search_for_artifact_endpoint(_coordinates)
|
57
|
+
raise NoMethodError, 'Cloudsmith has no search support'
|
58
|
+
end
|
59
|
+
|
60
|
+
def build_query_params(_coordinates, _what_parameters = nil)
|
61
|
+
''
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def get_sha1(coordinates)
|
67
|
+
base_path, versioned_artifact, = build_base_path_and_coords(coordinates)
|
68
|
+
endpoint = "#{base_path}/#{versioned_artifact}.sha1"
|
69
|
+
get_response_with_retries(coordinates, endpoint, nil)
|
70
|
+
end
|
71
|
+
|
72
|
+
def build_base_path_and_coords(coordinates)
|
73
|
+
coords = parse_coordinates(coordinates)
|
74
|
+
|
75
|
+
token_org_and_repo = URI.parse(configuration[:url]).path
|
76
|
+
|
77
|
+
[
|
78
|
+
"#{token_org_and_repo}/#{coords[:group_id].gsub('.', '/')}/#{coords[:artifact_id]}",
|
79
|
+
"#{coords[:version]}/#{coords[:artifact_id]}-#{coords[:version]}.#{coords[:extension]}",
|
80
|
+
coords
|
81
|
+
]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|