nexus_api 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +16 -7
- data/lib/endpoints/components.rb +12 -12
- data/lib/nexus_api.rb +4 -4
- data/lib/nexus_api/nexus_connection.rb +3 -2
- data/lib/nexus_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 371514d3283ad019a0143c037000fd69763e0231981dd864c224ddfbdbe3924f
|
4
|
+
data.tar.gz: f3180660805e3e34f6499d8476fe32745ac5e6ee4b9630b1b4b052b84eb523dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14a5948432eb3599b250ead5e7e42f3660790b461a6ca4f69fde81855e5e4aa286b56ba5e320a06d59856a3be224a241623429f213f2527833bb16ab21b0d3d4
|
7
|
+
data.tar.gz: 2d06ce5f2f4ae060772dd384fe93c89acc0e1b4806c6523f7ac6ece99bfe08d84872327fb11b3b98d649e1d07c3a7e8e365e7aefe653ca2eda70add7df10ed24
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
7
|
|
8
|
+
## [2.1.0](https://github.com/Cisco-AMP/nexus_api/compare/v2.0.1...v2.1.0) - 2020-10-13
|
9
|
+
### Added
|
10
|
+
- The ability to override HTTPS as the connection protocol for testing purposes
|
11
|
+
- The ability to specify a component name during upload that differs from the local file on disk
|
12
|
+
|
13
|
+
|
8
14
|
## [2.0.1](https://github.com/Cisco-AMP/nexus_api/compare/v2.0.0...v2.0.1) - 2020-09-08
|
9
15
|
### Security
|
10
16
|
- Use `rake` version `12.3.3` or later to avoid an [OS Command Injection](https://github.com/advisories/GHSA-jppv-gw3r-w3q8)
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -62,6 +62,7 @@ api = NexusAPI::API.new(
|
|
62
62
|
docker_pull_hostname: DOCKER_PULL_HOSTNAME, # Optional
|
63
63
|
docker_push_hostname: DOCKER_PUSH_HOSTNAME, # Optional
|
64
64
|
config: "team_configs/#{CONFIG_NAME}", # Optional
|
65
|
+
protocol: "https", # Optional
|
65
66
|
)
|
66
67
|
# NOTE: All Docker commands will fail if the docker hostnames are not initialized
|
67
68
|
|
@@ -251,41 +252,49 @@ api.download(
|
|
251
252
|
|
252
253
|
|
253
254
|
# Different asset types require differing information to be uploaded
|
254
|
-
# Optionally, you can
|
255
|
+
# Optionally, you can:
|
256
|
+
# - tag the component, provided the tag already exists
|
257
|
+
# - specify a new component name to use when uploading into Nexus (instead of using the local file name)
|
255
258
|
api.upload_maven_component(
|
256
259
|
filename: MAVEN_FILENAME,
|
257
260
|
group_id: GROUP_ID,
|
258
261
|
artifact_id: ARTIFACT_ID,
|
259
262
|
version: VERSION,
|
260
263
|
repository: REPOSITORY_NAME,
|
261
|
-
tag: TAG,
|
264
|
+
tag: TAG, # Optional
|
265
|
+
upstream_filename: UPSTREAM_FILENAME, # Optional
|
262
266
|
)
|
263
267
|
api.upload_npm_component(
|
264
268
|
filename: NPM_FILENAME,
|
265
269
|
repository: REPOSITORY_NAME,
|
266
|
-
tag: TAG,
|
270
|
+
tag: TAG, # Optional
|
271
|
+
upstream_filename: UPSTREAM_FILENAME, # Optional
|
267
272
|
)
|
268
273
|
api.upload_pypi_component(
|
269
274
|
filename: PYPI_FILENAME,
|
270
275
|
repository: REPOSITORY_NAME,
|
271
|
-
tag: TAG,
|
276
|
+
tag: TAG, # Optional
|
277
|
+
upstream_filename: UPSTREAM_FILENAME, # Optional
|
272
278
|
)
|
273
279
|
api.upload_raw_component(
|
274
280
|
filename: NPM_FILENAME,
|
275
281
|
directory: PATH_IN_NEXUS,
|
276
282
|
repository: REPOSITORY_NAME,
|
277
|
-
tag: TAG,
|
283
|
+
tag: TAG, # Optional
|
284
|
+
upstream_filename: UPSTREAM_FILENAME, # Optional
|
278
285
|
)
|
279
286
|
api.upload_rubygems_component(
|
280
287
|
filename: RUBYGEMS_FILENAME,
|
281
288
|
repository: REPOSITORY_NAME,
|
282
|
-
tag: TAG,
|
289
|
+
tag: TAG, # Optional
|
290
|
+
upstream_filename: UPSTREAM_FILENAME, # Optional
|
283
291
|
)
|
284
292
|
api.upload_yum_component(
|
285
293
|
filename: YUM_FILENAME,
|
286
294
|
directory: PATH_IN_NEXUS,
|
287
295
|
repository: REPOSITORY_NAME,
|
288
|
-
tag: TAG,
|
296
|
+
tag: TAG, # Optional
|
297
|
+
upstream_filename: UPSTREAM_FILENAME, # Optional
|
289
298
|
)
|
290
299
|
|
291
300
|
|
data/lib/endpoints/components.rb
CHANGED
@@ -16,62 +16,62 @@ module NexusAPI
|
|
16
16
|
end
|
17
17
|
|
18
18
|
# POST /service/rest/v1/components
|
19
|
-
def upload_maven_component(filename:, group_id:, artifact_id:, version:, repository: nil, tag: nil)
|
19
|
+
def upload_maven_component(filename:, group_id:, artifact_id:, version:, repository: nil, tag: nil, upstream_filename: nil)
|
20
20
|
repository ||= @team_config.maven_repository
|
21
21
|
parameters = {
|
22
22
|
'maven2.groupId' => group_id,
|
23
23
|
'maven2.artifactId' => artifact_id,
|
24
24
|
'maven2.version' => version,
|
25
|
-
'maven2.asset1' => File.open(filename, 'r'),
|
25
|
+
'maven2.asset1' => File.open(upstream_filename || filename, 'r'),
|
26
26
|
'maven2.asset1.extension' => filename.split('.').last,
|
27
27
|
}
|
28
28
|
parameters['maven2.tag'] = tag if tag
|
29
29
|
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
30
30
|
end
|
31
31
|
|
32
|
-
def upload_npm_component(filename:, repository: nil, tag: nil)
|
32
|
+
def upload_npm_component(filename:, repository: nil, tag: nil, upstream_filename: nil)
|
33
33
|
repository ||= @team_config.npm_repository
|
34
34
|
parameters = {
|
35
|
-
'npm.asset' => File.open(filename, 'r'),
|
35
|
+
'npm.asset' => File.open(upstream_filename || filename, 'r'),
|
36
36
|
}
|
37
37
|
parameters['npm.tag'] = tag if tag
|
38
38
|
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
39
39
|
end
|
40
40
|
|
41
|
-
def upload_pypi_component(filename:, repository: nil, tag: nil)
|
41
|
+
def upload_pypi_component(filename:, repository: nil, tag: nil, upstream_filename: nil)
|
42
42
|
repository ||= @team_config.pypi_repository
|
43
43
|
parameters = {
|
44
|
-
'pypi.asset' => File.open(filename, 'r'),
|
44
|
+
'pypi.asset' => File.open(upstream_filename || filename, 'r'),
|
45
45
|
}
|
46
46
|
parameters['pypi.tag'] = tag if tag
|
47
47
|
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
48
48
|
end
|
49
49
|
|
50
|
-
def upload_raw_component(filename:, directory:, repository: nil, tag: nil)
|
50
|
+
def upload_raw_component(filename:, directory:, repository: nil, tag: nil, upstream_filename: nil)
|
51
51
|
repository ||= @team_config.raw_repository
|
52
52
|
parameters = {
|
53
53
|
'raw.directory' => directory,
|
54
|
-
'raw.asset1' => File.open(filename, 'r'),
|
54
|
+
'raw.asset1' => File.open(upstream_filename || filename, 'r'),
|
55
55
|
'raw.asset1.filename' => filename.split('/').last,
|
56
56
|
}
|
57
57
|
parameters['raw.tag'] = tag if tag
|
58
58
|
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
59
59
|
end
|
60
60
|
|
61
|
-
def upload_rubygems_component(filename:, repository: nil, tag: nil)
|
61
|
+
def upload_rubygems_component(filename:, repository: nil, tag: nil, upstream_filename: nil)
|
62
62
|
repository ||= @team_config.rubygems_repository
|
63
63
|
parameters = {
|
64
|
-
'rubygems.asset' => File.open(filename, 'r'),
|
64
|
+
'rubygems.asset' => File.open(upstream_filename || filename, 'r'),
|
65
65
|
}
|
66
66
|
parameters['rubygems.tag'] = tag if tag
|
67
67
|
@connection.post(endpoint: "components?repository=#{repository}", parameters: parameters, headers: {})
|
68
68
|
end
|
69
69
|
|
70
|
-
def upload_yum_component(filename:, directory:, repository: nil, tag: nil)
|
70
|
+
def upload_yum_component(filename:, directory:, repository: nil, tag: nil, upstream_filename: nil)
|
71
71
|
repository ||= @team_config.yum_repository
|
72
72
|
parameters = {
|
73
73
|
'yum.directory' => directory,
|
74
|
-
'yum.asset' => File.open(filename, 'r'),
|
74
|
+
'yum.asset' => File.open(upstream_filename || filename, 'r'),
|
75
75
|
'yum.asset.filename' => filename.split('/').last,
|
76
76
|
}
|
77
77
|
parameters['yum.tag'] = tag if tag
|
data/lib/nexus_api.rb
CHANGED
@@ -11,17 +11,17 @@ require 'pry'
|
|
11
11
|
# https://[NEXUS_URL]/#admin/system/api
|
12
12
|
module NexusAPI
|
13
13
|
class API
|
14
|
-
attr_accessor :connection
|
15
|
-
attr_accessor :docker
|
16
|
-
attr_accessor :team_config
|
14
|
+
attr_accessor :protocol, :connection, :docker, :team_config
|
17
15
|
|
18
16
|
TEAM_CONFIG = File.join(File.dirname(__dir__), 'team_configs/default.yaml').freeze
|
19
17
|
|
20
|
-
def initialize(username:, password:, hostname:, docker_pull_hostname: nil, docker_push_hostname: nil, team_config: nil)
|
18
|
+
def initialize(username:, password:, hostname:, docker_pull_hostname: nil, docker_push_hostname: nil, team_config: nil, protocol: "https")
|
19
|
+
@protocol = protocol
|
21
20
|
@connection = NexusAPI::NexusConnection.new(
|
22
21
|
username: username,
|
23
22
|
password: password,
|
24
23
|
hostname: hostname,
|
24
|
+
protocol: protocol,
|
25
25
|
)
|
26
26
|
if docker_pull_hostname.nil? || docker_push_hostname.nil?
|
27
27
|
@docker = nil
|
@@ -9,10 +9,11 @@ module NexusAPI
|
|
9
9
|
|
10
10
|
attr_accessor :continuation_token
|
11
11
|
|
12
|
-
def initialize(username:, password:, hostname:)
|
12
|
+
def initialize(username:, password:, hostname:, protocol:)
|
13
13
|
@username = username
|
14
14
|
@password = password
|
15
15
|
@hostname = hostname
|
16
|
+
@protocol = protocol
|
16
17
|
end
|
17
18
|
|
18
19
|
def get_response(endpoint:, paginate: false, headers: {'Content-Type' => 'application/json'}, api_version: 'v1')
|
@@ -117,7 +118,7 @@ module NexusAPI
|
|
117
118
|
|
118
119
|
def send_request(connection_method, endpoint, parameters: '', headers: {}, api_version: 'v1')
|
119
120
|
parameters = parameters.to_json if headers['Content-Type'] == 'application/json'
|
120
|
-
url = "
|
121
|
+
url = "#{@protocol}://#{@hostname}/service/rest/#{api_version}/#{endpoint}"
|
121
122
|
catch_connection_error do
|
122
123
|
RestClient::Request.execute(
|
123
124
|
method: connection_method,
|
data/lib/nexus_api/version.rb
CHANGED