lamby 4.3.3 → 5.0.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 +9 -0
- data/Gemfile.lock +3 -1
- data/lamby.gemspec +1 -0
- data/lib/lamby/config.rb +1 -1
- data/lib/lamby/handler.rb +2 -12
- data/lib/lamby/version.rb +1 -1
- data/lib/lamby.rb +1 -2
- metadata +16 -4
- data/lib/lamby/command.rb +0 -43
- data/lib/lamby/runner.rb +0 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bed40f788bb3ef9eecb63040924c583bee423ac369179f76aa5fe43fe797e3ec
|
4
|
+
data.tar.gz: 7fd33a98bb6cd19b202a16ef58f5a03f7f7e1e21f75e6342330b318ebb260bed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dca95a577c3afbcb3fbcb9715e54987b04cd830abeda28ac9c4df82f088a50ea866ce8a6f19212e003d80cb3d88c37370393e79c69f9f023c34ae81f967f8d5
|
7
|
+
data.tar.gz: d795ac32b599d239ad6ccfde9da12e88b79bfcff854766c77c0630ca69acbaac9f2cbd5e5c56ee9eb48c46b70bd4d683b67fc7dbf1c2cef61c6dbf0f42a81728
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
See this http://keepachangelog.com link for information on how we want this documented formatted.
|
4
4
|
|
5
|
+
## v5.0.0
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
- ⚠️ Breaking Changes ⚠️
|
10
|
+
- Remove Lamby::Runner & Lamby::Command in favor of LambdaConsole Ruby gem.
|
11
|
+
- New runner pattern exceptions from above. Now: LambdaConsole::Run::UnknownCommandPattern
|
12
|
+
- Switch your own runner events to new https://github.com/rails-lambda/lambda-console spec.
|
13
|
+
|
5
14
|
## v4.3.1, v4.3.2
|
6
15
|
|
7
16
|
### Changed
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lamby (
|
4
|
+
lamby (5.0.0)
|
5
|
+
lambda-console-ruby
|
5
6
|
rack
|
6
7
|
|
7
8
|
GEM
|
@@ -98,6 +99,7 @@ GEM
|
|
98
99
|
i18n (1.12.0)
|
99
100
|
concurrent-ruby (~> 1.0)
|
100
101
|
jmespath (1.6.2)
|
102
|
+
lambda-console-ruby (1.0.0)
|
101
103
|
lambdakiq (2.2.0)
|
102
104
|
activejob
|
103
105
|
aws-sdk-sqs
|
data/lamby.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
spec.add_dependency 'rack'
|
22
|
+
spec.add_dependency 'lambda-console-ruby'
|
22
23
|
spec.add_development_dependency 'aws-sdk-ssm'
|
23
24
|
spec.add_development_dependency 'bundler'
|
24
25
|
spec.add_development_dependency 'rake'
|
data/lib/lamby/config.rb
CHANGED
data/lib/lamby/handler.rb
CHANGED
@@ -92,10 +92,8 @@ module Lamby
|
|
92
92
|
Lambdakiq.cmd event: @event, context: @context
|
93
93
|
elsif lambda_cable?
|
94
94
|
LambdaCable.cmd event: @event, context: @context
|
95
|
-
elsif
|
96
|
-
|
97
|
-
elsif runner?
|
98
|
-
Lamby::Runner.cmd event: @event, context: @context
|
95
|
+
elsif LambdaConsole.handle?(@event)
|
96
|
+
LambdaConsole.handle(@event)
|
99
97
|
elsif event_bridge?
|
100
98
|
Lamby.config.event_bridge_handler.call @event, @context
|
101
99
|
else
|
@@ -121,14 +119,6 @@ module Lamby
|
|
121
119
|
defined?(::Lambdakiq) && ::Lambdakiq.jobs?(@event)
|
122
120
|
end
|
123
121
|
|
124
|
-
def runner?
|
125
|
-
Lamby::Runner.handle?(@event)
|
126
|
-
end
|
127
|
-
|
128
|
-
def command?
|
129
|
-
Lamby::Command.handle?(@event)
|
130
|
-
end
|
131
|
-
|
132
122
|
def lambda_cable?
|
133
123
|
defined?(::LambdaCable) && ::LambdaCable.handle?(@event, @context)
|
134
124
|
end
|
data/lib/lamby/version.rb
CHANGED
data/lib/lamby.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'lamby/logger'
|
2
2
|
require 'rack'
|
3
3
|
require 'base64'
|
4
|
+
require 'lambda-console-ruby'
|
4
5
|
require 'lamby/version'
|
5
6
|
require 'lamby/config'
|
6
7
|
require 'lamby/rack'
|
@@ -8,8 +9,6 @@ require 'lamby/rack_alb'
|
|
8
9
|
require 'lamby/rack_rest'
|
9
10
|
require 'lamby/rack_http'
|
10
11
|
require 'lamby/debug'
|
11
|
-
require 'lamby/runner'
|
12
|
-
require 'lamby/command'
|
13
12
|
require 'lamby/handler'
|
14
13
|
|
15
14
|
if defined?(Rails)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lamby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Collins
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: lambda-console-ruby
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: aws-sdk-ssm
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -163,7 +177,6 @@ files:
|
|
163
177
|
- images/social2.png
|
164
178
|
- lamby.gemspec
|
165
179
|
- lib/lamby.rb
|
166
|
-
- lib/lamby/command.rb
|
167
180
|
- lib/lamby/config.rb
|
168
181
|
- lib/lamby/debug.rb
|
169
182
|
- lib/lamby/handler.rb
|
@@ -175,7 +188,6 @@ files:
|
|
175
188
|
- lib/lamby/rack_http.rb
|
176
189
|
- lib/lamby/rack_rest.rb
|
177
190
|
- lib/lamby/railtie.rb
|
178
|
-
- lib/lamby/runner.rb
|
179
191
|
- lib/lamby/ssm_parameter_store.rb
|
180
192
|
- lib/lamby/tasks.rake
|
181
193
|
- lib/lamby/version.rb
|
data/lib/lamby/command.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
module Lamby
|
2
|
-
class Command
|
3
|
-
|
4
|
-
class << self
|
5
|
-
|
6
|
-
def handle?(event)
|
7
|
-
event.dig('x-lambda-console', 'command') ||
|
8
|
-
event.dig('lamby', 'command')
|
9
|
-
end
|
10
|
-
|
11
|
-
def cmd(event:, context:)
|
12
|
-
new(event).call
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
def initialize(event)
|
18
|
-
@event = event
|
19
|
-
@body = ''
|
20
|
-
end
|
21
|
-
|
22
|
-
def call
|
23
|
-
begin
|
24
|
-
body = eval(command, TOPLEVEL_BINDING).inspect
|
25
|
-
{ statusCode: 200, headers: {}, body: body }
|
26
|
-
rescue Exception => e
|
27
|
-
body = "#<#{e.class}:#{e.message}>".tap do |b|
|
28
|
-
if e.backtrace
|
29
|
-
b << "\n"
|
30
|
-
b << e.backtrace.join("\n")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
{ statusCode: 422, headers: {}, body: body }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def command
|
38
|
-
@event.dig('x-lambda-console', 'command') ||
|
39
|
-
@event.dig('lamby', 'command')
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
data/lib/lamby/runner.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'open3'
|
2
|
-
|
3
|
-
module Lamby
|
4
|
-
class Runner
|
5
|
-
class Error < StandardError ; end
|
6
|
-
class UnknownCommandPattern < Error ; end
|
7
|
-
|
8
|
-
PATTERNS = [%r{.*}]
|
9
|
-
|
10
|
-
class << self
|
11
|
-
|
12
|
-
def handle?(event)
|
13
|
-
event.dig('x-lambda-console', 'runner') ||
|
14
|
-
event.dig('lamby', 'runner')
|
15
|
-
end
|
16
|
-
|
17
|
-
def cmd(event:, context:)
|
18
|
-
new(event).call
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def initialize(event)
|
24
|
-
@event = event
|
25
|
-
@body = ''
|
26
|
-
end
|
27
|
-
|
28
|
-
def call
|
29
|
-
validate!
|
30
|
-
status = Open3.popen3(env, command, chdir: chdir) do |_stdin, stdout, stderr, thread|
|
31
|
-
@body << stdout.read
|
32
|
-
@body << stderr.read
|
33
|
-
puts @body
|
34
|
-
thread.value.exitstatus
|
35
|
-
end
|
36
|
-
{ statusCode: status, headers: {}, body: @body }
|
37
|
-
end
|
38
|
-
|
39
|
-
def command
|
40
|
-
@event.dig('x-lambda-console', 'runner') ||
|
41
|
-
@event.dig('lamby', 'runner')
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def chdir
|
47
|
-
defined?(::Rails) ? ::Rails.root : Dir.pwd
|
48
|
-
end
|
49
|
-
|
50
|
-
def validate!
|
51
|
-
return if pattern?
|
52
|
-
raise UnknownCommandPattern.new(command)
|
53
|
-
end
|
54
|
-
|
55
|
-
def pattern?
|
56
|
-
PATTERNS.any? { |p| p === command }
|
57
|
-
end
|
58
|
-
|
59
|
-
def env
|
60
|
-
Hash[ENV.to_hash.map { |k,v| [k, ENV[k]] }]
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|