nexus_cli 1.0.2 → 2.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.
- data/.gitignore +4 -1
- data/.travis.yml +5 -0
- data/Gemfile +40 -0
- data/Guardfile +27 -0
- data/README.md +20 -23
- data/Thorfile +66 -0
- data/VERSION +1 -1
- data/{pro → features/pro}/nexus_custom_metadata.feature +0 -0
- data/{pro → features/pro}/nexus_pro.feature +0 -0
- data/features/support/env.rb +41 -32
- data/lib/nexus_cli.rb +26 -10
- data/lib/nexus_cli/base_remote.rb +32 -0
- data/lib/nexus_cli/configuration.rb +24 -5
- data/lib/nexus_cli/connection.rb +81 -0
- data/lib/nexus_cli/mixins/artifact_actions.rb +186 -0
- data/lib/nexus_cli/mixins/global_settings_actions.rb +64 -0
- data/lib/nexus_cli/mixins/logging_actions.rb +45 -0
- data/lib/nexus_cli/{nexus_pro_remote.rb → mixins/pro/custom_metadata_actions.rb} +5 -199
- data/lib/nexus_cli/mixins/pro/smart_proxy_actions.rb +214 -0
- data/lib/nexus_cli/mixins/repository_actions.rb +245 -0
- data/lib/nexus_cli/mixins/user_actions.rb +125 -0
- data/lib/nexus_cli/remote/oss_remote.rb +11 -0
- data/lib/nexus_cli/remote/pro_remote.rb +59 -0
- data/lib/nexus_cli/remote_factory.rb +24 -0
- data/lib/nexus_cli/tasks.rb +3 -3
- data/spec/fixtures/nexus.config +4 -0
- data/spec/spec_helper.rb +14 -2
- data/spec/{configuration_spec.rb → unit/nexus_cli/configuration_spec.rb} +0 -0
- data/spec/{oss_remote_spec.rb → unit/nexus_cli/oss_remote_spec.rb} +15 -5
- data/spec/{pro_remote_spec.rb → unit/nexus_cli/pro_remote_spec.rb} +6 -1
- metadata +32 -17
- data/Gemfile.lock +0 -65
- data/lib/nexus_cli/kernel.rb +0 -33
- data/lib/nexus_cli/nexus_oss_remote.rb +0 -636
- data/lib/nexus_cli/nexus_remote_factory.rb +0 -65
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'httpclient'
|
2
|
-
require 'nokogiri'
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
module NexusCli
|
6
|
-
class Factory
|
7
|
-
class << self
|
8
|
-
def create(overrides, ssl_verify=true)
|
9
|
-
@configuration = Configuration::parse(overrides)
|
10
|
-
@ssl_verify = ssl_verify
|
11
|
-
running_nexus_pro? ? ProRemote.new(overrides, ssl_verify) : OSSRemote.new(overrides, ssl_verify)
|
12
|
-
end
|
13
|
-
|
14
|
-
def configuration
|
15
|
-
return @configuration if @configuration
|
16
|
-
end
|
17
|
-
|
18
|
-
def nexus
|
19
|
-
client = HTTPClient.new
|
20
|
-
# https://github.com/nahi/httpclient/issues/63
|
21
|
-
client.set_auth(nil, configuration['username'], configuration['password'])
|
22
|
-
client.www_auth.basic_auth.challenge(configuration['url'])
|
23
|
-
client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @ssl_verify
|
24
|
-
return client
|
25
|
-
end
|
26
|
-
|
27
|
-
def nexus_url(url)
|
28
|
-
File.join(configuration['url'], url)
|
29
|
-
end
|
30
|
-
|
31
|
-
def status
|
32
|
-
begin
|
33
|
-
response = nexus.get(nexus_url("service/local/status"))
|
34
|
-
rescue OpenSSL::SSL::SSLError => e
|
35
|
-
raise SSLException
|
36
|
-
end
|
37
|
-
|
38
|
-
case response.status
|
39
|
-
when 200
|
40
|
-
doc = Nokogiri::XML(response.content).xpath("/status/data")
|
41
|
-
data = Hash.new
|
42
|
-
data['app_name'] = doc.xpath("appName")[0].text
|
43
|
-
data['version'] = doc.xpath("version")[0].text
|
44
|
-
data['edition_long'] = doc.xpath("editionLong")[0].text
|
45
|
-
data['state'] = doc.xpath("state")[0].text
|
46
|
-
data['started_at'] = doc.xpath("startedAt")[0].text
|
47
|
-
data['base_url'] = doc.xpath("baseUrl")[0].text
|
48
|
-
return data
|
49
|
-
when 401
|
50
|
-
raise PermissionsException
|
51
|
-
when 503
|
52
|
-
raise CouldNotConnectToNexusException
|
53
|
-
else
|
54
|
-
raise UnexpectedStatusCodeException.new(response.status)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def running_nexus_pro?
|
61
|
-
return status['edition_long'] == "Professional" ? true : false
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|