rockette 0.0.4 → 0.0.5

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: ee0d2270c8442e3e6b696cce15e9ac765a5d2c42e6a7ab84dc2c2a9b057d90e8
4
+ data.tar.gz: 70d91cff0436629fe0cdcf50f7f5201047daee8a6504ef87a3ffc009c0143035
5
5
  SHA512:
6
- metadata.gz: f35882caea1f6cf7a168097993b42b69410d3965e077d83b86aeb43ac924e9e0c34f11760174760f2823efb86b14ff120e1f00b40790a64b54016b512385e9e6
7
- data.tar.gz: c72fa95ef890e46a0527465c82eb8dfa075448a69070a6d75401434e7d19af3ca478c4f47021d768d8b1a6bd84d3f4724c6f3ad5f33f96c543c7bdcd2ccbbfed
6
+ metadata.gz: 9c7afa7c6b7c0a4f39a4ebfa16ae70fa9b15e4a83e32930e30f2dbbae1aafa04850061de0b63e44f5023eb346e3ac42eaa68e56bd8d0a7db2b1b1cf3efc6b32f
7
+ data.tar.gz: 0ac4932e7d0302bcdf9e3df9b9c8d6c4ce12a16e0831b8de9fe947a3850ca45633fa79cbdf1409ecd833bd76a42172beb6b681128d72177421eea068d4b8c418
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.5)
5
+ oci (~> 2.0)
5
6
  pastel (~> 0.0)
6
7
  rest-client (~> 2.0)
7
8
  thor (~> 1.0)
@@ -20,42 +21,49 @@ 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.4)
24
25
  domain_name (~> 0.5)
26
+ inifile (3.0.0)
27
+ json (2.5.1)
28
+ jwt (2.2.3)
25
29
  method_source (1.0.0)
26
30
  mime-types (3.3.1)
27
31
  mime-types-data (~> 3.2015)
28
- mime-types-data (3.2021.0225)
32
+ mime-types-data (3.2021.0901)
29
33
  minitest (5.14.4)
30
34
  netrc (0.11.0)
31
- parallel (1.20.1)
32
- parser (3.0.0.0)
35
+ oci (2.15.0)
36
+ inifile (~> 3.0, >= 3.0.0)
37
+ json (>= 1.4.6, < 3.0.0)
38
+ jwt (~> 2.1)
39
+ parallel (1.21.0)
40
+ parser (3.0.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
47
  rainbow (3.0.0)
40
- rake (13.0.3)
48
+ rake (13.0.6)
41
49
  regexp_parser (2.1.1)
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.21.0)
49
57
  parallel (~> 1.10)
50
58
  parser (>= 3.0.0.0)
51
59
  rainbow (>= 2.2.2, < 4.0)
52
60
  regexp_parser (>= 1.8, < 3.0)
53
61
  rexml
54
- rubocop-ast (>= 1.2.0, < 2.0)
62
+ rubocop-ast (>= 1.9.1, < 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.11.0)
66
+ parser (>= 3.0.1.1)
59
67
  ruby-progressbar (1.11.0)
60
68
  strings (0.2.1)
61
69
  strings-ansi (~> 0.2)
@@ -64,12 +72,12 @@ GEM
64
72
  strings-ansi (0.2.0)
65
73
  thor (1.1.0)
66
74
  tty-color (0.6.0)
