neetodeploy 1.1.4 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -1
- data/lib/neeto_deploy/cli/addon/commands.rb +25 -0
- data/lib/neeto_deploy/cli/addon/constants.rb +15 -0
- data/lib/neeto_deploy/cli/addon/info.rb +54 -0
- data/lib/neeto_deploy/cli/addon/scheduled_exports_settings.rb +48 -0
- data/lib/neeto_deploy/cli/autoscaling_config/commands.rb +19 -0
- data/lib/neeto_deploy/cli/autoscaling_config/list.rb +32 -0
- data/lib/neeto_deploy/cli/base.rb +1 -1
- data/lib/neeto_deploy/cli/dyno_console_manager.rb +85 -0
- data/lib/neeto_deploy/cli/exec/base.rb +18 -59
- data/lib/neeto_deploy/cli/pg/commands.rb +18 -0
- data/lib/neeto_deploy/cli/pg/console.rb +45 -0
- data/lib/neeto_deploy/cli/pg/constants.rb +13 -0
- data/lib/neeto_deploy/cli/redis/commands.rb +8 -0
- data/lib/neeto_deploy/cli/redis/constants.rb +1 -1
- data/lib/neeto_deploy/cli/redis/get.rb +20 -9
- data/lib/neeto_deploy/cli/redis/reset_stats.rb +39 -0
- data/lib/neeto_deploy/cli/redis/set.rb +19 -11
- data/lib/neeto_deploy/cli/ui.rb +7 -0
- data/lib/neeto_deploy/cli.rb +13 -0
- data/lib/neeto_deploy/version.rb +1 -1
- data/neetodeploy.gemspec +1 -0
- metadata +27 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7758b6320f1b7a4e6ca6245794c802800ade04945bfa1396ea027a67629a02ec
|
4
|
+
data.tar.gz: 95f3f1b502eaf798d0dfc00d79db4f4b5e2badc5c015043c2e65b0525f56486b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4654d5e1e23becddf4b9726aaed9619100933d81a06a495f119ef51c63a4466bd4cf371d77706cd58fd15e07cc9930c7ae3b1e05e0c5110a11e3f8969ea61f19
|
7
|
+
data.tar.gz: 06bff1ef5ad906b62f0d26dcb59170f8d1569476cb3e9a09321813c94cf02d319eb722327049163f64e654fa295637f33798550627d7b518d2a17b3eada1495a
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
neetodeploy (1.1.
|
4
|
+
neetodeploy (1.1.6)
|
5
5
|
colorize
|
6
6
|
dotenv (~> 2.8.1)
|
7
7
|
httparty (~> 0.21.0)
|
8
8
|
launchy (~> 2.5.0)
|
9
9
|
terminal-table (~> 3.0.2)
|
10
10
|
thor (~> 1.3.0)
|
11
|
+
tty-spinner
|
11
12
|
websocket-client-simple
|
12
13
|
|
13
14
|
GEM
|
@@ -30,6 +31,9 @@ GEM
|
|
30
31
|
terminal-table (3.0.2)
|
31
32
|
unicode-display_width (>= 1.1.1, < 3)
|
32
33
|
thor (1.3.0)
|
34
|
+
tty-cursor (0.7.1)
|
35
|
+
tty-spinner (0.9.3)
|
36
|
+
tty-cursor (~> 0.7)
|
33
37
|
unicode-display_width (2.4.2)
|
34
38
|
websocket (1.2.9)
|
35
39
|
websocket-client-simple (0.6.1)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require_relative "./info"
|
5
|
+
require_relative "./scheduled_exports_settings"
|
6
|
+
|
7
|
+
module NeetoDeploy
|
8
|
+
class CLI
|
9
|
+
module Addon
|
10
|
+
class Commands < Thor
|
11
|
+
desc "info", "Get addon informations"
|
12
|
+
option :addon_name, type: :string, aliases: "-n", required: true, desc: "Addon name"
|
13
|
+
def info
|
14
|
+
Info.new(options).run
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "scheduled_exports_enabled", "Check whether scheduled exports is enabled for an app"
|
18
|
+
option :app_name, type: :string, aliases: "-a", required: true, desc: "App name"
|
19
|
+
def scheduled_exports_enabled
|
20
|
+
ScheduledExportsSettings.new(options).run
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NeetoDeploy
|
4
|
+
class CLI
|
5
|
+
module Addon
|
6
|
+
module Constants
|
7
|
+
NEETO_DEPLOY_CLI_API_ADDON_URL = "#{NEETO_DEPLOY_CLI_API_BASE_URL}/addons".freeze
|
8
|
+
|
9
|
+
def addon_url(addon_name)
|
10
|
+
"#{NEETO_DEPLOY_CLI_API_BASE_URL}/addons/#{addon_name}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
require_relative "../session"
|
6
|
+
require_relative "./constants"
|
7
|
+
|
8
|
+
module NeetoDeploy
|
9
|
+
class CLI
|
10
|
+
module Addon
|
11
|
+
class Info < CLI::Base
|
12
|
+
include Constants
|
13
|
+
include Session
|
14
|
+
|
15
|
+
attr_reader :addon_name
|
16
|
+
|
17
|
+
def initialize(options)
|
18
|
+
super()
|
19
|
+
@addon_name = options[:addon_name]
|
20
|
+
end
|
21
|
+
|
22
|
+
def run
|
23
|
+
ui.execute_with_loading("Fetching info...") do
|
24
|
+
send_request
|
25
|
+
end
|
26
|
+
print_output
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def flatten_hash_from(hash)
|
32
|
+
hash.each_with_object({}) do |(key, value), memo|
|
33
|
+
next flatten_hash_from(value).each do |k, v|
|
34
|
+
memo["#{k}".intern] = v
|
35
|
+
end if value.is_a? Hash
|
36
|
+
memo[key] = value
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def send_request
|
41
|
+
@response = send_get_request(addon_url(addon_name), {})
|
42
|
+
end
|
43
|
+
|
44
|
+
def print_output
|
45
|
+
ui.error(@response["error"]) and return unless @response.success?
|
46
|
+
|
47
|
+
flatten_hash_from(JSON[@response.body]).each do |k, v|
|
48
|
+
ui.info("#{k}: #{v}")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
require_relative "../session"
|
6
|
+
require_relative "./constants"
|
7
|
+
|
8
|
+
module NeetoDeploy
|
9
|
+
class CLI
|
10
|
+
module Addon
|
11
|
+
class ScheduledExportsSettings < CLI::Base
|
12
|
+
include Constants
|
13
|
+
include Session
|
14
|
+
|
15
|
+
attr_reader :app_name
|
16
|
+
|
17
|
+
def initialize(options)
|
18
|
+
super()
|
19
|
+
@app_name = options[:app_name]
|
20
|
+
end
|
21
|
+
|
22
|
+
def run
|
23
|
+
ui.execute_with_loading("Fetching info...") do
|
24
|
+
send_request
|
25
|
+
end
|
26
|
+
print_output
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def send_request
|
32
|
+
@response = send_get_request("#{NEETO_DEPLOY_CLI_API_BASE_URL}/scheduled_exports/#{app_name}", {app_slug: app_name})
|
33
|
+
end
|
34
|
+
|
35
|
+
def print_output
|
36
|
+
ui.error(@response["error"]) and return unless @response.success?
|
37
|
+
|
38
|
+
scheduled_exports = JSON.parse(@response.body)["scheduled_exports_enabled"]
|
39
|
+
if scheduled_exports.nil?
|
40
|
+
ui.error("App doesn't seem to have a primary database addon")
|
41
|
+
else
|
42
|
+
ui.info("Scheduled exports is turned #{scheduled_exports ? "\u001b[32mon\u001b[0m" : "\u001b[31moff\u001b[0m"} for #{app_name}'s primary database")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
require_relative "./list"
|
6
|
+
|
7
|
+
module NeetoDeploy
|
8
|
+
class CLI
|
9
|
+
module AutoscalingConfig
|
10
|
+
class Commands < Thor
|
11
|
+
desc "list", "List autoscaling configs of an app"
|
12
|
+
option :app, type: :string, aliases: "-a", required: true, desc: "App slug"
|
13
|
+
def list
|
14
|
+
List.new(options:).run
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module NeetoDeploy
|
6
|
+
class CLI
|
7
|
+
module AutoscalingConfig
|
8
|
+
class List < CLI::Base
|
9
|
+
include Session
|
10
|
+
|
11
|
+
attr_reader :app_slug
|
12
|
+
|
13
|
+
def initialize(options:)
|
14
|
+
super()
|
15
|
+
@app_slug = options[:app]
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
response = send_get_request(
|
20
|
+
"#{NEETO_DEPLOY_CLI_API_BASE_URL}/autoscaling_configs/#{app_slug}", {
|
21
|
+
app_slug:
|
22
|
+
}
|
23
|
+
)
|
24
|
+
|
25
|
+
ui.error(response) and return unless response.success?
|
26
|
+
|
27
|
+
ui.success(JSON.parse(response.body)["autoscaling_status"])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -4,7 +4,7 @@ require_relative "ui"
|
|
4
4
|
require_relative "../version"
|
5
5
|
|
6
6
|
module NeetoDeploy
|
7
|
-
class CLI
|
7
|
+
class CLI
|
8
8
|
NEETO_DEPLOY_HOST = ENV["NEETO_DEPLOY_HOST"] || "https://app.neetodeploy.com"
|
9
9
|
NEETO_DEPLOY_CLI_API_BASE_URL = "#{NEETO_DEPLOY_HOST}/api/cli/#{CLI_API_VERSION}"
|
10
10
|
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module NeetoDeploy
|
6
|
+
class CLI
|
7
|
+
class DynoConsoleManager < Base
|
8
|
+
DYNO_CONSOLE_MANAGER_URL = "wss://neeto-deploy-lc.neetodeployapp.com"
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super()
|
12
|
+
@prompt = ""
|
13
|
+
end
|
14
|
+
|
15
|
+
def run_console
|
16
|
+
start_spinner
|
17
|
+
send_console_session_request
|
18
|
+
ui.error(response) and return unless @response.success?
|
19
|
+
|
20
|
+
send_websocket_request
|
21
|
+
define_websocket_blocks
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def start_spinner
|
27
|
+
@spinner = TTY::Spinner.new("[:spinner] Connecting to #{@instance_name}", format: :classic)
|
28
|
+
@spinner.auto_spin
|
29
|
+
end
|
30
|
+
|
31
|
+
def define_websocket_blocks
|
32
|
+
stop_spinner = lambda do
|
33
|
+
@spinner.stop unless @connection_established
|
34
|
+
end
|
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
|
57
|
+
|
58
|
+
@ws.on :close do |e|
|
59
|
+
puts e
|
60
|
+
exit 1
|
61
|
+
end
|
62
|
+
|
63
|
+
@ws.on :error do |e|
|
64
|
+
puts e
|
65
|
+
puts "MyserverBackend>> Close entered. Last error:#{$!.class}:#{$!.to_s};Module:#{$0};"
|
66
|
+
$@.each { |backtrace| puts backtrace }
|
67
|
+
exit 1
|
68
|
+
end
|
69
|
+
|
70
|
+
trap("SIGINT") do
|
71
|
+
Thread.new { @ws.send "4" }
|
72
|
+
end
|
73
|
+
|
74
|
+
loop do
|
75
|
+
sleep 0.1
|
76
|
+
input = Readline.readline(@prompt, true)
|
77
|
+
@ws.send "1" + input
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def connection_cleanup
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "websocket-client-simple"
|
3
4
|
require "thor"
|
4
5
|
require "readline"
|
5
6
|
|
6
7
|
require_relative "../session"
|
7
8
|
require_relative "./constants"
|
9
|
+
require_relative "../dyno_console_manager"
|
8
10
|
|
9
11
|
module NeetoDeploy
|
10
12
|
class CLI
|
11
13
|
module Exec
|
12
|
-
class Base < CLI::
|
14
|
+
class Base < CLI::DynoConsoleManager
|
13
15
|
include Constants
|
14
16
|
include Session
|
15
17
|
|
@@ -18,75 +20,32 @@ module NeetoDeploy
|
|
18
20
|
def initialize(app_name)
|
19
21
|
super()
|
20
22
|
@app_name = app_name
|
23
|
+
@instance_name = app_name
|
24
|
+
@connection_established = false
|
21
25
|
end
|
22
26
|
|
23
27
|
def process!
|
24
|
-
|
25
|
-
|
26
|
-
response = send_post_request(
|
27
|
-
console_session_base_url, {
|
28
|
-
# TODO refactor app_slug to app_name in dashboard app
|
29
|
-
app_slug: app_name,
|
30
|
-
}
|
31
|
-
)
|
32
|
-
|
33
|
-
ui.error(response) and return unless response.success?
|
34
|
-
|
35
|
-
console_token = response.parsed_response["console_token"]
|
36
|
-
|
37
|
-
ws = WebSocket::Client::Simple.connect "wss://neeto-deploy-lc.neetodeployapp.com/cli_console?deployment_name=#{app_name}&console_token=#{console_token}"
|
38
|
-
|
39
|
-
prompt = ''
|
40
|
-
|
41
|
-
delete_url = "#{console_session_base_url}/#{console_token}"
|
42
|
-
app_slug = app_name
|
43
|
-
|
44
|
-
send_delete_request = lambda do |url, body|
|
45
|
-
send_delete_request(url, body)
|
46
|
-
end
|
28
|
+
run_console
|
29
|
+
end
|
47
30
|
|
48
|
-
|
49
|
-
message = msg.data
|
50
|
-
if message.to_s.eql?("{\"exitCode\":0,\"signal\":0}")
|
51
|
-
send_delete_request.call(
|
52
|
-
delete_url, {
|
53
|
-
app_slug:
|
54
|
-
}
|
55
|
-
)
|
56
|
-
exit 0
|
57
|
-
end
|
58
|
-
cmd = message[0]
|
59
|
-
if cmd == "1"
|
60
|
-
prompt = "\u001b[2K\u001b[0G#{message.delete_prefix("1").split("\r\n").last}"
|
61
|
-
print message.delete_prefix("1")
|
62
|
-
end
|
63
|
-
end
|
31
|
+
private
|
64
32
|
|
65
|
-
|
33
|
+
def send_console_session_request
|
34
|
+
@response = send_post_request(console_session_base_url, { app_slug: @app_name })
|
66
35
|
end
|
67
36
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
37
|
+
def send_websocket_request
|
38
|
+
@console_token = @response.parsed_response["console_token"]
|
39
|
+
pubsub_token = @response.parsed_response["console_pubsub_token"]
|
40
|
+
deployment_name = "#{app_name}-#{pubsub_token}-console-deployment"
|
72
41
|
|
73
|
-
|
74
|
-
puts e
|
75
|
-
puts "MyserverBackend>> Close entered. Last error:#{$!.class}:#{$!.to_s};Module:#{$0};"
|
76
|
-
$@.each { |backtrace| puts backtrace }
|
77
|
-
exit 1
|
42
|
+
@ws = WebSocket::Client::Simple.connect "#{DYNO_CONSOLE_MANAGER_URL}/cli_console?app_name=#{app_name}&deployment_name=#{deployment_name}&console_token=#{@console_token}&kind=web"
|
78
43
|
end
|
79
44
|
|
80
|
-
|
81
|
-
|
45
|
+
def connection_cleanup
|
46
|
+
url = "#{console_session_base_url}/#{@console_token}"
|
47
|
+
send_delete_request(url, { app_slug: app_name })
|
82
48
|
end
|
83
|
-
|
84
|
-
loop do
|
85
|
-
sleep 0.1
|
86
|
-
input = Readline.readline(prompt, true)
|
87
|
-
ws.send "1" + input
|
88
|
-
end
|
89
|
-
end
|
90
49
|
end
|
91
50
|
end
|
92
51
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./console"
|
4
|
+
|
5
|
+
module NeetoDeploy
|
6
|
+
class CLI
|
7
|
+
module Pg
|
8
|
+
class Commands < Thor
|
9
|
+
desc "cli", "Connect to postgresql console"
|
10
|
+
option :addon_name, type: :string, aliases: "-n", required: true, desc: "Addon name"
|
11
|
+
|
12
|
+
def cli
|
13
|
+
Console.new(options).run
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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 Pg
|
11
|
+
class Console < CLI::DynoConsoleManager
|
12
|
+
include Constants
|
13
|
+
include Session
|
14
|
+
|
15
|
+
attr_reader :addon_name
|
16
|
+
|
17
|
+
def initialize(options)
|
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
|
26
|
+
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
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "thor"
|
4
4
|
require_relative "./set"
|
5
5
|
require_relative "./get"
|
6
|
+
require_relative "./reset_stats"
|
6
7
|
|
7
8
|
module NeetoDeploy
|
8
9
|
class CLI
|
@@ -23,6 +24,13 @@ module NeetoDeploy
|
|
23
24
|
def get
|
24
25
|
Get.new(options).run
|
25
26
|
end
|
27
|
+
|
28
|
+
desc "reset-stats", "Resets the statistics of the Redis instance"
|
29
|
+
option :addon_name, type: :string, aliases: "-n", required: true, desc: "Addon name"
|
30
|
+
def reset_stats
|
31
|
+
ResetStats.new(options).run
|
32
|
+
end
|
33
|
+
|
26
34
|
end
|
27
35
|
end
|
28
36
|
end
|
@@ -5,7 +5,7 @@ module NeetoDeploy
|
|
5
5
|
module Redis
|
6
6
|
module Constants
|
7
7
|
NEETO_DEPLOY_CLI_API_ADDONS_REDIS_URL = "#{NEETO_DEPLOY_CLI_API_BASE_URL}/addons/redis".freeze
|
8
|
-
AVAILABLE_REDIS_CONFIGS_TO_EDIT = ["maxmemory-policy"]
|
8
|
+
AVAILABLE_REDIS_CONFIGS_TO_EDIT = ["maxmemory-policy", "notify-keyspace-events"]
|
9
9
|
|
10
10
|
def redis_addon_url
|
11
11
|
NEETO_DEPLOY_CLI_API_ADDONS_REDIS_URL
|
@@ -20,17 +20,28 @@ module NeetoDeploy
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def run
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
)
|
23
|
+
ui.execute_with_loading("Fetching info...") do
|
24
|
+
send_request
|
25
|
+
end
|
26
|
+
print_output
|
27
|
+
end
|
29
28
|
|
30
|
-
|
29
|
+
private
|
31
30
|
|
32
|
-
|
33
|
-
|
31
|
+
def send_request
|
32
|
+
@response = send_patch_request(
|
33
|
+
redis_addon_url, {
|
34
|
+
addon_name:,
|
35
|
+
command: "CONFIG get #{key}"
|
36
|
+
}
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
def print_output
|
41
|
+
ui.error(@response["error"]) and return unless @response.success?
|
42
|
+
|
43
|
+
ui.success(@response["message"])
|
44
|
+
end
|
34
45
|
end
|
35
46
|
end
|
36
47
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require_relative "../session"
|
5
|
+
require_relative "./constants"
|
6
|
+
|
7
|
+
module NeetoDeploy
|
8
|
+
class CLI
|
9
|
+
module Redis
|
10
|
+
class ResetStats < CLI::Base
|
11
|
+
include Constants
|
12
|
+
include Session
|
13
|
+
|
14
|
+
attr_reader :addon_name
|
15
|
+
|
16
|
+
def initialize(options)
|
17
|
+
super()
|
18
|
+
@addon_name = options[:addon_name]
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
if ui.yes?("Are you sure you want to reset the statistics (y/n)")
|
23
|
+
response = send_patch_request(
|
24
|
+
redis_addon_url, {
|
25
|
+
addon_name:,
|
26
|
+
command: "CONFIG RESETSTAT"
|
27
|
+
}
|
28
|
+
)
|
29
|
+
ui.error(response["error"]) and return unless response.success?
|
30
|
+
|
31
|
+
ui.success("Stats reset successful.")
|
32
|
+
else
|
33
|
+
puts "Reset cancelled."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "thor"
|
4
|
-
require "byebug"
|
5
4
|
|
6
5
|
require_relative "../session"
|
7
6
|
require_relative "./constants"
|
@@ -28,16 +27,10 @@ module NeetoDeploy
|
|
28
27
|
return
|
29
28
|
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
}
|
36
|
-
)
|
37
|
-
|
38
|
-
ui.error(response) and return unless response.success?
|
39
|
-
|
40
|
-
ui.success("Done")
|
30
|
+
ui.execute_with_loading("Setting config...") do
|
31
|
+
send_request
|
32
|
+
end
|
33
|
+
print_output
|
41
34
|
end
|
42
35
|
|
43
36
|
private
|
@@ -45,6 +38,21 @@ module NeetoDeploy
|
|
45
38
|
def valid_config?
|
46
39
|
AVAILABLE_REDIS_CONFIGS_TO_EDIT.include?(key)
|
47
40
|
end
|
41
|
+
|
42
|
+
def send_request
|
43
|
+
@response = send_patch_request(
|
44
|
+
redis_addon_url, {
|
45
|
+
addon_name:,
|
46
|
+
command: "CONFIG set #{key} #{value}"
|
47
|
+
}
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def print_output
|
52
|
+
ui.error(@response["error"]) and return unless @response.success?
|
53
|
+
|
54
|
+
ui.success("#{key} config for #{addon_name} set to #{value}")
|
55
|
+
end
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|
data/lib/neeto_deploy/cli/ui.rb
CHANGED
@@ -34,6 +34,13 @@ module NeetoDeploy
|
|
34
34
|
def info(statement)
|
35
35
|
shell.say(statement)
|
36
36
|
end
|
37
|
+
|
38
|
+
def execute_with_loading(msg)
|
39
|
+
@spinner = TTY::Spinner.new("[:spinner] #{msg}", format: :classic)
|
40
|
+
@spinner.auto_spin
|
41
|
+
yield
|
42
|
+
@spinner.stop
|
43
|
+
end
|
37
44
|
end
|
38
45
|
end
|
39
46
|
end
|
data/lib/neeto_deploy/cli.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "thor"
|
4
|
+
require 'tty-spinner'
|
4
5
|
|
5
6
|
# TODO: make this like neetob
|
6
7
|
|
@@ -12,6 +13,9 @@ module NeetoDeploy
|
|
12
13
|
require_relative "cli/logs/base"
|
13
14
|
require_relative "cli/env/commands"
|
14
15
|
require_relative "cli/redis/commands"
|
16
|
+
require_relative "cli/pg/commands"
|
17
|
+
require_relative "cli/addon/commands"
|
18
|
+
require_relative "cli/autoscaling_config/commands"
|
15
19
|
|
16
20
|
def self.start(*)
|
17
21
|
super
|
@@ -40,5 +44,14 @@ module NeetoDeploy
|
|
40
44
|
|
41
45
|
desc "redis", "Manage redis addons"
|
42
46
|
subcommand "redis", Redis::Commands
|
47
|
+
|
48
|
+
desc "pg", "Manage postgresql addons"
|
49
|
+
subcommand "pg", Pg::Commands
|
50
|
+
|
51
|
+
desc "addon", "Manage addons"
|
52
|
+
subcommand "addon", Addon::Commands
|
53
|
+
|
54
|
+
desc "autoscaling_config", "Manage autoscaling"
|
55
|
+
subcommand "autoscaling_config", AutoscalingConfig::Commands
|
43
56
|
end
|
44
57
|
end
|
data/lib/neeto_deploy/version.rb
CHANGED
data/neetodeploy.gemspec
CHANGED
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_dependency "thor", "~> 1.3.0" # for cli
|
38
38
|
spec.add_dependency "websocket-client-simple"
|
39
39
|
spec.add_dependency "colorize"
|
40
|
+
spec.add_dependency "tty-spinner"
|
40
41
|
|
41
42
|
# To add the files from submodules
|
42
43
|
`git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
|
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.6
|
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-
|
11
|
+
date: 2024-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: tty-spinner
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: Manage neetoDeploy apps with CLI
|
112
126
|
email:
|
113
127
|
- subin.siby@bigbinary.com
|
@@ -122,7 +136,14 @@ files:
|
|
122
136
|
- exe/neetodeploy
|
123
137
|
- lib/neeto_deploy.rb
|
124
138
|
- lib/neeto_deploy/cli.rb
|
139
|
+
- lib/neeto_deploy/cli/addon/commands.rb
|
140
|
+
- lib/neeto_deploy/cli/addon/constants.rb
|
141
|
+
- lib/neeto_deploy/cli/addon/info.rb
|
142
|
+
- lib/neeto_deploy/cli/addon/scheduled_exports_settings.rb
|
143
|
+
- lib/neeto_deploy/cli/autoscaling_config/commands.rb
|
144
|
+
- lib/neeto_deploy/cli/autoscaling_config/list.rb
|
125
145
|
- lib/neeto_deploy/cli/base.rb
|
146
|
+
- lib/neeto_deploy/cli/dyno_console_manager.rb
|
126
147
|
- lib/neeto_deploy/cli/env/commands.rb
|
127
148
|
- lib/neeto_deploy/cli/env/constants.rb
|
128
149
|
- lib/neeto_deploy/cli/env/list.rb
|
@@ -134,9 +155,13 @@ files:
|
|
134
155
|
- lib/neeto_deploy/cli/login/constants.rb
|
135
156
|
- lib/neeto_deploy/cli/logs/base.rb
|
136
157
|
- lib/neeto_deploy/cli/logs/constants.rb
|
158
|
+
- lib/neeto_deploy/cli/pg/commands.rb
|
159
|
+
- lib/neeto_deploy/cli/pg/console.rb
|
160
|
+
- lib/neeto_deploy/cli/pg/constants.rb
|
137
161
|
- lib/neeto_deploy/cli/redis/commands.rb
|
138
162
|
- lib/neeto_deploy/cli/redis/constants.rb
|
139
163
|
- lib/neeto_deploy/cli/redis/get.rb
|
164
|
+
- lib/neeto_deploy/cli/redis/reset_stats.rb
|
140
165
|
- lib/neeto_deploy/cli/redis/set.rb
|
141
166
|
- lib/neeto_deploy/cli/session.rb
|
142
167
|
- lib/neeto_deploy/cli/ui.rb
|