lex-node 0.1.2 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffaa597a2f9951699fe797d9a8059d13bfccc420989c9c323e6d6637e435441f
4
- data.tar.gz: 50d886008d780357af23b29d5db25043b89f581c03c1426f18d9df5fd83c30f3
3
+ metadata.gz: 4971e9d0d31600942d57bd7061ec7b2aa20f68a6a13b9d1835c38d978f16177c
4
+ data.tar.gz: cae71cb0d1413186f546d957b393f0139b0b5a74b8509352823480e2ef765dbc
5
5
  SHA512:
6
- metadata.gz: ced343d85f99296fa5f3c6f982cefbac7a3b40b3b902533a938421658e975e9926c5c128d2ae82b34b8595b31035a783d8601844593838d4bf55d5f8c07619aa
7
- data.tar.gz: e2f55664ffb74836e4bec48b5550557077e52784c0a7169bc2cab3201fa123d44958224ada1558e3be5f7a3a24a0cc965a9d9356a678cb7b0e7813ea3dc6df28
6
+ metadata.gz: 707b454af232927fec2984db1ce5be986ef1a53ef5ae1e54cab77ce51d212cba4ca3848cdecf767a281835fda2750443aaf19f7ab047280e2a20dcd36b08734b
7
+ data.tar.gz: 3561f7dcacf86eb7d48124691a86984d91b170f79909b52c3908f759fb887b04fea123a95897abc730d9ec8df7fa9193a50e64ef55e0257c97e173f899049ab3
data/.rubocop.yml CHANGED
@@ -11,6 +11,7 @@ Style/Documentation:
11
11
  AllCops:
12
12
  TargetRubyVersion: 2.5
13
13
  NewCops: enable
14
+ SuggestExtensions: false
14
15
  Style/FrozenStringLiteralComment:
15
16
  Enabled: false
16
17
  Naming/FileName:
