rockette 0.0.4 → 0.0.7

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: 2b09df3f177186a45f823508dab42147ee6edb53904d9d36a16ee30fb8022cd7
4
- data.tar.gz: 1a2545edb027108b655cd7eefdc2c96b70fac34cc0babb3fbfb924108f10e18a
3
+ metadata.gz: 45f4e263b11ea088b11682b38ce8a6c8c20ae571e466aa493ec263f8b4031361
4
+ data.tar.gz: d6d0764f28665933b40d254b0f35e69e5c066cc6ac5c4754f60bf84ef4681ebf
5
5
  SHA512:
6
- metadata.gz: f35882caea1f6cf7a168097993b42b69410d3965e077d83b86aeb43ac924e9e0c34f11760174760f2823efb86b14ff120e1f00b40790a64b54016b512385e9e6
7
- data.tar.gz: c72fa95ef890e46a0527465c82eb8dfa075448a69070a6d75401434e7d19af3ca478c4f47021d768d8b1a6bd84d3f4724c6f3ad5f33f96c543c7bdcd2ccbbfed
6
+ metadata.gz: 21689694006cfe6ddf0393c60eaa2a87fa4b5cf4e1638b86785f31e1ab71f522b9a97f05fafbbbad5113e4587b561233f6866a5fcbfa574d5a69c63062f68e91
7
+ data.tar.gz: c97f3474bead31707a45592dfaa81904c88df431ee60a1e6e0e008c74678f42222f1ff359df3e6f7adb3d482c5f0e2c60388ac7b45d55b8184b1c7cd3c4e32b3
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rockette (0.0.2)
4
+ rockette (0.0.6)
5
+ oci (~> 2.0)
5
6
  pastel (~> 0.0)
6
7
  rest-client (~> 2.0)
7
8
  thor (~> 1.0)
@@ -20,56 +21,63 @@ GEM
20
21
  domain_name (0.5.20190701)
21
22
  unf (>= 0.0.5, < 1.0.0)
22
23
  http-accept (1.7.0)
23
- http-cookie (1.0.3)
24
+ http-cookie (1.0.5)
24
25
  domain_name (~> 0.5)
26
+ inifile (3.0.0)
27
+ json (2.6.2)
28
+ jwt (2.3.0)
25
29
  method_source (1.0.0)
26
- mime-types (3.3.1)
30
+ mime-types (3.4.1)
27
31
  mime-types-data (~> 3.2015)
28
- mime-types-data (3.2021.0225)
29
- minitest (5.14.4)
32
+ mime-types-data (3.2022.0105)
33
+ minitest (5.15.0)
30
34
  netrc (0.11.0)
31
- parallel (1.20.1)
32
- parser (3.0.0.0)
35
+ oci (2.17.0)
36
+ inifile (~> 3.0, >= 3.0.0)
37
+ json (>= 1.4.6, < 3.0.0)
38
+ jwt (~> 2.1)
39
+ parallel (1.22.1)
40
+ parser (3.1.2.0)
33
41
  ast (~> 2.4.1)
34
42
  pastel (0.8.0)
35
43
  tty-color (~> 0.5)
36
- pry (0.14.0)
44
+ pry (0.14.1)
37
45
  coderay (~> 1.1)
38
46
  method_source (~> 1.0)
39
- rainbow (3.0.0)
40
- rake (13.0.3)
41
- regexp_parser (2.1.1)
47
+ rainbow (3.1.1)
48
+ rake (13.0.6)
49
+ regexp_parser (2.5.0)
42
50
  rest-client (2.1.0)
43
51
  http-accept (>= 1.7.0, < 2.0)
44
52
  http-cookie (>= 1.0.2, < 2.0)
45
53
  mime-types (>= 1.16, < 4.0)
46
54
  netrc (~> 0.8)
47
- rexml (3.2.4)
48
- rubocop (1.11.0)
55
+ rexml (3.2.5)
56
+ rubocop (1.30.0)
49
57
  parallel (~> 1.10)
50
- parser (>= 3.0.0.0)
58
+ parser (>= 3.1.0.0)
51
59
  rainbow (>= 2.2.2, < 4.0)
52
60
  regexp_parser (>= 1.8, < 3.0)
