lita-nexus 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/README.md +38 -0
- data/Rakefile +6 -0
- data/lib/lita/handlers/nexus.rb +81 -0
- data/lib/lita-nexus.rb +13 -0
- data/lib/nexushelper/remote.rb +63 -0
- data/lita-nexus.gemspec +27 -0
- data/locales/en.yml +12 -0
- data/spec/lita/handlers/nexus_spec.rb +56 -0
- data/spec/spec_helper.rb +13 -0
- data/templates/.gitkeep +0 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3c8a79d0b2356abe6e12efc085737f6a3e4a566a
|
4
|
+
data.tar.gz: 4af234a72604fb1ad747ebd080350cf6a9a80541
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3921ae3d9fc07d5d43b7c2908a7953088a916d9ca5565b2206b8fd3d4e8df531ca766f98b41102fc0d114eec7768e9fd3de3cfaf7a42f0535f8b3a3f62cf8f4b
|
7
|
+
data.tar.gz: fa1436e5e9a61be7ae2f0552a1fb8321023106b59ff7914335fd186d176efde587cf8ff32410de0d08d5515365b378e4df547599b187002c7bfb88c2b56630e0
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# lita-nexus
|
2
|
+
|
3
|
+
Lita handlers to query nexus server for artifact and repository
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add lita-nexus to your Lita instance's Gemfile:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
gem "lita-nexus"
|
11
|
+
```
|
12
|
+
|
13
|
+
## Configuration
|
14
|
+
```ruby
|
15
|
+
Lita.configure do |config|
|
16
|
+
config.handlers.nexus.url = 'https://nexus.prod.co.entpub.net/nexus/'
|
17
|
+
config.handlers.nexus.username = 'dwang_sa'
|
18
|
+
#encrypted use rsa_public_key
|
19
|
+
config.handlers.nexus.password_hash =
|
20
|
+
'Zrt3Hwo7Er4nu9Ne4r0Y6ykuxwxlmvKTrEN26G7EYw63Wtnt9K4H9e933NEZ
|
21
|
+
eaqUhjoXKYCylhZNWsSj/KDnrEflCCr4eHkFq3kwNi9fRraI3kWVoBzg0v2E
|
22
|
+
jn5sVCVgrIKG3W8p+RGKbm+HEnkNSZRKJumqJy3vtPcbgMdSlWZQPpwNP4X2
|
23
|
+
c4NnOUNVY3nmEijX1FJkGnfL3pcZlJgx60lLhhLbGnKQkLz5LdeFRbiiXaVw
|
24
|
+
acFQufgrhNN85AsKaUlDp/n8ISuMB1K1nGVdN2ZYByf1aKVYwnIWdj+omffz
|
25
|
+
Da2gZuDpdDWvNfYsm7o3JV6BcmsS9YgiaeiBNi0l1Q=='
|
26
|
+
config.handlers.nexus.verify_ssl = false
|
27
|
+
config.handlers.nexus.default_repository = 'entertainment'
|
28
|
+
#used to decrypt password hash
|
29
|
+
config.handlers.nexus.rsa_private_key = "#{File.expand_path('~')}/.ssh/id_rsa"
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
* nexus artifact info webapps:sweetrewards:tar.gz:1.8.0
|
36
|
+
* nexus search artifact webapps:sweetrewards
|
37
|
+
* nexus license info # only for pro version
|
38
|
+
* nexus repo info snapshots
|
data/Rakefile
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
module Lita
|
2
|
+
module Handlers
|
3
|
+
class Nexus < Handler
|
4
|
+
|
5
|
+
namespace 'Nexus'
|
6
|
+
|
7
|
+
# insert handler code here
|
8
|
+
config :url, required: true, type: String
|
9
|
+
config :username, required: true, type: String
|
10
|
+
config :password_hash, required: true, type: String
|
11
|
+
config :default_repository, required: false, type: String
|
12
|
+
config :verify_ssl, required: false, type: [TrueClass,FalseClass], default: false
|
13
|
+
config :rsa_private_key, required: true, type: String
|
14
|
+
|
15
|
+
include ::LitaNexusHelper::Remote
|
16
|
+
|
17
|
+
route(
|
18
|
+
/^nexus\s+artifact\s+info\s+(\S+)\s*$/,
|
19
|
+
:cmd_artifact_info,
|
20
|
+
command: true,
|
21
|
+
help: {
|
22
|
+
t('help.cmd_artifact_info_key') => t('help.cmd_artifact_info_value')
|
23
|
+
}
|
24
|
+
)
|
25
|
+
|
26
|
+
route(
|
27
|
+
/^nexus\s+search\s+artifact\s+(\S+)\s*$/,
|
28
|
+
:cmd_search_artifact,
|
29
|
+
command: true,
|
30
|
+
help: {
|
31
|
+
t('help.cmd_search_artifact_key') => t('help.cmd_search_artifact_value')
|
32
|
+
}
|
33
|
+
)
|
34
|
+
|
35
|
+
route(
|
36
|
+
/^nexus\s+license\s+info\s*$/,
|
37
|
+
:cmd_license_info,
|
38
|
+
command: true,
|
39
|
+
help: {
|
40
|
+
t('help.cmd_license_info_key') => t('help.cmd_license_info_value')
|
41
|
+
}
|
42
|
+
)
|
43
|
+
|
44
|
+
route(
|
45
|
+
/^nexus\s+repo\s+info\s+(\S+)\s*$/,
|
46
|
+
:cmd_repo_info,
|
47
|
+
command: true,
|
48
|
+
help: {
|
49
|
+
t('help.cmd_repo_info_key') => t('help.cmd_repo_info_value')
|
50
|
+
}
|
51
|
+
)
|
52
|
+
|
53
|
+
def cmd_artifact_info(response)
|
54
|
+
coordinate = response.matches[0][0]
|
55
|
+
puts "coordinate = #{coordinate}"
|
56
|
+
info = get_artifact_info(coordinate)
|
57
|
+
response.reply info
|
58
|
+
end
|
59
|
+
|
60
|
+
def cmd_search_artifact(response)
|
61
|
+
coordinate = response.matches[0][0]
|
62
|
+
puts "coordinate = #{coordinate}"
|
63
|
+
info = search_for_artifact(coordinate)
|
64
|
+
response.reply info
|
65
|
+
end
|
66
|
+
|
67
|
+
def cmd_license_info(response)
|
68
|
+
info = get_license_info
|
69
|
+
response.reply info
|
70
|
+
end
|
71
|
+
|
72
|
+
def cmd_repo_info(response)
|
73
|
+
repo_name = response.matches[0][0]
|
74
|
+
info = get_repository_info repo_name
|
75
|
+
response.reply info
|
76
|
+
end
|
77
|
+
|
78
|
+
Lita.register_handler(self)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/lita-nexus.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "lita"
|
2
|
+
|
3
|
+
Lita.load_locales Dir[File.expand_path(
|
4
|
+
File.join("..", "..", "locales", "*.yml"), __FILE__
|
5
|
+
)]
|
6
|
+
|
7
|
+
require 'nexushelper/remote'
|
8
|
+
require "lita/handlers/nexus"
|
9
|
+
|
10
|
+
Lita::Handlers::Nexus.template_root File.expand_path(
|
11
|
+
File.join("..", "..", "templates"),
|
12
|
+
__FILE__
|
13
|
+
)
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'nexus_cli'
|
2
|
+
require 'openssl'
|
3
|
+
require 'base64'
|
4
|
+
|
5
|
+
module LitaNexusHelper
|
6
|
+
module Remote
|
7
|
+
def nexus_remote
|
8
|
+
begin
|
9
|
+
pk_path = config.rsa_private_key
|
10
|
+
pk = OpenSSL::PKey::RSA.new File.read(pk_path)
|
11
|
+
decrypted_pass = pk.private_decrypt Base64::decode64(config.password_hash)
|
12
|
+
overrides = {
|
13
|
+
:url => config.url,
|
14
|
+
:repository => config.default_repository,
|
15
|
+
:username => config.username,
|
16
|
+
:password => decrypted_pass
|
17
|
+
}
|
18
|
+
nexus_remote ||= NexusCli::RemoteFactory.create(overrides, config.verify_ssl||false)
|
19
|
+
rescue NexusCli::NexusCliError => e
|
20
|
+
say e.message, :red
|
21
|
+
exit e.status_code
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_artifact_info(coordinate)
|
26
|
+
remote = nexus_remote
|
27
|
+
info = nil
|
28
|
+
begin
|
29
|
+
info = remote.get_artifact_info(coordinate)
|
30
|
+
rescue NexusCli::ArtifactNotFoundException => e
|
31
|
+
info = "Artifact not found"
|
32
|
+
end
|
33
|
+
#puts "info: #{info}"
|
34
|
+
info
|
35
|
+
end
|
36
|
+
|
37
|
+
def search_for_artifact(coordinate)
|
38
|
+
remote = nexus_remote
|
39
|
+
info = remote.search_for_artifacts(coordinate)
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_license_info
|
43
|
+
remote = nexus_remote
|
44
|
+
if remote.respond_to? 'get_license_info'
|
45
|
+
remote.get_license_info
|
46
|
+
else
|
47
|
+
'Only supported on professional version.'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_repository_info(coordinate)
|
52
|
+
remote = nexus_remote
|
53
|
+
info = nil
|
54
|
+
begin
|
55
|
+
info = remote.get_repository_info(coordinate)
|
56
|
+
rescue NexusCli::RepositoryNotFoundException => e
|
57
|
+
info = "Repository not found"
|
58
|
+
end
|
59
|
+
#puts "info: #{info}"
|
60
|
+
info
|
61
|
+
end
|
62
|
+
end#module Remote
|
63
|
+
end #module helper
|
data/lita-nexus.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-nexus"
|
3
|
+
spec.version = "0.1.0"
|
4
|
+
spec.authors = ["Wang, Dawei"]
|
5
|
+
spec.email = ["dwang@entertainment.com"]
|
6
|
+
spec.description = "Lita Nexus Operations"
|
7
|
+
spec.summary = "Nexus server related operations"
|
8
|
+
spec.homepage = "https://github.com/af6140/lita-nexus"
|
9
|
+
spec.license = "Apache-2.0"
|
10
|
+
spec.metadata = { "lita_plugin_type" => "handler" }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
13
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_runtime_dependency "lita", ">= 4.7"
|
18
|
+
#support ruby v 2.1.x
|
19
|
+
spec.add_runtime_dependency "rack", "~> 1.6"
|
20
|
+
spec.add_runtime_dependency "nexus_cli", "~> 4.1"
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
#spec.add_development_dependency "pry-byebug"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
#spec.add_development_dependency "rack-test"
|
26
|
+
spec.add_development_dependency "rspec", ">= 3.0.0"
|
27
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
en:
|
2
|
+
lita:
|
3
|
+
handlers:
|
4
|
+
nexus:
|
5
|
+
cmd_artifact_info_key: 'nexus artifact info COORDICNATE'
|
6
|
+
cmd_artifact_info_value: 'Show artifact info with coordinate'
|
7
|
+
cmd_license_info_key: 'nexus license info'
|
8
|
+
cmd_license_info_value: 'Show license info'
|
9
|
+
cmd_search_artifact_key: 'nexus search artifact COORDICNATE'
|
10
|
+
cmd_search_artifact_value: 'Search all versions artifact with coordinate'
|
11
|
+
cmd_repo_info_key: 'nexus repo info REPONAME'
|
12
|
+
cmd_repo_info_value: 'Show repository REPONAME info'
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::Nexus, lita_handler: true do
|
4
|
+
before do
|
5
|
+
registry.config.handlers.nexus.url = 'https://nexus.prod.co.entpub.net/nexus/'
|
6
|
+
registry.config.handlers.nexus.username = 'dwang_sa'
|
7
|
+
registry.config.handlers.nexus.password_hash =
|
8
|
+
'Zrt3Hwo7Er4nu9Ne4r0Y6ykuxwxlmvKTrEN26G7EYw63Wtnt9K4H9e933NEZ
|
9
|
+
eaqUhjoXKYCylhZNWsSj/KDnrEflCCr4eHkFq3kwNi9fRraI3kWVoBzg0v2E
|
10
|
+
jn5sVCVgrIKG3W8p+RGKbm+HEnkNSZRKJumqJy3vtPcbgMdSlWZQPpwNP4X2
|
11
|
+
c4NnOUNVY3nmEijX1FJkGnfL3pcZlJgx60lLhhLbGnKQkLz5LdeFRbiiXaVw
|
12
|
+
acFQufgrhNN85AsKaUlDp/n8ISuMB1K1nGVdN2ZYByf1aKVYwnIWdj+omffz
|
13
|
+
Da2gZuDpdDWvNfYsm7o3JV6BcmsS9YgiaeiBNi0l1Q=='
|
14
|
+
registry.config.handlers.nexus.verify_ssl = false
|
15
|
+
registry.config.handlers.nexus.default_repository = 'entertainment'
|
16
|
+
registry.config.handlers.nexus.rsa_private_key = "#{File.expand_path('~')}/.ssh/id_rsa"
|
17
|
+
end
|
18
|
+
it do
|
19
|
+
is_expected.to route_command('nexus artifact info webapps:sweetrewards:tar.gz:1.8.0').to(:cmd_artifact_info)
|
20
|
+
is_expected.to route_command('nexus license info').to(:cmd_license_info)
|
21
|
+
is_expected.to route_command('nexus repo info test').to(:cmd_repo_info)
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#get artifact info' do
|
25
|
+
it 'fecth artifact info' do
|
26
|
+
send_command('nexus artifact info webapps:sweetrewards:tar.gz:1.8.0')
|
27
|
+
puts replies
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#search artifact info' do
|
32
|
+
it 'search artifact' do
|
33
|
+
send_command('nexus search artifact webapps:sweetrewards')
|
34
|
+
puts replies
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#get license info' do
|
39
|
+
it 'fecth server license info' do
|
40
|
+
send_command('nexus license info')
|
41
|
+
puts replies
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#get repo info' do
|
46
|
+
it 'fecth repository info' do
|
47
|
+
send_command('nexus repo info snapshots')
|
48
|
+
puts replies
|
49
|
+
|
50
|
+
end
|
51
|
+
it 'show repository not found' do
|
52
|
+
send_command('nexus repo info notexist')
|
53
|
+
puts replies
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "lita-nexus"
|
2
|
+
require "lita/rspec"
|
3
|
+
|
4
|
+
# A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
|
5
|
+
# was generated with Lita 4, the compatibility mode should be left disabled.
|
6
|
+
Lita.version_3_compatibility_mode = false
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.before do
|
10
|
+
registry.register_handler(Lita::Handlers::Nexus)
|
11
|
+
#registry.register_hook(:trigger_route, Lita::Extensions::KeywordArguments)
|
12
|
+
end
|
13
|
+
end
|
data/templates/.gitkeep
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-nexus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wang, Dawei
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lita
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nexus_cli
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.0.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.0.0
|
97
|
+
description: Lita Nexus Operations
|
98
|
+
email:
|
99
|
+
- dwang@entertainment.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
108
|
+
- lib/lita-nexus.rb
|
109
|
+
- lib/lita/handlers/nexus.rb
|
110
|
+
- lib/nexushelper/remote.rb
|
111
|
+
- lita-nexus.gemspec
|
112
|
+
- locales/en.yml
|
113
|
+
- spec/lita/handlers/nexus_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
- templates/.gitkeep
|
116
|
+
homepage: https://github.com/af6140/lita-nexus
|
117
|
+
licenses:
|
118
|
+
- Apache-2.0
|
119
|
+
metadata:
|
120
|
+
lita_plugin_type: handler
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.4.3
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: Nexus server related operations
|
141
|
+
test_files:
|
142
|
+
- spec/lita/handlers/nexus_spec.rb
|
143
|
+
- spec/spec_helper.rb
|