lex-node 0.1.3 → 0.1.4

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: fb5d86c4803b06a34c29d846eba9261050c63f20943e29d1c0a523b9a4b243d0
4
- data.tar.gz: 828cd9e8d8552ae2af5843cfe7d71a6d0cd9e22ed789e22765074a0d1fd0263f
3
+ metadata.gz: e6a9351a22dd6d43b490130d2ff7ad89a3406eb73c940f61dcc9ab17ff493c52
4
+ data.tar.gz: 3705b5af7c9bec277d1240b038cdc1f362938db4fb985dff586eb78e89391950
5
5
  SHA512:
6
- metadata.gz: 27086e2c3f5fa7839e2bd50602dca02cb757c745b909a915ed18d57cb4b6d2169d6e96dcd203e3e0f729103fad924d6273eda1aa9b33871dd6c80e7d9538dcf9
7
- data.tar.gz: 6c107540d0cddb8a3c897c1e526866a5ed31be0da73c5676ffa9da9aa5fd47c7a6471336d0171f3d39304f474256a1ed2fce9109a6ad68d2b9ac47d8b299c24a
6
+ metadata.gz: 9bc088e5128fb88a1ba84fa76097f57cb2b259523ce35732f26e5934f826b743862ba8ce37528276386634cd9457e90a3b4d9df472d7af7e3c816e6672ab804f
7
+ data.tar.gz: ced216b535743533b36e2780b2f20d09243de4113ffcd9053904d5fe98058bdf91c0df64b25470c8286a427089f0fd8fb2c191d3c640ae49ef8de36f13386fa8
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.3)
4
+ lex-node (0.1.4)
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)
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.2.3)
32
31
  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)
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.2)
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.3)
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.4)
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.1)
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,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ version = Legion::Extensions::ElasticAppSearch::VERSION
4
+ name = 'elastic_app_search'
5
+
6
+ require "./lib/legion/extensions/#{name}/version"
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 push legionio/lex-#{name}:latest")
12
+ 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,11 @@ module Legion::Extensions::Node::Actor
21
21
  end
22
22
 
23
23
  def time
24
- 10
24
+ settings['beat_interval']
25
+ end
26
+
27
+ def enabled?
28
+ settings['actor'] || false
25
29
  end
26
30
  end
27
31
  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
@@ -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
@@ -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.3'.freeze
4
+ VERSION = '0.1.4'.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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-24 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,39 +106,45 @@ 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/
@@ -158,7 +164,7 @@ 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
167
+ rubygems_version: 3.2.6
162
168
  signing_key:
163
169
  specification_version: 4
164
170
  summary: Does Legion Node things
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