67
- tty-config (0.4.0)
75
+ tty-config (0.5.0)
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)
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
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 = JSON.parse(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
+ @token = get_token
28
+ @hdrs["Authorization"] = "Bearer " + @token
29
+ @hdrs["Content-Type"] = "application/sql"
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,20 @@ 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
+ response = Rester.new(headers: @hdrs, meth: "Post", params: File.open(filey), url: push_url).rest_try
45
69
  bail unless response
46
70
  abort padder("Error. Got back response code: #{response.code}") unless (200..201).include? response.code
47
71
  response
@@ -49,13 +73,10 @@ module Rockette
49
73
 
50
74
  def execute(input: $stdin, output: $stdout)
51
75
  check_input(input)
52
- # Create and download export
76
+ filey = file_finder
77
+ file_not_found if filey.is_a?(Array)
53
78
  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
79
+ deployer
59
80
  output.puts padder("Deployed #{@filey} to target APEX instance: #{@options[:url]}")
60
81
  end
61
82
  end
@@ -11,12 +11,17 @@ 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"]
14
17
  @filey = "f#{@options[:app_id]}.sql"
18
+ @token = get_token
19
+ @hdrs["Authorization"] = "Bearer " + @token
15
20
  end
16
21
 
17
22
  def checker
18
23
  app_url = "#{@options[:url]}deploy/apps/#{@options[:app_id]}"
19
- response = Rester.new(url: app_url).rest_try
24
+ response = Rester.new(url: app_url, headers: @hdrs).rest_try
20
25
  bail unless response
21
26
  abort padder("App ID: #{@options[:app_id]}, not found. Received: #{response.code}") unless response.code == 200
22
27
  end
@@ -24,29 +29,22 @@ module Rockette
24
29
  def exporter
25
30
  checker
26
31
  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
32
+ export_url = "#{@options[:url]}deploy/app/#{@options[:app_id]}"
33
+ response = Rester.new(url: export_url, headers: @hdrs).rest_try
30
34
  bail unless response
31
- abort padder("Export failed for App ID: #{@options[:app_id]}.") unless (200..201).include? response.code
35
+ abort padder("Download failed for App ID: #{@options[:app_id]}.") unless (200..201).include? response.code
32
36
  response
33
37
  end
34
38
 
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
39
+ def get_token
40
+ token_url = "#{@options[:url]}oauth/token"
41
+ response = Rester.new(headers: @hdrs, meth: "Post", params: @body, url: token_url).rest_try
42
+ return JSON.parse(response.body)["access_token"]
41
43
  end
42
44
 
43
45
  def execute(input: $stdin, output: $stdout)
44
46
  check_input(input)
45
- # Create and download export
46
- exporter
47
- output.puts padder("Export created, downloading...")
48
- sleep 1
49
- response = grabber
47
+ response = exporter
50
48
  # Write file if export was grabbed.
51
49
  save_file = @options[:file] || @filey
52
50
  File.open(File.join(EXPORT_DIR, save_file), "wb") { |file| file.write(response.body) }
@@ -12,7 +12,8 @@ module Rockette
12
12
  @pastel = Pastel.new
13
13
  @prompt = TTY::Prompt.new
14
14
  @spinner = TTY::Spinner.new # ("[:spinner] Loading APEX environments ...", format: pulse_2)
15
- @view_actions = { "🏔 APEX Environments" => 1, "🎭 Registered Applications" => 2, "⬅️ Go Back" => 3 }
15
+ @view_actions = { "🏔 APEX Environments" => 1, "🎭 Registered Applications" => 2,
16
+ "🌎 Applications by Environment" => 3, "⬅️ Go Back" => 4 }
16
17
  end
17
18
 
18
19
  def launch!
@@ -22,7 +23,7 @@ module Rockette
22
23
  # input/action loop
23
24
  loop do
24
25
  action = @prompt.select("Which would you like to see?", @view_actions)
25
- break if action == 3
26
+ break if action == 4
26
27
 
27
28
  do_action(action)
28
29
  end
@@ -33,15 +34,20 @@ module Rockette
33
34
  when 1
34
35
  puts
35
36
  environments unless @table_env
36
- @spinner.auto_spin
37
- sleep(1)
38
- @spinner.stop
39
- puts @table_env.render(:ascii)
37
+ spinner(0.5)
38
+ puts @table_env.render(:unicode, resize: true, border: { style: :yellow })
40
39
  puts
41
40
  when 2
42
41
  puts
43
42
  registered unless @table_reg
44
- puts @table_reg.render(:ascii)
43
+ puts @table_reg.render(:unicode, resize: true, border: { style: :yellow })
44
+ puts
45
+ when 3
46
+ puts
47
+ puts "This can take a while...hang tight!"
48
+ puts
49
+ all_apps unless @table_all_apps
50
+ puts @table_all_apps.render(:unicode, resize: true, border: { style: :yellow })
45
51
  puts
46
52
  else
47
53
  puts "\nI don't understand that command.\n\n"
@@ -78,5 +84,25 @@ module Rockette
78
84
  @table_reg << [h["registered_name"], h["src_app_id"], h["src_url"], h["tgt_app_id"], h["tgt_url"]]
79
85
  end
80
86
  end
87
+
88
+ def all_apps
89
+ environments unless @table_env
90
+ @table_all_apps = TTY::Table.new(header: ["Environment Name", "Application Name", "Application ID"])
91
+ @table_env.each do |env|
92
+ next if env[0] == "Environment Name"
93
+
94
+ apps = applications(env[1])
95
+ apps.each do |app|
96
+ @table_all_apps << [env[0], app["application_name"], app["application_id"]]
97
+ end
98
+ end
99
+ end
100
+
101
+ def spinner(dur=1)
102
+ @spinner.auto_spin
103
+ sleep(dur)
104
+ @spinner.stop
105
+ end
106
+
81
107
  end
82
108
  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.5"
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,8 @@
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
20
8
  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.5
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: 2021-09-29 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