53
- rexml
54
- rubocop-ast (>= 1.2.0, < 2.0)
61
+ rexml (>= 3.2.5, < 4.0)
62
+ rubocop-ast (>= 1.18.0, < 2.0)
55
63
  ruby-progressbar (~> 1.7)
56
64
  unicode-display_width (>= 1.4.0, < 3.0)
57
- rubocop-ast (1.4.1)
58
- parser (>= 2.7.1.5)
65
+ rubocop-ast (1.18.0)
66
+ parser (>= 3.1.1.0)
59
67
  ruby-progressbar (1.11.0)
60
68
  strings (0.2.1)
61
69
  strings-ansi (~> 0.2)
62
70
  unicode-display_width (>= 1.5, < 3.0)
63
71
  unicode_utils (~> 1.4)
64
72
  strings-ansi (0.2.0)
65
- thor (1.1.0)
73
+ thor (1.2.1)
66
74
  tty-color (0.6.0)
67
- tty-config (0.4.0)
75
+ tty-config (0.5.1)
68
76
  tty-cursor (0.7.1)
69
- tty-editor (0.6.0)
77
+ tty-editor (0.7.0)
70
78
  tty-prompt (~> 0.22)
71
79
  tty-font (0.5.0)
72
- tty-prompt (0.23.0)
80
+ tty-prompt (0.23.1)
73
81
  pastel (~> 0.8)
74
82
  tty-reader (~> 0.8)
75
83
  tty-reader (0.9.0)
@@ -85,12 +93,13 @@ GEM
85
93
  tty-screen (~> 0.8)
86
94
  unf (0.1.4)
87
95
  unf_ext
88
- unf_ext (0.0.7.7)
89
- unicode-display_width (2.0.0)
96
+ unf_ext (0.0.8.2)
97
+ unicode-display_width (2.1.0)
90
98
  unicode_utils (1.4.0)
91
99
  wisper (2.0.1)
92
100
 
93
101
  PLATFORMS
102
+ ruby
94
103
  x86_64-darwin-19
95
104
 
96
105
  DEPENDENCIES
@@ -101,4 +110,4 @@ DEPENDENCIES
101
110
  rubocop (~> 1.7)
102
111
 
103
112
  BUNDLED WITH
104
- 2.2.11
113
+ 2.3.15
data/lib/requirements.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "base64"
3
4
  require "erb"
4
5
  require "json"
6
+ require "oci"
5
7
  require "pastel"
6
8
  require "psych"
7
9
  require "rest-client"
data/lib/rockette/cli.rb CHANGED
@@ -19,13 +19,13 @@ module Rockette
19
19
  method_option :help, aliases: "-h", type: :boolean,
20
20
  desc: "Display usage information"
21
21
  option :app_id, aliases: "-a", default: "0",
22
- desc: "Update this App ID with export set by '-f' Leave off or pass '-c' to copy export to target"
22
+ desc: "Update this App ID with export set by '-f' Omitting '-a' copies export to target"
23
23
  option :file, aliases: "-f", required: true,
24
24
  desc: "Provide an APEX application export file (sql)"
25
25
  option :url, aliases: "-u", required: true,
26
26
  desc: "Provide a valid APEX deployment url"
27
- option :copy, aliases: "-c", required: false,
28
- desc: "Use this flag if you are copying an application instead of overwriting"
27
+ option :secret, aliases: "-s", required: false,
28
+ desc: "Use this flag if you are using managed secrets"
29
29
  def deploy(*)
30
30
  if options[:help]
31
31
  invoke :help, ["deploy"]
@@ -12,11 +12,37 @@ module Rockette
12
12
  super()
13
13
  @options = options
14
14
  @filey = @options[:file]
