rockette 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +7 -1
- data/exe/rockette +20 -8
- data/lib/rockette.rb +84 -32
- data/lib/rockette/cli.rb +29 -32
- data/lib/rockette/command.rb +12 -11
- data/lib/rockette/commands/config.rb +7 -2
- data/lib/rockette/commands/deploy.rb +32 -30
- data/lib/rockette/commands/export.rb +35 -30
- data/lib/rockette/text_helper.rb +18 -0
- data/lib/rockette/version.rb +1 -1
- data/rockette.gemspec +1 -1
- data/templates/config.yml.erb +17 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2870c274fb8f46b67ff9590364eeb0b68936e046a2a33c162de7410542c735af
|
4
|
+
data.tar.gz: b2932d43fbd1562c79b86408afb907b1db2bf4c2fb8d072fdd36d61393dccd92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c214dc82ce832ae90d328447062ba8ac98a56ff3ab1056d7724123c8ae0da01bb3909845671b45ce2f869f6c2d880b326d8b7105f2a42c7069ac3618c3aad357
|
7
|
+
data.tar.gz: 1b9b8d76c9e547d8af19382d5b0eed3800f4e914f8f5dbe34933c75fdd1c766042ef289af4f0fd4f59167e8d71422a68edf35d88a71693cdba45e1c6781747f6
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -3,3 +3,11 @@
|
|
3
3
|
## [0.0.0] - 2021-02-08
|
4
4
|
|
5
5
|
- Initial release
|
6
|
+
|
7
|
+
|
8
|
+
## [0.0.1] - 2021-03-15
|
9
|
+
|
10
|
+
- Unify rest calls into Rester class
|
11
|
+
- Improve exception handling including socket errors
|
12
|
+
- Switch to yaml for config
|
13
|
+
- Use ~/.rockette as consistent location for config and exports
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rockette (0.0.
|
4
|
+
rockette (0.0.1)
|
5
5
|
rest-client (~> 2.0)
|
6
6
|
thor (~> 1.0)
|
7
7
|
|
@@ -9,11 +9,13 @@ GEM
|
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
ast (2.4.2)
|
12
|
+
coderay (1.1.3)
|
12
13
|
domain_name (0.5.20190701)
|
13
14
|
unf (>= 0.0.5, < 1.0.0)
|
14
15
|
http-accept (1.7.0)
|
15
16
|
http-cookie (1.0.3)
|
16
17
|
domain_name (~> 0.5)
|
18
|
+
method_source (1.0.0)
|
17
19
|
mime-types (3.3.1)
|
18
20
|
mime-types-data (~> 3.2015)
|
19
21
|
mime-types-data (3.2021.0212)
|
@@ -22,6 +24,9 @@ GEM
|
|
22
24
|
parallel (1.20.1)
|
23
25
|
parser (3.0.0.0)
|
24
26
|
ast (~> 2.4.1)
|
27
|
+
pry (0.14.0)
|
28
|
+
coderay (~> 1.1)
|
29
|
+
method_source (~> 1.0)
|
25
30
|
rainbow (3.0.0)
|
26
31
|
rake (13.0.3)
|
27
32
|
regexp_parser (2.1.1)
|
@@ -55,6 +60,7 @@ PLATFORMS
|
|
55
60
|
|
56
61
|
DEPENDENCIES
|
57
62
|
minitest (~> 5.0)
|
63
|
+
pry (~> 0.0)
|
58
64
|
rake (~> 13.0)
|
59
65
|
rockette!
|
60
66
|
rubocop (~> 1.7)
|
data/exe/rockette
CHANGED
@@ -1,21 +1,33 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
$:.unshift(lib_path) if !$:.include?(lib_path)
|
6
|
-
require 'rockette/cli'
|
4
|
+
require "rockette"
|
7
5
|
|
8
|
-
|
6
|
+
app_path = File.join(Dir.home, ".rockette")
|
7
|
+
lib_path = File.expand_path("../lib", __dir__)
|
8
|
+
tem_path = File.expand_path("../templates", __dir__)
|
9
|
+
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
|
10
|
+
|
11
|
+
Dir.mkdir(app_path) unless File.exist?(app_path)
|
12
|
+
unless File.exist?(File.join(app_path, "config.yml"))
|
13
|
+
template = File.read(File.join(tem_path, "config.yml.erb"))
|
14
|
+
data = ERB.new(template).result(binding)
|
15
|
+
File.write(File.join(app_path, "config.yml"), data)
|
16
|
+
end
|
17
|
+
Dir.mkdir(File.join(app_path, "exports")) unless File.exist?(File.join(app_path, "exports"))
|
18
|
+
|
19
|
+
CONF = Psych.load(File.read(File.join(app_path, "config.yml")))
|
9
20
|
ENV["THOR_SILENCE_DEPRECATION"] = "true"
|
21
|
+
EXPORT_DIR = File.join(app_path, "exports")
|
10
22
|
|
11
|
-
Signal.trap(
|
23
|
+
Signal.trap("INT") do
|
12
24
|
warn("\n#{caller.join("\n")}: interrupted")
|
13
25
|
exit(1)
|
14
26
|
end
|
15
27
|
|
16
28
|
begin
|
17
29
|
Rockette::CLI.start
|
18
|
-
rescue Rockette::CLI::Error =>
|
19
|
-
puts "ERROR: #{
|
30
|
+
rescue Rockette::CLI::Error => e
|
31
|
+
puts "ERROR: #{e.message}"
|
20
32
|
exit 1
|
21
|
-
end
|
33
|
+
end
|
data/lib/rockette.rb
CHANGED
@@ -1,39 +1,91 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "erb"
|
4
|
+
require "json"
|
5
|
+
require "psych"
|
6
|
+
require "rest-client"
|
7
|
+
require "thor"
|
8
|
+
require_relative "rockette/cli"
|
9
|
+
require_relative "rockette/text_helper"
|
10
|
+
require_relative "rockette/version"
|
4
11
|
|
12
|
+
# APEX deployment
|
5
13
|
module Rockette
|
6
14
|
class Error < StandardError; end
|
7
|
-
#
|
8
|
-
# # Export application on APEX instance
|
9
|
-
# def create_export(body, url)
|
10
|
-
# response = RestClient.post url, body
|
11
|
-
# response
|
12
|
-
# rescue StandardError => e
|
13
|
-
# # change these, send back the error message, don't puts it!
|
14
|
-
# puts "Unable to create export because #{e.message}" # puts error
|
15
|
-
# end
|
16
|
-
|
17
|
-
# # Grab application export from APEX instance
|
18
|
-
# def grab_export(url)
|
19
|
-
# response = RestClient.get url
|
20
|
-
# rescue StandardError => e
|
21
|
-
# puts "Unable to grab export because #{e.message}" # puts error
|
22
|
-
# end
|
23
|
-
|
24
|
-
# # Import application export into APEX instance
|
25
|
-
# def import_app(url, body)
|
26
|
-
# response = RestClient.post url, body
|
27
|
-
# rescue StandardError => e
|
28
|
-
# puts "Unable to import application because #{e.message}" # puts error
|
29
|
-
# end
|
30
|
-
|
31
|
-
# # Push attachment to api endpoint and show code
|
32
|
-
# def push_blob(filey, headers, url)
|
33
|
-
# response = RestClient.post url, filey, headers
|
34
|
-
# response
|
35
|
-
# rescue StandardError => e
|
36
|
-
# puts "Unable to push file because #{e.message}" # puts error
|
37
|
-
# end
|
38
15
|
|
16
|
+
# rest-client calls with error handling and auto retries
|
17
|
+
class Rester
|
18
|
+
VERBS = {
|
19
|
+
"delete" => :Delete,
|
20
|
+
"get" => :Get,
|
21
|
+
"post" => :Post,
|
22
|
+
"put" => :Put
|
23
|
+
}.freeze
|
24
|
+
|
25
|
+
def initialize(headers: {}, meth: "Get", params: {}, url: "https://array/", config: {})
|
26
|
+
@headers = headers
|
27
|
+
@meth = meth
|
28
|
+
@params = params
|
29
|
+
@url = url
|
30
|
+
@config = config
|
31
|
+
@config["timeout"] = @config["timeout"] ||= 30
|
32
|
+
end
|
33
|
+
|
34
|
+
def make_call
|
35
|
+
response = RestClient::Request.execute(headers: @headers,
|
36
|
+
method: VERBS[@meth.downcase], payload: @params,
|
37
|
+
timeout: @config["timeout"], url: @url, verify_ssl: false)
|
38
|
+
rescue SocketError => e
|
39
|
+
puts "#{e.class}: #{e.message}"
|
40
|
+
nil
|
41
|
+
rescue StandardError => e
|
42
|
+
e.response
|
43
|
+
else
|
44
|
+
response
|
45
|
+
end
|
46
|
+
|
47
|
+
def cookie
|
48
|
+
if @url =~ %r{auth/session}
|
49
|
+
response = make_call
|
50
|
+
raise "There was an issue getting a cookie!" unless response.code == 200
|
51
|
+
|
52
|
+
(response.cookies.map { |key, val| "#{key}=#{val}" })[0]
|
53
|
+
else
|
54
|
+
error_text("cookie", @url.to_s, "auth/session")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# use rest-client with retry
|
59
|
+
def rest_try
|
60
|
+
3.times do |i|
|
61
|
+
response = make_call
|
62
|
+
unless response.nil?
|
63
|
+
break response if (200..299).include? response.code
|
64
|
+
break response if i > 1
|
65
|
+
end
|
66
|
+
puts "Failed #{@meth} on #{@url}, retry...#{i + 1}"
|
67
|
+
sleep 3 unless i > 1
|
68
|
+
return nil if i > 1 # Handles socket errors, etc. where there is no response.
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def error_text(method_name, url, wanted)
|
75
|
+
{
|
76
|
+
"response" =>
|
77
|
+
"ERROR: Wrong url for the #{method_name} method.\n"\
|
78
|
+
"Sent: #{url}\n"\
|
79
|
+
"Expected: \"#{wanted}\" as part of the url.",
|
80
|
+
"status" => 400
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
def responder(response)
|
85
|
+
{
|
86
|
+
"response" => JSON.parse(response.body),
|
87
|
+
"status" => response.code.to_i
|
88
|
+
}
|
89
|
+
end
|
90
|
+
end
|
39
91
|
end
|
data/lib/rockette/cli.rb
CHANGED
@@ -1,65 +1,62 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'json'
|
4
|
-
require 'rest-client'
|
5
|
-
require 'thor'
|
6
|
-
|
7
3
|
module Rockette
|
8
4
|
#
|
9
5
|
# @api public
|
6
|
+
# Handle actions and parameters
|
10
7
|
class CLI < Thor
|
11
8
|
# Error raised by this runner
|
12
9
|
Error = Class.new(StandardError)
|
13
10
|
|
14
|
-
desc
|
11
|
+
desc "version", "rockette version"
|
15
12
|
def version
|
16
|
-
require_relative
|
13
|
+
require_relative "version"
|
17
14
|
puts "v#{Rockette::VERSION}"
|
18
15
|
end
|
19
|
-
map %w
|
16
|
+
map %w[--version -v] => :version
|
20
17
|
|
21
|
-
desc
|
22
|
-
method_option :help, aliases:
|
23
|
-
desc:
|
24
|
-
option :app_id, aliases:
|
25
|
-
|
26
|
-
option :file, aliases:
|
27
|
-
|
28
|
-
option :url, aliases:
|
29
|
-
|
18
|
+
desc "deploy", "Deploy chosen export file to target APEX instance"
|
19
|
+
method_option :help, aliases: "-h", type: :boolean,
|
20
|
+
desc: "Display usage information"
|
21
|
+
option :app_id, aliases: "-a", required: true,
|
22
|
+
desc: "Provide an APEX application ID"
|
23
|
+
option :file, aliases: "-f", required: true,
|
24
|
+
desc: "Provide an APEX application export file (.sql)"
|
25
|
+
option :url, aliases: "-u", required: true,
|
26
|
+
desc: "Provide a valid url"
|
30
27
|
def deploy(*)
|
31
28
|
if options[:help]
|
32
|
-
invoke :help, [
|
29
|
+
invoke :help, ["deploy"]
|
33
30
|
else
|
34
|
-
require_relative
|
31
|
+
require_relative "commands/deploy"
|
35
32
|
Rockette::Commands::Deploy.new(options).execute
|
36
33
|
end
|
37
34
|
end
|
38
35
|
|
39
|
-
desc
|
40
|
-
method_option :help, aliases:
|
41
|
-
desc:
|
42
|
-
option :app_id, aliases:
|
43
|
-
|
44
|
-
option :url, aliases:
|
45
|
-
|
36
|
+
desc "export", "Export and download application from target APEX environment"
|
37
|
+
method_option :help, aliases: "-h", type: :boolean,
|
38
|
+
desc: "Display usage information"
|
39
|
+
option :app_id, aliases: "-a", required: true,
|
40
|
+
desc: "Provide an APEX application ID"
|
41
|
+
option :url, aliases: "-u", required: true,
|
42
|
+
desc: "Provide a valid url"
|
46
43
|
def export(*)
|
47
44
|
if options[:help]
|
48
|
-
invoke :help, [
|
45
|
+
invoke :help, ["export"]
|
49
46
|
else
|
50
|
-
require_relative
|
47
|
+
require_relative "commands/export"
|
51
48
|
Rockette::Commands::Export.new(options).execute
|
52
49
|
end
|
53
50
|
end
|
54
51
|
|
55
|
-
desc
|
56
|
-
method_option :help, aliases:
|
57
|
-
desc:
|
52
|
+
desc "config", "Command description..."
|
53
|
+
method_option :help, aliases: "-h", type: :boolean,
|
54
|
+
desc: "Display usage information"
|
58
55
|
def config(*)
|
59
56
|
if options[:help]
|
60
|
-
invoke :help, [
|
57
|
+
invoke :help, ["config"]
|
61
58
|
else
|
62
|
-
require_relative
|
59
|
+
require_relative "commands/config"
|
63
60
|
Rockette::Commands::Config.new(options).execute
|
64
61
|
end
|
65
62
|
end
|
data/lib/rockette/command.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "forwardable"
|
4
4
|
|
5
5
|
module Rockette
|
6
|
+
# Enable tty- integration
|
6
7
|
class Command
|
7
8
|
extend Forwardable
|
8
9
|
|
@@ -24,7 +25,7 @@ module Rockette
|
|
24
25
|
#
|
25
26
|
# @api public
|
26
27
|
def command(**options)
|
27
|
-
require
|
28
|
+
require "tty-command"
|
28
29
|
TTY::Command.new(options)
|
29
30
|
end
|
30
31
|
|
@@ -34,7 +35,7 @@ module Rockette
|
|
34
35
|
#
|
35
36
|
# @api public
|
36
37
|
def cursor
|
37
|
-
require
|
38
|
+
require "tty-cursor"
|
38
39
|
TTY::Cursor
|
39
40
|
end
|
40
41
|
|
@@ -44,7 +45,7 @@ module Rockette
|
|
44
45
|
#
|
45
46
|
# @api public
|
46
47
|
def editor
|
47
|
-
require
|
48
|
+
require "tty-editor"
|
48
49
|
TTY::Editor
|
49
50
|
end
|
50
51
|
|
@@ -54,7 +55,7 @@ module Rockette
|
|
54
55
|
#
|
55
56
|
# @api public
|
56
57
|
def generator
|
57
|
-
require
|
58
|
+
require "tty-file"
|
58
59
|
TTY::File
|
59
60
|
end
|
60
61
|
|
@@ -64,7 +65,7 @@ module Rockette
|
|
64
65
|
#
|
65
66
|
# @api public
|
66
67
|
def pager(**options)
|
67
|
-
require
|
68
|
+
require "tty-pager"
|
68
69
|
TTY::Pager.new(options)
|
69
70
|
end
|
70
71
|
|
@@ -74,7 +75,7 @@ module Rockette
|
|
74
75
|
#
|
75
76
|
# @api public
|
76
77
|
def platform
|
77
|
-
require
|
78
|
+
require "tty-platform"
|
78
79
|
TTY::Platform.new
|
79
80
|
end
|
80
81
|
|
@@ -84,7 +85,7 @@ module Rockette
|
|
84
85
|
#
|
85
86
|
# @api public
|
86
87
|
def prompt(**options)
|
87
|
-
require
|
88
|
+
require "tty-prompt"
|
88
89
|
TTY::Prompt.new(options)
|
89
90
|
end
|
90
91
|
|
@@ -94,7 +95,7 @@ module Rockette
|
|
94
95
|
#
|
95
96
|
# @api public
|
96
97
|
def screen
|
97
|
-
require
|
98
|
+
require "tty-screen"
|
98
99
|
TTY::Screen
|
99
100
|
end
|
100
101
|
|
@@ -104,7 +105,7 @@ module Rockette
|
|
104
105
|
#
|
105
106
|
# @api public
|
106
107
|
def which(*args)
|
107
|
-
require
|
108
|
+
require "tty-which"
|
108
109
|
TTY::Which.which(*args)
|
109
110
|
end
|
110
111
|
|
@@ -114,7 +115,7 @@ module Rockette
|
|
114
115
|
#
|
115
116
|
# @api public
|
116
117
|
def exec_exist?(*args)
|
117
|
-
require
|
118
|
+
require "tty-which"
|
118
119
|
TTY::Which.exist?(*args)
|
119
120
|
end
|
120
121
|
end
|
@@ -1,17 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "../command"
|
4
4
|
|
5
5
|
module Rockette
|
6
6
|
module Commands
|
7
|
+
# Configure Rockette
|
7
8
|
class Config < Rockette::Command
|
9
|
+
include TextHelper
|
10
|
+
|
8
11
|
def initialize(options)
|
12
|
+
super()
|
9
13
|
@options = options
|
10
14
|
end
|
11
15
|
|
12
16
|
def execute(input: $stdin, output: $stdout)
|
13
17
|
# Command logic goes here ...
|
14
|
-
output.puts "
|
18
|
+
output.puts "Coming soon..."
|
19
|
+
check_input(input)
|
15
20
|
end
|
16
21
|
end
|
17
22
|
end
|
@@ -1,51 +1,53 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "../command"
|
4
4
|
|
5
5
|
module Rockette
|
6
6
|
module Commands
|
7
|
+
# Push export file and import into APEX
|
7
8
|
class Deploy < Rockette::Command
|
9
|
+
include TextHelper
|
10
|
+
|
8
11
|
def initialize(options)
|
12
|
+
super()
|
9
13
|
@options = options
|
14
|
+
@filey = "f#{@options[:app_id]}.sql"
|
10
15
|
end
|
11
16
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
def importer
|
18
|
+
body = CONF["deploy_body"]
|
19
|
+
body["app_id_src"] = @options[:app_id]
|
20
|
+
body["app_id_tgt"] = @options[:app_id]
|
21
|
+
# body["app_id_tgt"] = "0" #test app copy
|
22
|
+
url = "#{@options[:url]}deploy/app"
|
23
|
+
response = Rester.new(meth: "Post", params: body, url: url).rest_try
|
24
|
+
bail unless response
|
25
|
+
abort padder("Error. Got back response code: #{response.code}") unless (200..201).include? response.code
|
26
|
+
response
|
17
27
|
end
|
18
28
|
|
19
|
-
|
20
|
-
|
21
|
-
|
29
|
+
def pusher
|
30
|
+
push_hdrs = CONF["push_hdrs"]
|
31
|
+
push_hdrs["file_name"] = @filey
|
32
|
+
push_url = "#{@options[:url]}data_loader/blob"
|
33
|
+
# Push the chosen export file to the target system
|
34
|
+
filey = File.join(EXPORT_DIR, @filey)
|
35
|
+
response = Rester.new(headers: push_hdrs, meth: "Post", params: File.open(filey), url: push_url).rest_try
|
36
|
+
bail unless response
|
37
|
+
abort padder("Error. Got back response code: #{response.code}") unless (200..201).include? response.code
|
22
38
|
response
|
23
|
-
rescue StandardError => e
|
24
|
-
puts "Unable to push file because #{e.message}" # puts error
|
25
39
|
end
|
26
40
|
|
27
41
|
def execute(input: $stdin, output: $stdout)
|
42
|
+
check_input(input)
|
28
43
|
# Create and download export
|
29
|
-
output.puts "OK, deploying export file #{@
|
30
|
-
|
31
|
-
|
32
|
-
push_hdrs = CONF["push_hdrs"]
|
33
|
-
push_hdrs["file_name"] = filey
|
34
|
-
push_url = @options[:url] + 'data_loader/blob'
|
35
|
-
pusher = push_blob(File.open(filey), push_hdrs, push_url)
|
44
|
+
output.puts padder("OK, deploying export file #{@filey}")
|
45
|
+
pusher
|
46
|
+
output.puts padder("Pushed #{@filey} to instance and attempting import now...")
|
36
47
|
# If push was successful, request application import
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
body = CONF["deploy_body"]
|
41
|
-
body["app_id_src"] = @options[:app_id]
|
42
|
-
body["app_id_tgt"] = @options[:app_id]
|
43
|
-
body["app_id_tgt"] = "0" #test app copy
|
44
|
-
deploy = import_app(@options[:url] + 'deploy/app', body)
|
45
|
-
puts deploy.code
|
46
|
-
puts deploy.headers
|
47
|
-
puts deploy.body
|
48
|
-
end
|
48
|
+
sleep 1
|
49
|
+
importer
|
50
|
+
output.puts padder("Deployed #{@filey} to target APEX instance: #{@options[:url]}")
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
@@ -1,50 +1,55 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "../command"
|
4
4
|
|
5
5
|
module Rockette
|
6
6
|
module Commands
|
7
|
+
# Export and download APEX application
|
7
8
|
class Export < Rockette::Command
|
9
|
+
include TextHelper
|
10
|
+
|
8
11
|
def initialize(options)
|
12
|
+
super()
|
9
13
|
@options = options
|
14
|
+
@filey = "f#{@options[:app_id]}.sql"
|
15
|
+
end
|
16
|
+
|
17
|
+
def checker
|
18
|
+
app_url = "#{@options[:url]}deploy/apps/#{@options[:app_id]}"
|
19
|
+
response = Rester.new(url: app_url).rest_try
|
20
|
+
bail unless response
|
21
|
+
abort padder("App ID: #{@options[:app_id]}, not found. Received: #{response.code}") unless response.code == 200
|
10
22
|
end
|
11
23
|
|
12
|
-
|
13
|
-
|
14
|
-
|
24
|
+
def exporter
|
25
|
+
checker
|
26
|
+
puts padder("Found Application ID: #{@options[:app_id]}, proceeding...")
|
27
|
+
body = { "app_id" => @options[:app_id] }
|
28
|
+
export_url = "#{@options[:url]}deploy/app_export"
|
29
|
+
response = Rester.new(meth: "Post", params: body, url: export_url).rest_try
|
30
|
+
bail unless response
|
31
|
+
abort padder("Export failed for App ID: #{@options[:app_id]}.") unless (200..201).include? response.code
|
15
32
|
response
|
16
|
-
rescue StandardError => e
|
17
|
-
# change these, send back the error message, don't puts it!
|
18
|
-
puts "Unable to create export because #{e.message}" # puts error
|
19
33
|
end
|
20
34
|
|
21
|
-
|
22
|
-
|
23
|
-
response =
|
24
|
-
|
25
|
-
|
35
|
+
def grabber
|
36
|
+
export_url = "#{@options[:url]}deploy/app_export/#{@filey}"
|
37
|
+
response = Rester.new(url: export_url).rest_try
|
38
|
+
bail unless response
|
39
|
+
abort padder("Download failed for App ID: #{@options[:app_id]}.") unless (200..201).include? response.code
|
40
|
+
response
|
26
41
|
end
|
27
42
|
|
28
43
|
def execute(input: $stdin, output: $stdout)
|
44
|
+
check_input(input)
|
29
45
|
# Create and download export
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
puts
|
37
|
-
export = create_export(body, export_url)
|
38
|
-
if export.code == 201 # Check if export was successfully created first
|
39
|
-
sleep 1 # Change to query api to see if file is there
|
40
|
-
export_url = export_url + '/' + filey
|
41
|
-
response = grab_export(export_url)
|
42
|
-
# Now write file if export was grabbed.
|
43
|
-
if response.code == 200 || response.code == 201
|
44
|
-
File.open(filey, 'wb') {|file| file.write(response.body)}
|
45
|
-
puts "Downloaded #{filey} and all done here."
|
46
|
-
end
|
47
|
-
end
|
46
|
+
exporter
|
47
|
+
output.puts padder("Export created, downloading...")
|
48
|
+
sleep 1
|
49
|
+
response = grabber
|
50
|
+
# Write file if export was grabbed.
|
51
|
+
File.open(File.join(EXPORT_DIR, @filey), "wb") { |file| file.write(response.body) }
|
52
|
+
output.puts padder("Finished downloading #{@filey}. Have a good one!")
|
48
53
|
end
|
49
54
|
end
|
50
55
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Add common methods to Rockette module
|
4
|
+
module TextHelper
|
5
|
+
def bail
|
6
|
+
puts "Bailing, unable to check for application. Can you access the url from here?"
|
7
|
+
puts "Double check the url and make sure you have a network connection to the target."
|
8
|
+
exit
|
9
|
+
end
|
10
|
+
|
11
|
+
def check_input(input)
|
12
|
+
input unless input.nil?
|
13
|
+
end
|
14
|
+
|
15
|
+
def padder(str)
|
16
|
+
"\n#{str}\n"
|
17
|
+
end
|
18
|
+
end
|
data/lib/rockette/version.rb
CHANGED
data/rockette.gemspec
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
push_hdrs:
|
3
|
+
Content-Type: application/json
|
4
|
+
created_by: dcs_automation
|
5
|
+
message_date: ''
|
6
|
+
msg_from_addr: ''
|
7
|
+
msg_from_name: ''
|
8
|
+
file_charset: UTF-8
|
9
|
+
file_mimetype: text/plain
|
10
|
+
file_name: ''
|
11
|
+
file_type: sql
|
12
|
+
tags: ''
|
13
|
+
target_use: push_deployment
|
14
|
+
deploy_body:
|
15
|
+
app_id_src: ''
|
16
|
+
app_id_tgt: ''
|
17
|
+
blob_url: https://local.data_loader
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rockette
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kody Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -80,8 +80,10 @@ files:
|
|
80
80
|
- lib/rockette/commands/config.rb
|
81
81
|
- lib/rockette/commands/deploy.rb
|
82
82
|
- lib/rockette/commands/export.rb
|
83
|
+
- lib/rockette/text_helper.rb
|
83
84
|
- lib/rockette/version.rb
|
84
85
|
- rockette.gemspec
|
86
|
+
- templates/config.yml.erb
|
85
87
|
homepage: https://github.com/kodywilson/rockette
|
86
88
|
licenses:
|
87
89
|
- MIT
|