neetodeploy 1.1.9 → 1.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +11 -6
- data/exe/console +0 -0
- data/lib/neeto_deploy/cli/addon/commands.rb +2 -2
- data/lib/neeto_deploy/cli/addon/info.rb +1 -1
- data/lib/neeto_deploy/cli/addon/scheduled_exports_settings.rb +1 -1
- data/lib/neeto_deploy/cli/dyno_console_manager.rb +31 -55
- data/lib/neeto_deploy/cli/exec/base.rb +2 -2
- data/lib/neeto_deploy/cli/logs/base.rb +34 -46
- data/lib/neeto_deploy/cli/pg/commands.rb +5 -6
- data/lib/neeto_deploy/cli/pg/console.rb +3 -26
- data/lib/neeto_deploy/cli/pg/constants.rb +2 -2
- data/lib/neeto_deploy/cli/redis/commands.rb +10 -3
- data/lib/neeto_deploy/cli/redis/console.rb +22 -0
- data/lib/neeto_deploy/cli/redis/constants.rb +4 -0
- data/lib/neeto_deploy/cli/redis/get.rb +1 -1
- data/lib/neeto_deploy/cli/redis/reset_stats.rb +1 -1
- data/lib/neeto_deploy/cli/redis/set.rb +1 -1
- data/lib/neeto_deploy/version.rb +1 -1
- data/neetodeploy.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 991f65ca44d321dc7580b71263b9436176095769a7f069f55c2edadb6f5f2532
|
4
|
+
data.tar.gz: d614216531a9ef2a3c500a3a4e54cb9a72b34144607e4ea5f0ce8c6e1afabd22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21eea9fe929b0bb2176b83ef0f547912bd2824aa3fbc28a4757a9e01cbb19ad56d7b9f658482318ee65f7c57d587d98c47abc74eae87127bd33375af46973763
|
7
|
+
data.tar.gz: 503ce18f29dc4a0bd9f4263cbd09b7f314aaf2bc3a5e95fba63b5ff1c2ec0c9193c90d59ab3625c9e77b03d659da3dd67bceabb7ed56d740491475361807f535
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
neetodeploy (1.1.
|
4
|
+
neetodeploy (1.1.11)
|
5
5
|
colorize
|
6
6
|
dotenv (~> 2.8.1)
|
7
7
|
httparty (~> 0.21.0)
|
@@ -9,7 +9,7 @@ PATH
|
|
9
9
|
terminal-table (~> 3.0.2)
|
10
10
|
thor (~> 1.3.0)
|
11
11
|
tty-spinner
|
12
|
-
websocket-client
|
12
|
+
websocket-eventmachine-client
|
13
13
|
|
14
14
|
GEM
|
15
15
|
remote: https://rubygems.org/
|
@@ -19,7 +19,7 @@ GEM
|
|
19
19
|
byebug (11.1.3)
|
20
20
|
colorize (1.1.0)
|
21
21
|
dotenv (2.8.1)
|
22
|
-
|
22
|
+
eventmachine (1.2.7)
|
23
23
|
httparty (0.21.0)
|
24
24
|
mini_mime (>= 1.0.0)
|
25
25
|
multi_xml (>= 0.5.2)
|
@@ -36,9 +36,13 @@ GEM
|
|
36
36
|
tty-cursor (~> 0.7)
|
37
37
|
unicode-display_width (2.4.2)
|
38
38
|
websocket (1.2.9)
|
39
|
-
websocket-
|
40
|
-
|
41
|
-
websocket
|
39
|
+
websocket-eventmachine-base (1.2.0)
|
40
|
+
eventmachine (~> 1.0)
|
41
|
+
websocket (~> 1.0)
|
42
|
+
websocket-native (~> 1.0)
|
43
|
+
websocket-eventmachine-client (1.3.0)
|
44
|
+
websocket-eventmachine-base (~> 1.0)
|
45
|
+
websocket-native (1.0.0)
|
42
46
|
|
43
47
|
PLATFORMS
|
44
48
|
arm64-darwin-20
|
@@ -48,6 +52,7 @@ PLATFORMS
|
|
48
52
|
DEPENDENCIES
|
49
53
|
byebug
|
50
54
|
neetodeploy!
|
55
|
+
websocket-eventmachine-client
|
51
56
|
|
52
57
|
BUNDLED WITH
|
53
58
|
2.4.8
|
data/exe/console
CHANGED
Binary file
|
@@ -9,13 +9,13 @@ module NeetoDeploy
|
|
9
9
|
module Addon
|
10
10
|
class Commands < Thor
|
11
11
|
desc "info", "Get addon informations"
|
12
|
-
option :
|
12
|
+
option :addon, type: :string, aliases: "-n", required: true, desc: "Addon name"
|
13
13
|
def info
|
14
14
|
Info.new(options).run
|
15
15
|
end
|
16
16
|
|
17
17
|
desc "scheduled_exports_enabled", "Check whether scheduled exports is enabled for an app"
|
18
|
-
option :
|
18
|
+
option :app, type: :string, aliases: "-a", required: true, desc: "App name"
|
19
19
|
def scheduled_exports_enabled
|
20
20
|
ScheduledExportsSettings.new(options).run
|
21
21
|
end
|
@@ -5,80 +5,56 @@ require "thor"
|
|
5
5
|
module NeetoDeploy
|
6
6
|
class CLI
|
7
7
|
class DynoConsoleManager < Base
|
8
|
-
|
8
|
+
attr_reader :addon_name, :kind
|
9
9
|
|
10
|
-
def initialize
|
10
|
+
def initialize(addon_name)
|
11
11
|
super()
|
12
|
-
@
|
12
|
+
@addon_name = addon_name
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def process!
|
16
16
|
start_spinner
|
17
17
|
send_console_session_request
|
18
|
-
ui.error(response) and return unless @response.success?
|
18
|
+
ui.error("\n#{@response.body}") and return unless @response.success?
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
start_console
|
21
|
+
connection_cleanup_callback
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
26
|
+
def console_executable_path
|
27
|
+
gem_spec = Gem::Specification.find_by_name("neetodeploy")
|
28
|
+
gem_dir = gem_spec.gem_dir
|
29
|
+
executable_path = File.join(gem_dir, "exe", "console")
|
29
30
|
end
|
30
31
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
cleanup = lambda do
|
37
|
-
connection_cleanup
|
38
|
-
end
|
39
|
-
|
40
|
-
@ws.on :message do |msg|
|
41
|
-
message = msg.data
|
42
|
-
if message.to_s.eql?("{\"exitCode\":0,\"signal\":0}")
|
43
|
-
cleanup.call
|
44
|
-
exit 0
|
45
|
-
end
|
46
|
-
cmd = message[0]
|
47
|
-
if cmd == "1"
|
48
|
-
extracted_message = message.delete_prefix("1")
|
49
|
-
stop_spinner.call && @connection_established = true unless extracted_message == ""
|
50
|
-
@prompt = "\u001b[2K\u001b[0G#{extracted_message.split("\r\n").last}"
|
51
|
-
print extracted_message
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
@ws.on :open do
|
56
|
-
end
|
32
|
+
def start_console
|
33
|
+
console_access_token = @response.parsed_response["console_access_token"]
|
34
|
+
pod_name = @response.parsed_response["pod_name"]
|
35
|
+
database_url = @response.parsed_response["database_url"]
|
36
|
+
container_name = @response.parsed_response["container_name"]
|
57
37
|
|
58
|
-
|
59
|
-
|
60
|
-
exit 1
|
61
|
-
end
|
38
|
+
execute_console(pod_name, console_access_token, container_name, kind, database_url)
|
39
|
+
end
|
62
40
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
$@.each { |backtrace| puts backtrace }
|
67
|
-
exit 1
|
68
|
-
end
|
41
|
+
def execute_console(pod_name, console_access_token, container_name, kind, database_url)
|
42
|
+
system("#{console_executable_path} -podname #{pod_name} -token #{console_access_token} -kind #{kind} -container #{container_name} -url #{database_url}")
|
43
|
+
end
|
69
44
|
|
70
|
-
|
71
|
-
|
72
|
-
|
45
|
+
def send_console_session_request
|
46
|
+
@response = send_post_request(console_session_base_url, { addon_name:, kind: })
|
47
|
+
@spinner.stop
|
48
|
+
end
|
73
49
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
@ws.send "1" + input
|
78
|
-
end
|
50
|
+
def connection_cleanup_callback
|
51
|
+
url = "#{console_session_base_url}/#{addon_name}"
|
52
|
+
send_delete_request(url, { pubsub_token: @pubsub_token })
|
79
53
|
end
|
80
54
|
|
81
|
-
def
|
55
|
+
def start_spinner
|
56
|
+
@spinner = TTY::Spinner.new("Setting up dyno [:spinner]", format: :classic)
|
57
|
+
@spinner.auto_spin
|
82
58
|
end
|
83
59
|
end
|
84
60
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "websocket-client-simple"
|
4
3
|
require "thor"
|
5
4
|
require "readline"
|
6
5
|
|
@@ -42,7 +41,8 @@ module NeetoDeploy
|
|
42
41
|
@pubsub_token = @response.parsed_response["console_pubsub_token"]
|
43
42
|
console_access_token = @response.parsed_response["console_access_token"]
|
44
43
|
pod_name = "#{app_name}-#{@pubsub_token}-console-deployment"
|
45
|
-
|
44
|
+
container_name = "#{app_name}-#{@pubsub_token}-console"
|
45
|
+
system("#{console_executable_path} -podname #{pod_name} -token #{console_access_token} -container #{container_name}")
|
46
46
|
end
|
47
47
|
|
48
48
|
def send_console_session_request
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "websocket-client-simple"
|
4
3
|
require "thor"
|
5
4
|
require "colorize"
|
5
|
+
require "websocket-eventmachine-client"
|
6
6
|
|
7
7
|
require_relative "../session"
|
8
8
|
require_relative "./constants"
|
@@ -14,11 +14,11 @@ module NeetoDeploy
|
|
14
14
|
include Constants
|
15
15
|
include Session
|
16
16
|
|
17
|
-
attr_reader :
|
17
|
+
attr_reader :app_slug, :process_type
|
18
18
|
|
19
|
-
def initialize(
|
19
|
+
def initialize(app_slug, process_type = nil)
|
20
20
|
super()
|
21
|
-
@
|
21
|
+
@app_slug = app_slug
|
22
22
|
@process_type = process_type
|
23
23
|
end
|
24
24
|
|
@@ -32,57 +32,45 @@ module NeetoDeploy
|
|
32
32
|
"wss://connect.neetodeploy.com/cable"
|
33
33
|
end
|
34
34
|
|
35
|
-
def ensure_app_access?
|
36
|
-
response = send_get_request(app_verify_access_url, { app_slug: app_name })
|
37
|
-
@ui.error(JSON[response.body]["error"]) unless response.success?
|
38
|
-
response.success?
|
39
|
-
end
|
40
|
-
|
41
35
|
def stream_logs
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
pubsub_token = SecureRandom.hex(16)
|
36
|
+
EM.run do
|
37
|
+
session_token = common_body[:session_token]
|
38
|
+
pubsub_token = SecureRandom.hex(16)
|
39
|
+
ws_connection = WebSocket::EventMachine::Client.connect(uri:)
|
47
40
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
41
|
+
ws_connection.onopen do
|
42
|
+
payload = {
|
43
|
+
command: "subscribe",
|
44
|
+
identifier: {
|
45
|
+
channel: "Cli::LogChannel", app_slug:, pubsub_token:, process_type:,
|
46
|
+
session_token:
|
47
|
+
}.to_json
|
48
|
+
}
|
49
|
+
ws_connection.send(payload.to_json)
|
50
|
+
end
|
58
51
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
52
|
+
ws_connection.onmessage do |msg, type|
|
53
|
+
parsed_message = JSON[msg]
|
54
|
+
if parsed_message["message"] && parsed_message["type"] != "ping"
|
55
|
+
logs = JSON[parsed_message["message"]]["streams"].flat_map do |stream|
|
56
|
+
stream["values"].map do |array|
|
57
|
+
"#{Time.at(array[0].to_i / 1e9).to_s.light_magenta} #{array[1]}"
|
58
|
+
end
|
65
59
|
end
|
66
|
-
|
67
|
-
|
60
|
+
STDOUT.puts logs
|
61
|
+
end
|
62
|
+
|
63
|
+
if parsed_message["type"] == "disconnect"
|
64
|
+
puts parsed_message["error"].red
|
65
|
+
ws_connection.close
|
68
66
|
exit
|
69
67
|
end
|
70
68
|
end
|
71
|
-
end
|
72
|
-
|
73
|
-
ws_connection.on :close do |e|
|
74
|
-
p e unless e.nil?
|
75
|
-
exit 1
|
76
|
-
end
|
77
69
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
$@.each { |backtrace| puts backtrace }
|
82
|
-
exit 1
|
70
|
+
ws_connection.onerror do |error|
|
71
|
+
puts "Error: #{error}"
|
72
|
+
end
|
83
73
|
end
|
84
|
-
|
85
|
-
loop do end
|
86
74
|
end
|
87
75
|
end
|
88
76
|
end
|
@@ -6,12 +6,11 @@ module NeetoDeploy
|
|
6
6
|
class CLI
|
7
7
|
module Pg
|
8
8
|
class Commands < Thor
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# end
|
9
|
+
desc "cli", "Connect to postgresql console"
|
10
|
+
option :addon, type: :string, aliases: "-n", required: true, desc: "Addon name"
|
11
|
+
def cli
|
12
|
+
Console.new(options[:addon]).process!
|
13
|
+
end
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
@@ -12,33 +12,10 @@ module NeetoDeploy
|
|
12
12
|
include Constants
|
13
13
|
include Session
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
super()
|
19
|
-
@addon_name = options[:addon_name]
|
20
|
-
@instance_name = options[:addon_name]
|
21
|
-
@connection_established = false
|
22
|
-
end
|
23
|
-
|
24
|
-
def run
|
25
|
-
run_console
|
15
|
+
def initialize(addon_name)
|
16
|
+
super(addon_name)
|
17
|
+
@kind = "neetodeploy-postgresql"
|
26
18
|
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def send_console_session_request
|
31
|
-
@response = send_post_request(console_session_base_url(addon_name), {})
|
32
|
-
end
|
33
|
-
|
34
|
-
def send_websocket_request
|
35
|
-
console_token = @response.parsed_response["console_token"]
|
36
|
-
database_url = @response.parsed_response["url"]
|
37
|
-
deployment_name = @response.parsed_response["internal_name"]
|
38
|
-
app_name = @response.parsed_response["app_name"]
|
39
|
-
|
40
|
-
@ws = WebSocket::Client::Simple.connect "#{DYNO_CONSOLE_MANAGER_URL}/cli_console?app_name=#{app_name}&deployment_name=#{deployment_name}&console_token=#{console_token}&database_url=#{database_url}&kind=postgres"
|
41
|
-
end
|
42
19
|
end
|
43
20
|
end
|
44
21
|
end
|
@@ -4,8 +4,8 @@ module NeetoDeploy
|
|
4
4
|
class CLI
|
5
5
|
module Pg
|
6
6
|
module Constants
|
7
|
-
def console_session_base_url
|
8
|
-
"#{NEETO_DEPLOY_CLI_API_BASE_URL}/addons
|
7
|
+
def console_session_base_url
|
8
|
+
"#{NEETO_DEPLOY_CLI_API_BASE_URL}/addons/console_sessions"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -4,13 +4,14 @@ require "thor"
|
|
4
4
|
require_relative "./set"
|
5
5
|
require_relative "./get"
|
6
6
|
require_relative "./reset_stats"
|
7
|
+
require_relative "./console"
|
7
8
|
|
8
9
|
module NeetoDeploy
|
9
10
|
class CLI
|
10
11
|
module Redis
|
11
12
|
class Commands < Thor
|
12
13
|
desc "set", "Set redis config"
|
13
|
-
option :
|
14
|
+
option :addon, type: :string, aliases: "-n", required: true, desc: "Addon name"
|
14
15
|
option :key, type: :string, aliases: "-k", required: true, desc: "CONFIG name"
|
15
16
|
option :value, type: :string, aliases: "-v", required: true, desc: "New value for the CONFIG"
|
16
17
|
|
@@ -19,18 +20,24 @@ module NeetoDeploy
|
|
19
20
|
end
|
20
21
|
|
21
22
|
desc "get", "Get redis config"
|
22
|
-
option :
|
23
|
+
option :addon, type: :string, aliases: "-n", required: true, desc: "Addon name"
|
23
24
|
option :key, type: :string, aliases: "-k", required: true, desc: "CONFIG name"
|
24
25
|
def get
|
25
26
|
Get.new(options).run
|
26
27
|
end
|
27
28
|
|
28
29
|
desc "reset-stats", "Resets the statistics of the Redis instance"
|
29
|
-
option :
|
30
|
+
option :addon, type: :string, aliases: "-n", required: true, desc: "Addon name"
|
30
31
|
def reset_stats
|
31
32
|
ResetStats.new(options).run
|
32
33
|
end
|
33
34
|
|
35
|
+
desc "cli", "Connect to redis console"
|
36
|
+
option :addon, type: :string, aliases: "-n", required: true, desc: "Addon name"
|
37
|
+
def cli
|
38
|
+
Console.new(options[:addon]).process!
|
39
|
+
end
|
40
|
+
|
34
41
|
end
|
35
42
|
end
|
36
43
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require_relative "../session"
|
5
|
+
require_relative "./constants"
|
6
|
+
require_relative "../dyno_console_manager"
|
7
|
+
|
8
|
+
module NeetoDeploy
|
9
|
+
class CLI
|
10
|
+
module Redis
|
11
|
+
class Console < CLI::DynoConsoleManager
|
12
|
+
include Constants
|
13
|
+
include Session
|
14
|
+
|
15
|
+
def initialize(addon_name)
|
16
|
+
super(addon_name)
|
17
|
+
@kind = "neetodeploy-redis"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/neeto_deploy/version.rb
CHANGED
data/neetodeploy.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_dependency "launchy", "~> 2.5.0" # for opening in browser
|
36
36
|
spec.add_dependency "terminal-table", "~> 3.0.2" # for building cli table
|
37
37
|
spec.add_dependency "thor", "~> 1.3.0" # for cli
|
38
|
-
spec.add_dependency "websocket-client
|
38
|
+
spec.add_dependency "websocket-eventmachine-client"
|
39
39
|
spec.add_dependency "colorize"
|
40
40
|
spec.add_dependency "tty-spinner"
|
41
41
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neetodeploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Subin Siby
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.3.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: websocket-client
|
84
|
+
name: websocket-eventmachine-client
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- lib/neeto_deploy/cli/pg/console.rb
|
162
162
|
- lib/neeto_deploy/cli/pg/constants.rb
|
163
163
|
- lib/neeto_deploy/cli/redis/commands.rb
|
164
|
+
- lib/neeto_deploy/cli/redis/console.rb
|
164
165
|
- lib/neeto_deploy/cli/redis/constants.rb
|
165
166
|
- lib/neeto_deploy/cli/redis/get.rb
|
166
167
|
- lib/neeto_deploy/cli/redis/reset_stats.rb
|