data/Dockerfile ADDED
@@ -0,0 +1,9 @@
1
+ FROM legionio/legion:latest
2
+ LABEL maintainer="Matthew Iverson <matthewdiverson@gmail.com>"
3
+
4
+ RUN mkdir /etc/legionio
5
+ RUN apk update && apk add build-base tzdata gcc git
6
+
7
+ COPY . ./
8
+ RUN gem install lex-elastic_app_search --no-document --no-prerelease
9
+ CMD ruby --jit $(which legionio)
data/Gemfile.lock CHANGED
@@ -1,114 +1,106 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lex-node (0.1.2)
4
+ lex-node (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  amq-protocol (2.3.2)
10
- ast (2.4.1)
10
+ ast (2.4.2)
11
11
  aws-eventstream (1.1.0)
12
12
  aws-sigv4 (1.2.2)
13
13
  aws-eventstream (~> 1, >= 1.0.2)
14
14
  bunny (2.17.0)
15
15
  amq-protocol (~> 2.3, >= 2.3.1)
16
- concurrent-ruby (1.1.7)
17
- concurrent-ruby-ext (1.1.7)
18
- concurrent-ruby (= 1.1.7)
16
+ concurrent-ruby (1.1.8)
17
+ concurrent-ruby-ext (1.1.8)
18
+ concurrent-ruby (= 1.1.8)
19
19
  connection_pool (2.2.3)
20
20
  daemons (1.3.1)
21
21
  dalli (2.7.11)
22
22
  diff-lcs (1.4.4)
23
- docile (1.3.2)
24
- hashdiff (1.0.1)
25
- json (2.3.1)
26
- json_pure (2.3.1)
27
- legion-cache (1.0.0)
28
- connection_pool
29
- dalli
30
- redis
31
- legion-crypt (0.2.1)
32
- vault
33
- legion-data (1.1.4)
34
- legion-logging
35
- legion-settings
36
- mysql2
37
- sequel
38
- legion-exceptions (1.1.2)
39
- legion-json (1.1.2)
23
+ docile (1.3.5)
24
+ json (2.5.1)
25
+ json_pure (2.5.1)
26
+ legion-cache (1.1.1)
27
+ connection_pool (>= 2.2.3)
28
+ dalli (>= 2.7)
29
+ redis (>= 4.2)
30
+ legion-crypt (0.3.0)
31
+ vault (>= 0.15.0)
32
+ legion-exceptions (1.1.5)
33
+ legion-json (1.1.4)
40
34
  json_pure
35
+ legion-exceptions (>= 1.1.5)
41
36
  multi_json
42
- legion-logging (1.1.3)
37
+ legion-logging (1.1.4)
43
38
  rainbow (~> 3)
44
- legion-settings (1.1.2)
39
+ legion-settings (1.1.3)
45
40
  legion-json
46
41
  legion-logging
47
- legion-transport (1.1.5)
48
- bunny
49
- concurrent-ruby
42
+ legion-transport (1.1.9)
43
+ bunny (>= 2.17.0)
44
+ concurrent-ruby (>= 1.1.7)
50
45
  legion-json
51
- legionio (0.3.4)
52
- bunny
53
- concurrent-ruby
54
- concurrent-ruby-ext
55
- daemons
56
- hashdiff
46
+ legionio (0.4.3)
47
+ concurrent-ruby (>= 1.1.7)
48
+ concurrent-ruby-ext (>= 1.1.7)
49
+ daemons (>= 1.3.1)
57
50
  legion-cache
58
- legion-crypt
59
- legion-data
51
+ legion-crypt (>= 0.2.0)
60
52
  legion-exceptions
61
53
  legion-json
62
54
  legion-logging
63
55
  legion-settings
64
- legion-transport
56
+ legion-transport (>= 1.1.9)
65
57
  lex-node
66
- oj
58
+ oj (>= 3.10)
59
+ thor (>= 1)
67
60
  multi_json (1.15.0)
68
- mysql2 (0.5.3)
69
- oj (3.10.15)
70
- parallel (1.19.2)
71
- parser (2.7.2.0)
61
+ oj (3.11.2)
62
+ parallel (1.20.1)
63
+ parser (3.0.0.0)
72
64
  ast (~> 2.4.1)
73
65
  rainbow (3.0.0)
74
- rake (13.0.1)
75
- redis (4.2.2)
76
- regexp_parser (1.8.2)
66
+ rake (13.0.3)
67
+ redis (4.2.5)
68
+ regexp_parser (2.1.1)
77
69
  rexml (3.2.4)
78
- rspec (3.9.0)
79
- rspec-core (~> 3.9.0)
80
- rspec-expectations (~> 3.9.0)
81
- rspec-mocks (~> 3.9.0)
82
- rspec-core (3.9.3)
83
- rspec-support (~> 3.9.3)
84
- rspec-expectations (3.9.2)
70
+ rspec (3.10.0)
71
+ rspec-core (~> 3.10.0)
72
+ rspec-expectations (~> 3.10.0)
73
+ rspec-mocks (~> 3.10.0)
74
+ rspec-core (3.10.1)
75
+ rspec-support (~> 3.10.0)
76
+ rspec-expectations (3.10.1)
85
77
  diff-lcs (>= 1.2.0, < 2.0)
86
- rspec-support (~> 3.9.0)
87
- rspec-mocks (3.9.1)
78
+ rspec-support (~> 3.10.0)
79
+ rspec-mocks (3.10.2)
88
80
  diff-lcs (>= 1.2.0, < 2.0)
89
- rspec-support (~> 3.9.0)
90
- rspec-support (3.9.3)
81
+ rspec-support (~> 3.10.0)
82
+ rspec-support (3.10.2)
91
83
  rspec_junit_formatter (0.4.1)
92
84
  rspec-core (>= 2, < 4, != 2.12.0)
93
- rubocop (1.0.0)
85
+ rubocop (1.11.0)
94
86
  parallel (~> 1.10)
95
- parser (>= 2.7.1.5)
87
+ parser (>= 3.0.0.0)
96
88
  rainbow (>= 2.2.2, < 4.0)
97
- regexp_parser (>= 1.8)
89
+ regexp_parser (>= 1.8, < 3.0)
98
90
  rexml
99
- rubocop-ast (>= 0.6.0)
91
+ rubocop-ast (>= 1.2.0, < 2.0)
100
92
  ruby-progressbar (~> 1.7)
101
- unicode-display_width (>= 1.4.0, < 2.0)
102
- rubocop-ast (1.0.0)
93
+ unicode-display_width (>= 1.4.0, < 3.0)
94
+ rubocop-ast (1.4.1)
103
95
  parser (>= 2.7.1.5)
104
- ruby-progressbar (1.10.1)
105
- sequel (5.37.0)
96
+ ruby-progressbar (1.11.0)
106
97
  simplecov (0.17.1)
107
98
  docile (~> 1.1)
108
99
  json (>= 1.8, < 3)
109
100
  simplecov-html (~> 0.10.0)
110
101
  simplecov-html (0.10.2)
111
- unicode-display_width (1.7.0)
102
+ thor (1.1.0)
103
+ unicode-display_width (2.0.0)
112
104
  vault (0.15.0)
113
105
  aws-sigv4
114
106
 
@@ -1,4 +1,4 @@
1
- image: ruby:2.7.0
1
+ image: ruby:2.7
2
2
 
3
3
  pipelines:
4
4
  tags:
@@ -7,11 +7,13 @@ pipelines:
7
7
  name: Push to RubyGems
8
8
  deployment: RubyGems
9
9
  script:
10
- - gem install bundler gem-release rake rspec
11
- - bundle install
12
- - rake build
13
- - mkdir .gem
14
- - (umask 077 ; echo $gem_creds | base64 --decode > .gem/credentials)
10
+ - gem install gem-release
11
+ - (umask 077 ; echo $gem_creds | base64 --decode > ~/.gem/credentials)
15
12
  - gem release
16
13
  artifacts:
17
- - pkg/**
14
+ - pkg/**
15
+ - step:
16
+ name: Push to Docker
17
+ deployment: Docker
18
+ script:
19
+ - './docker_deploy.rb'
data/docker_deploy.rb ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ name = 'node'
4
+ require "./lib/legion/extensions/#{name}/version"
5
+ version = Legion::Extensions::Node::VERSION
6
+
7
+ puts "Building docker image for Legion v#{version}"
8
+ system("docker build --tag legionio/lex-#{name}:v#{version} .")
9
+ puts 'Pushing to hub.docker.com'
10
+ system("docker push legionio/lex-#{name}:v#{version}")
11
+ system("docker tag legionio/lex-#{name}:v#{version} legionio/lex-#{name}:latest")
12
+ system("docker push legionio/lex-#{name}:latest")
13
+ puts 'completed'
data/lex-node.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
 
9
9
  spec.summary = 'Does Legion Node things'
10
10
  spec.description = 'This lex is responsible for sending heartbeats, and allowing for dynamic confgs'
11
- spec.homepage = 'https://bitbucket.org/legion-io/lex-node/CHANGELOG.md'
11
+ spec.homepage = 'https://bitbucket.org/legion-io/lex-node/'
12
12
  spec.license = 'MIT'
13
13
  spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
14
14
 
@@ -21,7 +21,7 @@ module Legion::Extensions::Node::Actor
21
21
  end
22
22
 
23
23
  def time
24
- 10
24
+ settings['beat_interval']
25
25
  end
26
26
  end
27
27
  end
@@ -0,0 +1,27 @@
1
+ module Legion::Extensions::Node::Actor
2
+ class Vault < Legion::Extensions::Actors::Subscription
3
+ # def delay_start
4
+ # 2
5
+ # end
6
+
7
+ def runner_class
8
+ Legion::Extensions::Node::Runners::Vault
9
+ end
10
+
11
+ def disabled?
12
+ false
13
+ end
14
+
15
+ def use_runner?
16
+ true
17
+ end
18
+
19
+ def check_subtask?
20
+ false
21
+ end
22
+
23
+ def generate_task?
24
+ false
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ module Legion::Extensions::Node::Actor
2
+ class VaultTokenRequest < Legion::Extensions::Actors::Once
3
+ def runner_function
4
+ 'request_token'
5
+ end
6
+
7
+ def runner_class
8
+ Legion::Extensions::Node::Runners::Vault
9
+ end
10
+
11
+ def use_runner?
12
+ false
13
+ end
14
+
15
+ def check_subtask?
16
+ false
17
+ end
18
+
19
+ def generate_task?
20
+ false
21
+ end
22
+
23
+ def delay
24
+ 0
25
+ end
26
+ end
27
+ end
@@ -24,7 +24,7 @@ module Legion::Extensions::Node::Runners
24
24
  def request_public_keys(**_opts)
25
25
  log.debug 'request_public_keys'
26
26
  message_hash = { function: 'push_public_key' }
27
- Legion::Extensions::Node::Transport::Messages::RequestPublicKeys.new(message_hash).publish
27
+ Legion::Extensions::Node::Transport::Messages::RequestPublicKeys.new(**message_hash).publish
28
28
  {}
29
29
  end
30
30
 
@@ -21,7 +21,7 @@ module Legion::Extensions::Node::Runners
21
21
  message_hash = { function: 'update_public_key',
22
22
  public_key: Legion::Crypt.public_key.to_s,
23
23
  **Legion::Settings[:client] }
24
- Legion::Extensions::Node::Transport::Messages::PublicKey.new(message_hash).publish
24
+ Legion::Extensions::Node::Transport::Messages::PublicKey.new(**message_hash).publish
25
25
  {}
26
26
  end
27
27
 
@@ -51,6 +51,11 @@ module Legion::Extensions::Node::Runners
51
51
  {}
52
52
  end
53
53
 
54
+ def receive_vault_token(message:, routing_key:, public_key:, **)
55
+ Legion::Extensions::Node::Runners::Vault.receive_vault_token(message: message, routing_key: routing_key,
56
+ public_key: public_key)
57
+ end
58
+
54
59
  include Legion::Extensions::Helpers::Lex
55
60
  end
56
61
  end
@@ -0,0 +1,40 @@
1
+ module Legion::Extensions::Node::Runners
2
+ module Vault
3
+ def request_token(**)
4
+ return {} if Legion::Settings[:crypt][:vault][:connected]
5
+ return {} unless Legion::Settings[:crypt][:vault][:enabled]
6
+
7
+ request_vault_token
8
+ end
9
+
10
+ def request_vault_token(**)
11
+ Legion::Extensions::Node::Transport::Messages::RequestVaultToken.new.publish
12
+ {}
13
+ end
14
+
15
+ def receive_vault_token(message:, **opts) # rubocop:disable Metrics/AbcSize
16
+ return if Legion::Settings[:crypt][:vault][:connected]
17
+
18
+ Legion::Settings[:crypt][:vault][:token] = Legion::Crypt.decrypt_from_keypair(message: message)
19
+ %i[protocol address port].each do |setting|
20
+ next unless opts.key? setting
21
+ next unless Legion::Settings[:crypt][:vault][setting].nil?
22
+
23
+ Legion::Settings[:crypt][:vault][setting] = opts[setting]
24
+ end
25
+ Legion::Crypt.connect_vault
26
+ {}
27
+ end
28
+
29
+ def push_vault_token(public_key:, node_name:, **)
30
+ return {} unless Legion::Settings[:crypt][:vault][:token]
31
+
32
+ encrypted = Legion::Crypt.encrypt_from_keypair(message: Legion::Settings[:crypt][:vault][:token],
33
+ pub_key: public_key)
34
+ Legion::Extensions::Node::Transport::Messages::PushVaultToken.new(token: encrypted, queue_name: node_name).publish
35
+ {}
36
+ end
37
+
38
+ include Legion::Extensions::Helpers::Lex
39
+ end
40
+ end
@@ -1,3 +1,5 @@
1
+ require 'legion/transport/exchanges/node'
2
+
1
3
  module Legion::Extensions::Node
2
4
  module Transport
3
5
  module Exchanges
@@ -0,0 +1,35 @@
1
+ module Legion::Extensions::Node::Transport::Messages
2
+ class PushVaultToken < Legion::Transport::Message
3
+ def routing_key
4
+ "node.#{@options[:queue_name]}"
5
+ end
6
+
7
+ def exchange
8
+ Legion::Transport::Exchanges::Node
9
+ end
10
+
11
+ def message
12
+ data =
13
+ { function: 'receive_vault_token',
14
+ runner_class: 'Legion::Extensions::Node::Runners::Vault',
15
+ message: @options[:token],
16
+ public_key: Base64.encode64(Legion::Crypt.public_key) }
17
+
18
+ Legion::Logging.unknown data
19
+ Legion::Logging.unknown routing_key
20
+ data
21
+ end
22
+
23
+ def type
24
+ 'task'
25
+ end
26
+
27
+ def encrypt?
28
+ false
29
+ end
30
+
31
+ def validate
32
+ @valid = true
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,28 @@
1
+ module Legion::Extensions::Node::Transport::Messages
2
+ class RequestVaultToken < Legion::Transport::Message
3
+ def routing_key
4
+ 'vault'
5
+ end
6
+
7
+ def message
8
+ {
9
+ function: 'push_vault_token',
10
+ node_name: Legion::Settings[:client][:name],
11
+ runner_class: 'Legion::Extensions::Node::Runners::Vault',
12
+ public_key: Legion::Crypt.public_key
13
+ }
14
+ end
15
+
16
+ def type
17
+ 'task'
18
+ end
19
+
20
+ def encrypt?
21
+ false
22
+ end
23
+
24
+ def validate
25
+ @valid = true
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ module Legion::Extensions::Node::Transport::Queues
2
+ class Vault < Legion::Transport::Queue
3
+ def queue_options
4
+ { auto_delete: false }
5
+ end
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
1
  module Legion
2
2
  module Extensions
3
3
  module Node
4
- VERSION = '0.1.2'.freeze
4
+ VERSION = '0.1.7'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-node
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-23 00:00:00.000000000 Z
11
+ date: 2021-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: legionio
@@ -106,44 +106,50 @@ files:
106
106
  - ".gitignore"
107
107
  - ".rspec"
108
108
  - ".rubocop.yml"
109
+ - Dockerfile
109
110
  - Gemfile
110
111
  - Gemfile.lock
111
112
  - LICENSE.txt
112
113
  - README.md
113
114
  - Rakefile
114
- - bin/console
115
- - bin/setup
116
115
  - bitbucket-pipelines.yml
116
+ - docker_deploy.rb
117
117
  - lex-node.gemspec
118
118
  - lib/legion/extensions/node.rb
119
119
  - lib/legion/extensions/node/actors/beat.rb
120
120
  - lib/legion/extensions/node/actors/crypt.rb
121
121
  - lib/legion/extensions/node/actors/push_key.rb
122
+ - lib/legion/extensions/node/actors/vault.rb
123
+ - lib/legion/extensions/node/actors/vault_token_request.rb
122
124
  - lib/legion/extensions/node/runners/beat.rb
123
125
  - lib/legion/extensions/node/runners/crypt.rb
124
126
  - lib/legion/extensions/node/runners/node.rb
127
+ - lib/legion/extensions/node/runners/vault.rb
125
128
  - lib/legion/extensions/node/transport.rb
126
129
  - lib/legion/extensions/node/transport/exchanges/node.rb
127
130
  - lib/legion/extensions/node/transport/messages/beat.rb
128
131
  - lib/legion/extensions/node/transport/messages/public_key.rb
129
132
  - lib/legion/extensions/node/transport/messages/push_cluster_secret.rb
133
+ - lib/legion/extensions/node/transport/messages/push_vault_token.rb
130
134
  - lib/legion/extensions/node/transport/messages/request_cluster_secret.rb
131
135
  - lib/legion/extensions/node/transport/messages/request_public_keys.rb
136
+ - lib/legion/extensions/node/transport/messages/request_vault_token.rb
132
137
  - lib/legion/extensions/node/transport/queues/crypt.rb
133
138
  - lib/legion/extensions/node/transport/queues/health.rb
134
139
  - lib/legion/extensions/node/transport/queues/node.rb
140
+ - lib/legion/extensions/node/transport/queues/vault.rb
135
141
  - lib/legion/extensions/node/version.rb
136
142
  - sonar-project.properties
137
- homepage: https://bitbucket.org/legion-io/lex-node/CHANGELOG.md
143
+ homepage: https://bitbucket.org/legion-io/lex-node/
138
144
  licenses:
139
145
  - MIT
140
146
  metadata:
141
- homepage_uri: https://bitbucket.org/legion-io/lex-node/CHANGELOG.md
147
+ homepage_uri: https://bitbucket.org/legion-io/lex-node/
142
148
  source_code_uri: https://bitbucket.org/legion-io/lex-node
143
149
  documentation_uri: https://legionio.atlassian.net/wiki/spaces/LEX/pages/612139025
144
150
  changelog_uri: https://legionio.atlassian.net/wiki/spaces/LEX/pages/612139042/
145
151
  bug_tracker_uri: https://bitbucket.org/legion-io/lex-node/issues
146
- post_install_message:
152
+ post_install_message:
147
153
  rdoc_options: []
148
154
  require_paths:
149
155
  - lib
@@ -158,8 +164,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
164
  - !ruby/object:Gem::Version
159
165
  version: '0'
160
166
  requirements: []
161
- rubygems_version: 3.1.2
162
- signing_key:
167
+ rubygems_version: 3.1.4
168
+ signing_key:
163
169
  specification_version: 4
164
170
  summary: Does Legion Node things
165
171
  test_files: []
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'legion/extensions/node'
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require 'irb'
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here