15
- @conf = Psych.load(File.read(CONF))
16
- @body = @conf["deploy_body"]
17
- @body["app_id_src"] = "1" # @options[:app_id]
18
- @body["app_id_tgt"] = @options[:copy] ? 0 : @options[:app_id]
19
- @body["blob_url"] = @filey
15
+ if @options[:secret]
16
+ secret_id = @options[:secret]
17
+ signer = OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner.new
18
+ identity_client = OCI::Identity::IdentityClient.new(config: OCI::Config.new, signer: signer)
19
+ secret_client = OCI::Secrets::SecretsClient.new(config: OCI::Config.new, signer: signer)
20
+ secret_response = secret_client.get_secret_bundle(secret_id).data.secret_bundle_content.content
21
+ @conf = Psych.load(Base64.decode64(secret_response))
22
+ else
23
+ @conf = Psych.load(File.read(CONF))
24
+ end
25
+ @body = @conf["token_body"]
26
+ @hdrs = @conf["token_hdrs"]
27
+ @hdrs["Authorization"] = @conf["web_creds"][@options[:cred]] if @options[:cred]
28
+ @token = get_token
29
+ @hdrs["Authorization"] = "Bearer " + @token
30
+ end
31
+
32
+ def check_version(filey)
33
+ app_url = "#{@options[:url]}deploy/apps/#{@options[:app_id]}"
34
+ response = Rester.new(url: app_url, headers: @hdrs).rest_try
35
+ bail unless response
36
+ abort padder("App ID: #{@options[:app_id]}, not found. Received: #{response.code}") unless response.code == 200
37
+ deployed_version = JSON.parse(response.body)["version"]
38
+ fh = File.open(filey, 'r')
39
+ export_version = ''
40
+ fh.each_line do |line|
41
+ if line.match(/,p_flow_version=>'/)
42
+ export_version = line.match(/^,p_flow_version=>'(.*?)'$/)[1]
43
+ end
44
+ end
45
+ return deployed_version == export_version
20
46
  end
21
47
 
22
48
  def file_finder
@@ -26,22 +52,21 @@ module Rockette
26
52
  end
27
53
  end
28
54
 
29
- def importer
30
- url = "#{@options[:url]}deploy/app"
31
- response = Rester.new(meth: "Post", params: @body, url: url).rest_try
32
- bail unless response
33
- abort padder("Error. Got back response code: #{response.code}") unless (200..201).include? response.code
34
- response
55
+ def get_token
56
+ token_url = "#{@options[:url]}oauth/token"
57
+ response = Rester.new(headers: @hdrs, meth: "Post", params: @body, url: token_url).rest_try
58
+ return JSON.parse(response.body)["access_token"]
35
59
  end
36
60
 
37
- def pusher
38
- push_hdrs = @conf["push_hdrs"]
39
- push_hdrs["file_name"] = @filey
40
- push_url = "#{@options[:url]}data_loader/blob"
41
- # Push the chosen export file to the target system
61
+ def deployer
62
+ push_url = "#{@options[:url]}deploy/app/#{@options[:app_id]}/"
42
63
  filey = file_finder
43
64
  file_not_found if filey.is_a?(Array)
44
- response = Rester.new(headers: push_hdrs, meth: "Post", params: File.open(filey), url: push_url).rest_try
65
+ if @options[:app_id] != '0' then
66
+ abort padder("Error. Versions are identical, unable to deploy export") if check_version(filey)
67
+ end
68
+ @hdrs["Content-Type"] = "application/sql"
69
+ response = Rester.new(headers: @hdrs, meth: "Post", params: File.open(filey), url: push_url).rest_try
45
70
  bail unless response
46
71
  abort padder("Error. Got back response code: #{response.code}") unless (200..201).include? response.code
47
72
  response
@@ -49,13 +74,10 @@ module Rockette
49
74
 
50
75
  def execute(input: $stdin, output: $stdout)
51
76
  check_input(input)
52
- # Create and download export
77
+ filey = file_finder
78
+ file_not_found if filey.is_a?(Array)
53
79
  output.puts padder("Attempting to deploy export file #{@filey}...")
54
- pusher
55
- output.puts padder("Pushed #{@filey} to instance and attempting import now...")
56
- # If push was successful, request application import
57
- sleep 1
58
- importer
80
+ deployer
59
81
  output.puts padder("Deployed #{@filey} to target APEX instance: #{@options[:url]}")
60
82
  end
61
83
  end
@@ -11,12 +11,18 @@ module Rockette
11
11
  def initialize(options)
12
12
  super()
13
13
  @options = options
14
+ @conf = Psych.load(File.read(CONF))
15
+ @body = @conf["token_body"]
16
+ @hdrs = @conf["token_hdrs"]
17
+ @hdrs["Authorization"] = @conf["web_creds"][@options[:cred]] if @options[:cred]
14
18
  @filey = "f#{@options[:app_id]}.sql"
19
+ @token = get_token
20
+ @hdrs["Authorization"] = "Bearer " + @token
15
21
  end
16
22
 
17
23
  def checker
18
24
  app_url = "#{@options[:url]}deploy/apps/#{@options[:app_id]}"
19
- response = Rester.new(url: app_url).rest_try
25
+ response = Rester.new(url: app_url, headers: @hdrs).rest_try
20
26
  bail unless response
21
27
  abort padder("App ID: #{@options[:app_id]}, not found. Received: #{response.code}") unless response.code == 200
22
28
  end
@@ -24,29 +30,22 @@ module Rockette
24
30
  def exporter
25
31
  checker
26
32
  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
33
+ export_url = "#{@options[:url]}deploy/app/#{@options[:app_id]}"
34
+ response = Rester.new(url: export_url, headers: @hdrs).rest_try
30
35
  bail unless response
31
- abort padder("Export failed for App ID: #{@options[:app_id]}.") unless (200..201).include? response.code
36
+ abort padder("Download failed for App ID: #{@options[:app_id]}.") unless (200..201).include? response.code
32
37
  response
33
38
  end
34
39
 
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
40
+ def get_token
41
+ token_url = "#{@options[:url]}oauth/token"
42
+ response = Rester.new(headers: @hdrs, meth: "Post", params: @body, url: token_url).rest_try
43
+ return JSON.parse(response.body)["access_token"]
41
44
  end
42
45
 
43
46
  def execute(input: $stdin, output: $stdout)
44
47
  check_input(input)
45
- # Create and download export
46
- exporter
47
- output.puts padder("Export created, downloading...")
48
- sleep 1
49
- response = grabber
48
+ response = exporter
50
49
  # Write file if export was grabbed.
51
50
  save_file = @options[:file] || @filey
52
51
  File.open(File.join(EXPORT_DIR, save_file), "wb") { |file| file.write(response.body) }
@@ -47,6 +47,18 @@ module Rockette
47
47
  end
48
48
  end
49
49
 
50
+ def add_controller_cred
51
+ puts "Now that you have entered a controller url, please enter the OAuth client credentials for the controller."
52
+ user = @prompt.ask("User:")
53
+ pass = @prompt.ask("Pass:")
54
+ basey = 'Basic ' + Base64.encode64(user + ":" + pass).tr("\n", "")
55
+ @config.set(:rockette, :controller_cred, value: basey)
56
+ @config.write(force: true)
57
+ refresh_conf
58
+ puts "Choose View Resources and then All Applications to automate adding client credentials for each environment."
59
+ puts "You will need these credentials to use Rockette to deploy, export, and update applications."
60
+ end
61
+
50
62
  def add_url
51
63
  uri = @prompt.ask("Please enter APEX deployment URI (base path):") do |u|
52
64
  u.validate(%r{^https://\w+.\w+})
@@ -70,6 +82,7 @@ module Rockette
70
82
  response = @prompt.yes?("Would you like to enter a URI?")
71
83
  if response == true
72
84
  add_url
85
+ add_controller_cred
73
86
  else
74
87
  response = @prompt.yes?("Would you like to disable these checks in the future?")
75
88
  @config.set(:rockette, :check_for_url, value: false) if response == true
@@ -45,21 +45,24 @@ module Rockette
45
45
  def add_app
46
46
  puts padder("Let's choose an export to add")
47
47
  file = choose_file
48
- url = choose_env
48
+ env = choose_env
49
+ return if env == -1
50
+ url = env[0]
49
51
  puts padder("You chose to add #{file} to the environment at #{url}")
50
52
  puts
51
53
  return unless @prompt.yes?("Proceed with the deployment?")
52
54
 
53
55
  options = Thor::CoreExt::HashWithIndifferentAccess.new "app_id" => "0", "url" => url, "file" => file,
54
- "force" => true
56
+ "cred" => env[1], "force" => true
55
57
  Rockette::Commands::Deploy.new(options).execute
56
58
  puts
57
59
  end
58
60
 
59
- def choose_app(apps_url)
60
- apps = Rockette::Viewer.new.applications(apps_url)
61
+ def choose_app(apps_url, cred)
62
+ apps = Rockette::Viewer.new.applications(apps_url, cred)
61
63
  list = list_builder(apps)
62
64
  action = @prompt.slider("Application to update => ", list, default: 1)
65
+ return -1 if action == apps.count + 1
63
66
 
64
67
  apps[action - 1]
65
68
  end
@@ -68,7 +71,8 @@ module Rockette
68
71
  enviros = Rockette::Viewer.new.environments
69
72
  list = list_builder(enviros)
70
73
  action = @prompt.select("Which environment?", list)
71
- enviros[action - 1]["deployment_api"]
74
+ return -1 if action == enviros.count + 1
75
+ [enviros[action - 1]["deployment_api"], enviros[action - 1]["web_cred"]]
72
76
  end
73
77
 
74
78
  def choose_file
@@ -90,15 +94,18 @@ module Rockette
90
94
  def updater
91
95
  puts padder("Please choose the export with your updated application code")
92
96
  file = choose_file
93
- url = choose_env
94
- app = choose_app(url)
97
+ env = choose_env
98
+ return if env == -1
99
+ url = env[0]
100
+ app = choose_app(url, env[1])
101
+ return if app == -1
95
102
  puts "Application: #{app["application_name"]} | App ID: #{app["application_id"]} | Env URI: #{url}"
96
103
  puts "will be updated with the code from export: #{file}"
97
104
  puts
98
105
  return unless @prompt.yes?("Proceed with the deployment?")
99
106
 
100
107
  options = Thor::CoreExt::HashWithIndifferentAccess.new "app_id" => app["application_id"], "url" => url,
101
- "file" => file, "force" => true
108
+ "cred" => env[1], "file" => file, "force" => true
102
109
  Rockette::Commands::Deploy.new(options).execute
103
110
  puts
104
111
  end
@@ -27,19 +27,20 @@ module Rockette
27
27
  break if action == list.length
28
28
 
29
29
  apps_url = enviros[action - 1]["deployment_api"]
30
- choose_app(apps_url)
30
+ cred = enviros[action - 1]["web_cred"]
31
+ choose_app(apps_url, cred)
31
32
  end
32
33
  end
33
34
 
34
- def do_export(app_id, apps_url)
35
+ def do_export(app_id, apps_url, cred)
35
36
  response = @prompt.yes?("Would you like to enter a filename for the export?")
36
37
  if response == true
37
38
  file = @prompt.ask("Please enter your desired filename:")
38
- options = Thor::CoreExt::HashWithIndifferentAccess.new "app_id" => app_id, "url" => apps_url, "file" => file,
39
- "force" => true
39
+ options = Thor::CoreExt::HashWithIndifferentAccess.new "app_id" => app_id, "url" => apps_url, "cred" => cred,
40
+ "file" => file, "force" => true
40
41
  else
41
42
  puts padder("Saving under default file name: f#{app_id}.sql")
42
- options = Thor::CoreExt::HashWithIndifferentAccess.new "app_id" => app_id, "url" => apps_url, "force" => true
43
+ options = Thor::CoreExt::HashWithIndifferentAccess.new "app_id" => app_id, "url" => apps_url, "cred" => cred, "force" => true
43
44
  end
44
45
  Rockette::Commands::Export.new(options).execute
45
46
  puts
@@ -47,15 +48,15 @@ module Rockette
47
48
 
48
49
  protected
49
50
 
50
- def choose_app(apps_url)
51
+ def choose_app(apps_url, cred)
51
52
  loop do
52
- apps = Rockette::Viewer.new.applications(apps_url)
53
+ apps = Rockette::Viewer.new.applications(apps_url, cred)
53
54
  list = list_builder(apps)
54
55
  action = @prompt.slider("Download application => ", list, default: 1)
55
56
  break if action == list.length
56
57
 
57
58
  app_id = apps[action - 1]["application_id"]
58
- do_export(app_id, apps_url)
59
+ do_export(app_id, apps_url, cred)
59
60
  end
60
61
  end
61
62
 
@@ -8,11 +8,25 @@ module Rockette
8
8
  include TextHelper
9
9
 
10
10
  def initialize
11
+ @config = TTY::Config.new
12
+ @config.append_path APP_PATH
13
+ @config.read
11
14
  @conf = Psych.load(File.read(CONF))
15
+ @body = @conf["token_body"]
16
+ @hdrs = @conf["token_hdrs"]
17
+ #@hdrs["Authorization"] = @conf["web_creds"]["controller_cred"]
18
+ token_url = @conf["rockette"]["controller_url"].sub!('deploy/', '')
19
+ @token = get_token(token_url, "controller_cred")
20
+ @hdrs["Authorization"] = "Bearer " + @token
12
21
  @pastel = Pastel.new
13
22
  @prompt = TTY::Prompt.new
14
23
  @spinner = TTY::Spinner.new # ("[:spinner] Loading APEX environments ...", format: pulse_2)
15
- @view_actions = { "🏔 APEX Environments" => 1, "🎭 Registered Applications" => 2, "⬅️ Go Back" => 3 }
24
+ @view_actions = { "🏔 APEX Environments" => 1, "🎭 Registered Applications" => 2,
25
+ "🌎 Applications by Environment" => 3, "⬅️ Go Back" => 4 }
26
+ end
27
+
28
+ def self.config
29
+ @config ||= self.class.new.config
16
30
  end
17
31
 
18
32
  def launch!
@@ -22,7 +36,7 @@ module Rockette
22
36
  # input/action loop
23
37
  loop do
24
38
  action = @prompt.select("Which would you like to see?", @view_actions)
25
- break if action == 3
39
+ break if action == 4
26
40
 
27
41
  do_action(action)
28
42
  end
@@ -33,40 +47,69 @@ module Rockette
33
47
  when 1
34
48
  puts
35
49
  environments unless @table_env
36
- @spinner.auto_spin
37
- sleep(1)
38
- @spinner.stop
39
- puts @table_env.render(:ascii)
50
+ spinner(0.5)
51
+ puts @table_env.render(:unicode, resize: true, border: { style: :yellow })
40
52
  puts
41
53
  when 2
42
54
  puts
43
55
  registered unless @table_reg
44
- puts @table_reg.render(:ascii)
56
+ puts @table_reg.render(:unicode, resize: true, border: { style: :yellow })
57
+ puts
58
+ when 3
59
+ puts
60
+ puts "This can take a while...hang tight!"
61
+ puts
62
+ all_apps unless @table_all_apps
63
+ puts @table_all_apps.render(:unicode, resize: true, border: { style: :yellow })
45
64
  puts
46
65
  else
47
66
  puts "\nI don't understand that command.\n\n"
48
67
  end
49
68
  end
50
69
 
51
- def ape_e_i(uri)
52
- response = Rester.new(url: uri).rest_try
70
+ def add_web_cred(env_cred, env_name)
71
+ puts "You are attempting to access a resource that requires authentication."
72
+ puts "Please enter the OAuth client credentials for the #{env_name} environment."
73
+ user = @prompt.ask("User:")
74
+ pass = @prompt.ask("Pass:")
75
+ basey = 'Basic ' + Base64.encode64(user + ":" + pass).tr("\n", "")
76
+ @config.set(:web_creds, env_cred.to_sym, value: basey)
77
+ @config.write(force: true)
78
+ refresh_conf
79
+ end
80
+
81
+ def ape_e_i(uri, headers = @hdrs)
82
+ response = Rester.new(url: uri, headers: headers).rest_try
53
83
  bail unless response
54
84
  abort padder("#{uri} didn't work. Received: #{response.code}") unless response.code == 200
55
85
  response
56
86
  end
57
87
 
58
- def applications(url)
59
- uri = "#{url}deploy/apps"
60
- response = ape_e_i(uri)
88
+ def applications(url, cred)
89
+ headers = @hdrs
90
+ #@hdrs["Authorization"] = @conf["web_creds"][cred]
91
+ @token = get_token(url, cred)
92
+ @hdrs["Authorization"] = "Bearer " + @token
93
+ uri = "#{url}deploy/apps/"
94
+
95
+ response = ape_e_i(uri, @hdrs)
96
+ @hdrs = headers
61
97
  JSON.parse(response.body)["items"]
62
98
  end
63
99
 
64
100
  def environments
65
101
  uri = "#{@conf["rockette"]["controller_url"]}deploy/environments/"
66
102
  response = ape_e_i(uri)
67
- @table_env = TTY::Table.new(header: ["Environment Name", "API", "Domain", "Owner", "Workspace"])
103
+ @table_env = TTY::Table.new(header: ["Environment Name", "API", "Domain", "Owner", "Workspace", "Web Cred"])
68
104
  items = JSON.parse(response.body)["items"]
69
- items.each { |h| @table_env << [h["name"], h["deployment_api"], h["domain"], h["owner"], h["workspace"]] }
105
+ items.each { |h| @table_env << [h["name"], h["deployment_api"], h["domain"], h["owner"], h["workspace"], h["web_cred"]] }
106
+ end
107
+
108
+ def get_token(url, cred)
109
+ @hdrs["Authorization"] = @conf["web_creds"][cred]
110
+ token_url = url + "oauth/token"
111
+ response = Rester.new(headers: @hdrs, meth: "Post", params: @body, url: token_url).rest_try
112
+ return JSON.parse(response.body)["access_token"]
70
113
  end
71
114
 
72
115
  def registered
@@ -78,5 +121,34 @@ module Rockette
78
121
  @table_reg << [h["registered_name"], h["src_app_id"], h["src_url"], h["tgt_app_id"], h["tgt_url"]]
79
122
  end
80
123
  end
124
+
125
+ def all_apps
126
+ environments unless @table_env
127
+ @table_all_apps = TTY::Table.new(header: ["Environment Name", "Application Name", "Application ID"])
128
+ @table_env.each do |env|
129
+ next if env[0] == "Environment Name"
130
+
131
+ creds = Hash.new
132
+ creds = @conf["web_creds"]
133
+ add_web_cred(env[5], env[0]) unless creds.has_key?(env[5])
134
+
135
+ apps = applications(env[1], env[5])
136
+ apps.each do |app|
137
+ @table_all_apps << [env[0], app["application_name"], app["application_id"]]
138
+ end
139
+ end
140
+ end
141
+
142
+ def refresh_conf
143
+ @config.read
144
+ @conf = Psych.load(File.read(CONF))
145
+ end
146
+
147
+ def spinner(dur=1)
148
+ @spinner.auto_spin
149
+ sleep(dur)
150
+ @spinner.stop
151
+ end
152
+
81
153
  end
82
154
  end
@@ -44,6 +44,9 @@ module Rockette
44
44
  puts @pastel.yellow(font.write("Rockette"))
45
45
  puts
46
46
  puts "-" * 85
47
+ puts "Version: " + VERSION
48
+ puts "-" * 14
49
+ puts
47
50
  puts "Rockette helps export and deploy APEX applications."
48
51
  puts
49
52
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rockette
4
- VERSION = "0.0.4"
4
+ VERSION = "0.0.7"
5
5
  end
data/lib/rockette.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require_relative "requirements"
4
4
 
5
5
  # Set paths
6
- APP_PATH = if File.exist?(File.join("/", "usr", "app")) # Why Docker, why?
6
+ APP_PATH = if File.exist?(File.join("/", "usr", "app"))
7
7
  File.join("/", "usr", "app", ".rockette")
8
8
  elsif File.exist?(Dir.home)
9
9
  File.join(Dir.home, ".rockette")
data/rockette.gemspec CHANGED
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "pry", "~> 0.0"
34
34
 
35
35
  # Dependencies
36
+ spec.add_dependency "oci", "~> 2.0"
36
37
  spec.add_dependency "pastel", "~> 0.0"
37
38
  spec.add_dependency "rest-client", "~> 2.0"
38
39
  spec.add_dependency "thor", "~> 1.0"
@@ -42,5 +43,4 @@ Gem::Specification.new do |spec|
42
43
  spec.add_dependency "tty-prompt", "~> 0.0"
43
44
  spec.add_dependency "tty-spinner", "~> 0.0"
44
45
  spec.add_dependency "tty-table", "~> 0.0"
45
-
46
46
  end
@@ -1,20 +1,9 @@
1
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
2
+ token_body:
3
+ grant_type: client_credentials
4
+ token_hdrs:
5
+ Content-Type: application/x-www-form-urlencoded
18
6
  rockette:
19
7
  check_for_url: true
8
+ controller_cred: ''
20
9
  controller_url: ''
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
4
+ version: 0.0.7
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-03-30 00:00:00.000000000 Z
11
+ date: 2022-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: oci
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: pastel
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -213,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
227
  - !ruby/object:Gem::Version
214
228
  version: '0'
215
229
  requirements: []
216
- rubygems_version: 3.1.4
230
+ rubygems_version: 3.1.6
217
231
  signing_key:
218
232
  specification_version: 4
219
233
  summary: Oracle APEX Deployment Assistant