kpm 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +138 -0
  4. data/Gemfile +2 -0
  5. data/README.adoc +126 -109
  6. data/Rakefile +2 -1
  7. data/bin/kpm +4 -2
  8. data/kpm.gemspec +10 -8
  9. data/lib/kpm.rb +3 -0
  10. data/lib/kpm/account.rb +269 -337
  11. data/lib/kpm/base_artifact.rb +40 -36
  12. data/lib/kpm/base_installer.rb +71 -84
  13. data/lib/kpm/blob.rb +29 -0
  14. data/lib/kpm/cli.rb +3 -1
  15. data/lib/kpm/coordinates.rb +10 -12
  16. data/lib/kpm/database.rb +93 -103
  17. data/lib/kpm/diagnostic_file.rb +126 -146
  18. data/lib/kpm/formatter.rb +76 -48
  19. data/lib/kpm/inspector.rb +24 -34
  20. data/lib/kpm/installer.rb +53 -46
  21. data/lib/kpm/kaui_artifact.rb +4 -3
  22. data/lib/kpm/killbill_plugin_artifact.rb +10 -7
  23. data/lib/kpm/killbill_server_artifact.rb +24 -10
  24. data/lib/kpm/migrations.rb +26 -11
  25. data/lib/kpm/nexus_helper/actions.rb +45 -9
  26. data/lib/kpm/nexus_helper/github_api_calls.rb +70 -0
  27. data/lib/kpm/nexus_helper/nexus_api_calls_v2.rb +130 -108
  28. data/lib/kpm/nexus_helper/nexus_facade.rb +5 -3
  29. data/lib/kpm/plugins_directory.rb +14 -9
  30. data/lib/kpm/plugins_directory.yml +16 -175
  31. data/lib/kpm/plugins_manager.rb +29 -24
  32. data/lib/kpm/sha1_checker.rb +56 -15
  33. data/lib/kpm/system.rb +104 -135
  34. data/lib/kpm/system_helpers/cpu_information.rb +56 -55
  35. data/lib/kpm/system_helpers/disk_space_information.rb +60 -63
  36. data/lib/kpm/system_helpers/entropy_available.rb +37 -39
  37. data/lib/kpm/system_helpers/memory_information.rb +52 -51
  38. data/lib/kpm/system_helpers/os_information.rb +45 -47
  39. data/lib/kpm/system_helpers/system_proxy.rb +10 -10
  40. data/lib/kpm/tasks.rb +370 -443
  41. data/lib/kpm/tenant_config.rb +68 -83
  42. data/lib/kpm/tomcat_manager.rb +10 -8
  43. data/lib/kpm/trace_logger.rb +18 -16
  44. data/lib/kpm/uninstaller.rb +81 -14
  45. data/lib/kpm/utils.rb +13 -14
  46. data/lib/kpm/version.rb +3 -1
  47. data/packaging/Gemfile +2 -0
  48. data/pom.xml +1 -1
  49. data/spec/kpm/remote/base_artifact_spec.rb +33 -17
  50. data/spec/kpm/remote/base_installer_spec.rb +35 -34
  51. data/spec/kpm/remote/github_api_calls_spec.rb +40 -0
  52. data/spec/kpm/remote/installer_spec.rb +80 -78
  53. data/spec/kpm/remote/kaui_artifact_spec.rb +7 -6
  54. data/spec/kpm/remote/killbill_plugin_artifact_spec.rb +25 -30
  55. data/spec/kpm/remote/killbill_server_artifact_spec.rb +30 -13
  56. data/spec/kpm/remote/migrations_spec.rb +12 -11
  57. data/spec/kpm/remote/nexus_facade_spec.rb +32 -28
  58. data/spec/kpm/remote/tenant_config_spec.rb +30 -29
  59. data/spec/kpm/remote/tomcat_manager_spec.rb +4 -3
  60. data/spec/kpm/unit/actions_spec.rb +52 -0
  61. data/spec/kpm/unit/base_artifact_spec.rb +19 -18
  62. data/spec/kpm/unit/cpu_information_spec.rb +67 -0
  63. data/spec/kpm/unit/disk_space_information_spec.rb +47 -0
  64. data/spec/kpm/unit/entropy_information_spec.rb +36 -0
  65. data/spec/kpm/unit/formatter_spec.rb +163 -0
  66. data/spec/kpm/unit/inspector_spec.rb +34 -42
  67. data/spec/kpm/unit/installer_spec.rb +7 -6
  68. data/spec/kpm/unit/memory_information_spec.rb +102 -0
  69. data/spec/kpm/unit/os_information_spec.rb +38 -0
  70. data/spec/kpm/unit/plugins_directory_spec.rb +38 -22
  71. data/spec/kpm/unit/plugins_manager_spec.rb +62 -66
  72. data/spec/kpm/unit/sha1_checker_spec.rb +107 -60
  73. data/spec/kpm/unit/uninstaller_spec.rb +118 -72
  74. data/spec/kpm/unit_mysql/account_spec.rb +144 -143
  75. data/spec/spec_helper.rb +20 -18
  76. data/tasks/package.rake +18 -18
  77. metadata +26 -22
@@ -1,66 +1,64 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module KPM
2
4
  module SystemProxy
3
- module OsInformation
4
- class << self
5
+ class OsInformation
6
+ attr_reader :os_info, :labels
5
7
 
6
- def fetch
7
- os_information = nil
8
- if OS.windows?
9
- os_information = fetch_windows
10
- elsif OS.linux?
11
- os_information = fetch_linux
12
- elsif OS.mac?
13
- os_information = fetch_mac
14
- end
8
+ def initialize
9
+ @os_info = fetch
10
+ @labels = [{ label: :os_detail },
11
+ { label: :value }]
12
+ end
15
13
 
16
- os_information
17
- end
14
+ private
18
15
 
19
- def get_labels
20
- labels = [{:label => :os_detail},
21
- {:label => :value}]
22
- labels
16
+ def fetch
17
+ os_information = nil
18
+ if OS.windows?
19
+ os_information = fetch_windows
20
+ elsif OS.linux?
21
+ os_information = fetch_linux
22
+ elsif OS.mac?
23
+ os_information = fetch_mac
23
24
  end
24
25
 
25
- private
26
- def fetch_linux
27
- os_data = `lsb_release -a 2>&1`
26
+ os_information
27
+ end
28
28
 
29
- if os_data.nil? || os_data.include?('lsb_release: not found')
30
- os_data = `cat /etc/issue 2>&1`
31
- os_data = 'Description:'+os_data.gsub('\n \l','')
32
- end
29
+ def fetch_linux
30
+ os_data = `lsb_release -a 2>&1`
33
31
 
34
- os = get_hash(os_data)
35
- os
36
- end
32
+ if os_data.nil? || os_data.include?('lsb_release: not found')
33
+ os_data = `cat /etc/issue 2>&1`
34
+ os_data = 'Description:' + os_data.gsub('\n \l', '')
35
+ end
37
36
 
38
- def fetch_mac
39
- os_data = `sw_vers`
40
- os = get_hash(os_data)
41
- os
42
- end
37
+ build_hash(os_data)
38
+ end
43
39
 
44
- def fetch_windows
45
- os_data = `systeminfo | findstr /C:"OS"`
46
- os = get_hash(os_data)
47
- os
48
- end
40
+ def fetch_mac
41
+ os_data = `sw_vers`
42
+ build_hash(os_data)
43
+ end
49
44
 
50
- def get_hash(data)
51
- os = Hash.new
45
+ def fetch_windows
46
+ os_data = `systeminfo | findstr /C:"OS"`
47
+ build_hash(os_data)
48
+ end
52
49
 
53
- unless data.nil?
54
- data.split("\n").each do |info|
55
- infos = info.split(':')
56
- os[infos[0].to_s.strip] = {:os_detail => infos[0].to_s.strip, :value => infos[1].to_s.strip}
57
- end
58
- end
50
+ def build_hash(data)
51
+ os = {}
59
52
 
60
- os
53
+ unless data.nil?
54
+ data.split("\n").each do |info|
55
+ infos = info.split(':')
56
+ os[infos[0].to_s.strip] = { os_detail: infos[0].to_s.strip, value: infos[1].to_s.strip }
61
57
  end
58
+ end
62
59
 
60
+ os
63
61
  end
64
62
  end
65
63
  end
66
- end
64
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'cpu_information'
2
4
  require_relative 'memory_information'
3
5
  require_relative 'disk_space_information'
@@ -5,24 +7,22 @@ require_relative 'entropy_available'
5
7
  require_relative 'os_information'
6
8
  module KPM
7
9
  module SystemProxy
8
-
9
10
  module OS
10
- def OS.windows?
11
- (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RbConfig::CONFIG["host_os"]) != nil
11
+ def self.windows?
12
+ (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RbConfig::CONFIG['host_os']) != nil
12
13
  end
13
14
 
14
- def OS.mac?
15
- (/darwin/ =~ RbConfig::CONFIG["host_os"]) != nil
15
+ def self.mac?
16
+ (/darwin/ =~ RbConfig::CONFIG['host_os']) != nil
16
17
  end
17
18
 
18
- def OS.unix?
19
+ def self.unix?
19
20
  !OS.windows?
20
21
  end
21
22
 
22
- def OS.linux?
23
- OS.unix? and not OS.mac?
23
+ def self.linux?
24
+ OS.unix? && !OS.mac?
24
25
  end
25
26
  end
26
-
27
27
  end
28
- end
28
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'highline'
2
4
  require 'logger'
3
5
  require 'thor'
@@ -10,81 +12,96 @@ module KPM
10
12
  def self.included(base)
11
13
  base.send :include, ::Thor::Actions
12
14
  base.class_eval do
13
-
14
-
15
- desc 'KPM version', 'Return current KPM version.'
15
+ desc 'version', 'Return current KPM version.'
16
16
  def version
17
17
  say "KPM version #{KPM::VERSION}"
18
18
  end
19
19
 
20
20
  class_option :overrides,
21
- :type => :hash,
22
- :default => nil,
23
- :desc => "A hashed list of overrides. Available options are 'url', 'repository', 'username', and 'password'."
21
+ type: :hash,
22
+ default: nil,
23
+ desc: "A hashed list of overrides. Available options are 'url', 'repository', 'username', and 'password'."
24
24
 
25
25
  class_option :ssl_verify,
26
- :type => :boolean,
27
- :default => true,
28
- :desc => 'Set to false to disable SSL Verification.'
26
+ type: :boolean,
27
+ default: true,
28
+ desc: 'Set to false to disable SSL Verification.'
29
29
 
30
30
  method_option :force_download,
31
- :type => :boolean,
32
- :default => false,
33
- :desc => 'Force download of the artifact even if it exists'
31
+ type: :boolean,
32
+ default: false,
33
+ desc: 'Force download of the artifact even if it exists'
34
34
  method_option :verify_sha1,
35
- :type => :boolean,
36
- :default => true,
37
- :desc => 'Validate sha1 sum'
35
+ type: :boolean,
36
+ default: true,
37
+ desc: 'Validate sha1 sum'
38
38
  desc 'install config_file', 'Install Kill Bill server and plugins according to the specified YAML configuration file.'
39
- def install(config_file=nil)
39
+ def install(config_file = nil)
40
40
  help = Installer.from_file(config_file).install(options[:force_download], options[:verify_sha1])
41
41
  help = JSON(help)
42
42
  say help['help'], :green unless help['help'].nil?
43
43
  end
44
44
 
45
45
  method_option :destination,
46
- :type => :string,
47
- :default => nil,
48
- :desc => 'A different folder other than the default bundles directory.'
46
+ type: :string,
47
+ default: nil,
48
+ desc: 'A different folder other than the default bundles directory.'
49
49
  method_option :force,
50
- :type => :boolean,
51
- :default => nil,
52
- :desc => 'Don\'t ask for confirmation while deleting multiple versions of a plugin.'
50
+ type: :boolean,
51
+ default: nil,
52
+ desc: 'Don\'t ask for confirmation while deleting multiple versions of a plugin.'
53
+ method_option :version,
54
+ type: :string,
55
+ default: nil,
56
+ desc: 'Specific plugin version to uninstall'
53
57
  desc 'uninstall plugin', 'Uninstall the specified plugin, identified by its name or key, from current deployment'
54
58
  def uninstall(plugin)
55
- say 'Done!' if Uninstaller.new(options[:destination]).uninstall_plugin(plugin, options[:force])
59
+ Uninstaller.new(options[:destination]).uninstall_plugin(plugin, options[:force], options[:version])
56
60
  end
57
61
 
58
62
  method_option :destination,
59
- :type => :string,
60
- :default => nil,
61
- :desc => 'A different folder other than the current working directory.'
63
+ type: :string,
64
+ default: nil,
65
+ desc: 'A different folder other than the default bundles directory.'
66
+ method_option :dry_run,
67
+ type: :boolean,
68
+ default: false,
69
+ desc: 'Print the plugins which would be deleted'
70
+ desc 'cleanup', 'Delete old plugins'
71
+ def cleanup
72
+ Uninstaller.new(options[:destination]).uninstall_non_default_plugins(options[:dry_run])
73
+ end
74
+
75
+ method_option :destination,
76
+ type: :string,
77
+ default: nil,
78
+ desc: 'A different folder other than the current working directory.'
62
79
  method_option :bundles_dir,
63
- :type => :string,
64
- :default => nil,
65
- :desc => 'The location where bundles will be installed (along with sha1 file)'
80
+ type: :string,
81
+ default: nil,
82
+ desc: 'The location where bundles will be installed (along with sha1 file)'
66
83
  method_option :force_download,
67
- :type => :boolean,
68
- :default => false,
69
- :desc => 'Force download of the artifact even if it exists'
84
+ type: :boolean,
85
+ default: false,
86
+ desc: 'Force download of the artifact even if it exists'
70
87
  method_option :verify_sha1,
71
- :type => :boolean,
72
- :default => true,
73
- :desc => 'Validate sha1 sum'
74
- desc 'pull_kb_server_war <version>', 'Pulls Kill Bill server war from Sonatype and places it on your machine. If version was not specified it uses the latest released version.'
75
- def pull_kb_server_war(version='LATEST')
88
+ type: :boolean,
89
+ default: true,
90
+ desc: 'Validate sha1 sum'
91
+ desc 'pull_kb_server_war <version>', 'Pulls Kill Bill server war and places it on your machine. If version was not specified it uses the latest released version.'
92
+ def pull_kb_server_war(version = 'LATEST')
76
93
  installer = BaseInstaller.new(logger,
77
94
  options[:overrides],
78
95
  options[:ssl_verify])
79
96
  response = installer.install_killbill_server(KillbillServerArtifact::KILLBILL_GROUP_ID,
80
- KillbillServerArtifact::KILLBILL_ARTIFACT_ID,
81
- KillbillServerArtifact::KILLBILL_PACKAGING,
82
- KillbillServerArtifact::KILLBILL_CLASSIFIER,
83
- version,
84
- options[:destination],
85
- options[:bundles_dir],
86
- options[:force_download],
87
- options[:verify_sha1])
97
+ KillbillServerArtifact::KILLBILL_ARTIFACT_ID,
98
+ KillbillServerArtifact::KILLBILL_PACKAGING,
99
+ KillbillServerArtifact::KILLBILL_CLASSIFIER,
100
+ version,
101
+ options[:destination],
102
+ options[:bundles_dir],
103
+ options[:force_download],
104
+ options[:verify_sha1])
88
105
  say "Artifact has been retrieved and can be found at path: #{response[:file_path]}", :green
89
106
  end
90
107
 
@@ -97,98 +114,54 @@ module KPM
97
114
  options[:ssl_verify]).to_a.join(', ')}", :green
98
115
  end
99
116
 
100
- method_option :destination,
101
- :type => :string,
102
- :default => nil,
103
- :desc => 'A different folder other than the current working directory.'
104
- method_option :bundles_dir,
105
- :type => :string,
106
- :default => nil,
107
- :desc => 'The location where bundles will be installed (along with sha1 file)'
108
- method_option :force_download,
109
- :type => :boolean,
110
- :default => false,
111
- :desc => 'Force download of the artifact even if it exists'
112
- method_option :verify_sha1,
113
- :type => :boolean,
114
- :default => true,
115
- :desc => 'Validates sha1 sum'
116
- desc 'pull_kp_server_war <version>', 'Pulls Kill Pay server war from Sonatype and places it on your machine. If version was not specified it uses the latest released version.'
117
- def pull_kp_server_war(version='LATEST')
118
- installer = BaseInstaller.new(logger,
119
- options[:overrides],
120
- options[:ssl_verify])
121
- response = installer.install_killbill_server(KillbillServerArtifact::KILLBILL_GROUP_ID,
122
- KillbillServerArtifact::KILLPAY_ARTIFACT_ID,
123
- KillbillServerArtifact::KILLPAY_PACKAGING,
124
- KillbillServerArtifact::KILLPAY_CLASSIFIER,
125
- version,
126
- options[:destination],
127
- options[:bundles_dir],
128
- options[:force_download],
129
- options[:verify_sha1])
130
- say "Artifact has been retrieved and can be found at path: #{response[:file_path]}", :green
131
- end
132
-
133
- desc 'search_for_kp_server', 'Searches for all versions of Kill Pay server and prints them to the screen.'
134
- def search_for_kp_server
135
- say "Available versions: #{KillbillServerArtifact.versions(KillbillServerArtifact::KILLPAY_ARTIFACT_ID,
136
- KillbillServerArtifact::KILLPAY_PACKAGING,
137
- KillbillServerArtifact::KILLPAY_CLASSIFIER,
138
- options[:overrides],
139
- options[:ssl_verify]).to_a.join(', ')}", :green
140
- end
141
-
142
117
  method_option :group_id,
143
- :type => :string,
144
- :default => KillbillPluginArtifact::KILLBILL_JAVA_PLUGIN_GROUP_ID,
145
- :desc => 'The plugin artifact group-id'
118
+ type: :string,
119
+ default: KillbillPluginArtifact::KILLBILL_JAVA_PLUGIN_GROUP_ID,
120
+ desc: 'The plugin artifact group-id'
146
121
  method_option :artifact_id,
147
- :type => :string,
148
- :default => nil,
149
- :desc => 'The plugin artifact id'
122
+ type: :string,
123
+ default: nil,
124
+ desc: 'The plugin artifact id'
150
125
  method_option :version,
151
- :type => :string,
152
- :default => nil,
153
- :desc => 'The plugin artifact version'
126
+ type: :string,
127
+ default: nil,
128
+ desc: 'The plugin artifact version'
154
129
  method_option :packaging,
155
- :type => :string,
156
- :default => KillbillPluginArtifact::KILLBILL_JAVA_PLUGIN_PACKAGING,
157
- :desc => 'The plugin artifact packaging'
130
+ type: :string,
131
+ default: KillbillPluginArtifact::KILLBILL_JAVA_PLUGIN_PACKAGING,
132
+ desc: 'The plugin artifact packaging'
158
133
  method_option :classifier,
159
- :type => :string,
160
- :default => KillbillPluginArtifact::KILLBILL_JAVA_PLUGIN_CLASSIFIER,
161
- :desc => 'The plugin artifact classifier'
134
+ type: :string,
135
+ default: KillbillPluginArtifact::KILLBILL_JAVA_PLUGIN_CLASSIFIER,
136
+ desc: 'The plugin artifact classifier'
162
137
  method_option :from_source_file,
163
- :type => :string,
164
- :default => nil,
165
- :desc => 'Specify the plugin jar that should be used for the installation.'
138
+ type: :string,
139
+ default: nil,
140
+ desc: 'Specify the plugin jar that should be used for the installation.'
166
141
  method_option :destination,
167
- :type => :string,
168
- :default => nil,
169
- :desc => 'A different folder other than the current working directory.'
142
+ type: :string,
143
+ default: nil,
144
+ desc: 'A different folder other than the current working directory.'
170
145
  method_option :force_download,
171
- :type => :boolean,
172
- :default => false,
173
- :desc => 'Force download of the artifact even if it exists'
146
+ type: :boolean,
147
+ default: false,
148
+ desc: 'Force download of the artifact even if it exists'
174
149
  method_option :sha1_file,
175
- :type => :string,
176
- :default => nil,
177
- :desc => 'Location of the sha1 file'
150
+ type: :string,
151
+ default: nil,
152
+ desc: 'Location of the sha1 file'
178
153
  method_option :verify_sha1,
179
- :type => :boolean,
180
- :default => true,
181
- :desc => 'Validates sha1 sum'
182
- desc 'install_java_plugin plugin-key <kb-version>', 'Pulls a java plugin from Sonatype and installs it under the specified destination. If the kb-version has been specified, it is used to download the matching plugin artifact version; if not, it uses the specified plugin version or if null, the LATEST one.'
183
- def install_java_plugin(plugin_key, kb_version='LATEST')
184
-
185
-
154
+ type: :boolean,
155
+ default: true,
156
+ desc: 'Validates sha1 sum'
157
+ desc 'install_java_plugin plugin-key <kb-version>', 'Pulls a java plugin and installs it under the specified destination. If the kb-version has been specified, it is used to download the matching plugin artifact version; if not, it uses the specified plugin version or if null, the LATEST one.'
158
+ def install_java_plugin(plugin_key, kb_version = 'LATEST')
186
159
  installer = BaseInstaller.new(logger,
187
160
  options[:overrides],
188
161
  options[:ssl_verify])
189
162
 
190
- if options[:from_source_file].nil?
191
- response = installer.install_plugin(plugin_key,
163
+ response = if options[:from_source_file].nil?
164
+ installer.install_plugin(plugin_key,
192
165
  kb_version,
193
166
  options[:group_id],
194
167
  options[:artifact_id],
@@ -200,64 +173,61 @@ module KPM
200
173
  options[:force_download],
201
174
  options[:verify_sha1],
202
175
  false)
203
- else
204
- response = installer.install_plugin_from_fs(plugin_key, options[:from_source_file], nil, options[:version], options[:destination], 'java')
205
- end
176
+ else
177
+ installer.install_plugin_from_fs(plugin_key, options[:from_source_file], nil, options[:version], options[:destination], 'java')
178
+ end
206
179
 
207
180
  say "Artifact has been retrieved and can be found at path: #{response[:file_path]}", :green
208
181
  end
209
182
 
210
-
211
-
212
-
213
183
  method_option :group_id,
214
- :type => :string,
215
- :default => KillbillPluginArtifact::KILLBILL_RUBY_PLUGIN_GROUP_ID,
216
- :desc => 'The plugin artifact group-id'
184
+ type: :string,
185
+ default: KillbillPluginArtifact::KILLBILL_RUBY_PLUGIN_GROUP_ID,
186
+ desc: 'The plugin artifact group-id'
217
187
  method_option :artifact_id,
218
- :type => :string,
219
- :default => nil,
220
- :desc => 'The plugin artifact id'
188
+ type: :string,
189
+ default: nil,
190
+ desc: 'The plugin artifact id'
221
191
  method_option :version,
222
- :type => :string,
223
- :default => nil,
224
- :desc => 'The plugin artifact version'
192
+ type: :string,
193
+ default: nil,
194
+ desc: 'The plugin artifact version'
225
195
  method_option :packaging,
226
- :type => :string,
227
- :default => KillbillPluginArtifact::KILLBILL_RUBY_PLUGIN_PACKAGING,
228
- :desc => 'The plugin artifact packaging'
196
+ type: :string,
197
+ default: KillbillPluginArtifact::KILLBILL_RUBY_PLUGIN_PACKAGING,
198
+ desc: 'The plugin artifact packaging'
229
199
  method_option :classifier,
230
- :type => :string,
231
- :default => KillbillPluginArtifact::KILLBILL_RUBY_PLUGIN_CLASSIFIER,
232
- :desc => 'The plugin artifact classifier'
200
+ type: :string,
201
+ default: KillbillPluginArtifact::KILLBILL_RUBY_PLUGIN_CLASSIFIER,
202
+ desc: 'The plugin artifact classifier'
233
203
  method_option :from_source_file,
234
- :type => :string,
235
- :default => nil,
236
- :desc => 'Specify the ruby plugin archive that should be used for the installation.'
204
+ type: :string,
205
+ default: nil,
206
+ desc: 'Specify the ruby plugin archive that should be used for the installation.'
237
207
  method_option :destination,
238
- :type => :string,
239
- :default => nil,
240
- :desc => 'A different folder other than the current working directory.'
208
+ type: :string,
209
+ default: nil,
210
+ desc: 'A different folder other than the current working directory.'
241
211
  method_option :force_download,
242
- :type => :boolean,
243
- :default => false,
244
- :desc => 'Force download of the artifact even if it exists'
212
+ type: :boolean,
213
+ default: false,
214
+ desc: 'Force download of the artifact even if it exists'
245
215
  method_option :sha1_file,
246
- :type => :string,
247
- :default => nil,
248
- :desc => 'Location of the sha1 file'
216
+ type: :string,
217
+ default: nil,
218
+ desc: 'Location of the sha1 file'
249
219
  method_option :verify_sha1,
250
- :type => :boolean,
251
- :default => true,
252
- :desc => 'Validates sha1 sum'
253
- desc 'install_ruby_plugin plugin-key <kb-version>', 'Pulls a ruby plugin from Sonatype and installs it under the specified destination. If the kb-version has been specified, it is used to download the matching plugin artifact version; if not, it uses the specified plugin version or if null, the LATEST one.'
254
- def install_ruby_plugin(plugin_key, kb_version='LATEST')
220
+ type: :boolean,
221
+ default: true,
222
+ desc: 'Validates sha1 sum'
223
+ desc 'install_ruby_plugin plugin-key <kb-version>', 'Pulls a ruby plugin and installs it under the specified destination. If the kb-version has been specified, it is used to download the matching plugin artifact version; if not, it uses the specified plugin version or if null, the LATEST one.'
224
+ def install_ruby_plugin(plugin_key, kb_version = 'LATEST')
255
225
  installer = BaseInstaller.new(logger,
256
- options[:overrides],
257
- options[:ssl_verify])
226
+ options[:overrides],
227
+ options[:ssl_verify])
258
228
 
259
- if options[:from_source_file].nil?
260
- response = installer.install_plugin(plugin_key,
229
+ response = if options[:from_source_file].nil?
230
+ installer.install_plugin(plugin_key,
261
231
  kb_version,
262
232
  options[:group_id],
263
233
  options[:artifact_id],
@@ -269,28 +239,27 @@ module KPM
269
239
  options[:force_download],
270
240
  options[:verify_sha1],
271
241
  true)
272
- else
273
- response = installer.install_plugin_from_fs(plugin_key, options[:from_source_file], nil, nil, options[:destination], 'ruby')
274
- end
242
+ else
243
+ installer.install_plugin_from_fs(plugin_key, options[:from_source_file], nil, nil, options[:destination], 'ruby')
244
+ end
275
245
 
276
246
  say "Artifact has been retrieved and can be found at path: #{response[:file_path]}", :green
277
-
278
247
  end
279
248
 
280
249
  method_option :destination,
281
- :type => :string,
282
- :default => nil,
283
- :desc => 'A different folder other than the default bundles directory.'
250
+ type: :string,
251
+ default: nil,
252
+ desc: 'A different folder other than the default bundles directory.'
284
253
  method_option :force_download,
285
- :type => :boolean,
286
- :default => false,
287
- :desc => 'Force download of the artifact even if it exists'
254
+ type: :boolean,
255
+ default: false,
256
+ desc: 'Force download of the artifact even if it exists'
288
257
  method_option :verify_sha1,
289
- :type => :boolean,
290
- :default => true,
291
- :desc => 'Validates sha1 sum'
292
- desc 'pull_defaultbundles <kb-version>', 'Pulls the default OSGI bundles from Sonatype and places it on your machine. If the kb-version has been specified, it is used to download the matching platform artifact; if not, it uses the latest released version.'
293
- def pull_defaultbundles(kb_version='LATEST')
258
+ type: :boolean,
259
+ default: true,
260
+ desc: 'Validates sha1 sum'
261
+ desc 'pull_defaultbundles <kb-version>', 'Pulls the default OSGI bundles and places it on your machine. If the kb-version has been specified, it is used to download the matching platform artifact; if not, it uses the latest released version.'
262
+ def pull_defaultbundles(kb_version = 'LATEST')
294
263
  response = BaseInstaller.new(logger,
295
264
  options[:overrides],
296
265
  options[:ssl_verify])
@@ -318,23 +287,23 @@ module KPM
318
287
  end
319
288
 
320
289
  method_option :destination,
321
- :type => :string,
322
- :default => nil,
323
- :desc => 'A different folder other than the current working directory.'
290
+ type: :string,
291
+ default: nil,
292
+ desc: 'A different folder other than the current working directory.'
324
293
  method_option :force_download,
325
- :type => :boolean,
326
- :default => false,
327
- :desc => 'Force download of the artifact even if it exists'
294
+ type: :boolean,
295
+ default: false,
296
+ desc: 'Force download of the artifact even if it exists'
328
297
  method_option :sha1_file,
329
- :type => :string,
330
- :default => nil,
331
- :desc => 'Location of the sha1 file'
298
+ type: :string,
299
+ default: nil,
300
+ desc: 'Location of the sha1 file'
332
301
  method_option :verify_sha1,
333
- :type => :boolean,
334
- :default => true,
335
- :desc => 'Validates sha1 sum'
336
- desc 'pull_kaui_war <version>', 'Pulls Kaui war from Sonatype and places it on your machine. If version was not specified it uses the latest released version.'
337
- def pull_kaui_war(version='LATEST')
302
+ type: :boolean,
303
+ default: true,
304
+ desc: 'Validates sha1 sum'
305
+ desc 'pull_kaui_war <version>', 'Pulls Kaui war and places it on your machine. If version was not specified it uses the latest released version.'
306
+ def pull_kaui_war(version = 'LATEST')
338
307
  response = KauiArtifact.pull(logger,
339
308
  KauiArtifact::KAUI_GROUP_ID,
340
309
  KauiArtifact::KAUI_ARTIFACT_ID,
@@ -356,36 +325,54 @@ module KPM
356
325
  end
357
326
 
358
327
  method_option :version,
359
- :type => :string,
360
- :default => 'LATEST',
361
- :desc => 'Kill Bill version'
328
+ type: :string,
329
+ default: 'LATEST',
330
+ desc: 'Kill Bill version'
331
+ method_option :force_download,
332
+ type: :boolean,
333
+ default: false,
334
+ desc: 'Ignore local cache'
335
+ method_option :sha1_file,
336
+ type: :string,
337
+ default: nil,
338
+ desc: 'Location of the sha1 file'
339
+ method_option :verify_sha1,
340
+ type: :boolean,
341
+ default: true,
342
+ desc: 'Validates sha1 sum'
343
+ method_option :as_json,
344
+ type: :boolean,
345
+ default: false,
346
+ desc: 'Set the output format as JSON when true'
362
347
  desc 'info', 'Describe information about a Kill Bill version'
363
348
  def info
364
-
365
- say "Fetching info for version #{options[:version]}...\n"
366
-
367
349
  versions_info = KillbillServerArtifact.info(options[:version],
368
- options[:overrides],
369
- options[:ssl_verify])
370
- say "Dependencies for version #{options[:version]}\n " + (versions_info.map {|k,v| "#{k} #{v}"}).join("\n "), :green
371
- say "\n\n"
372
-
350
+ options[:sha1_file],
351
+ options[:force_download],
352
+ options[:verify_sha1],
353
+ options[:overrides],
354
+ options[:ssl_verify])
373
355
  resolved_kb_version = versions_info['killbill']
374
- kb_version = resolved_kb_version.split('.').slice(0,2).join(".")
356
+ kb_version = resolved_kb_version.split('.').slice(0, 2).join('.')
375
357
 
376
358
  plugins_info = KPM::PluginsDirectory.list_plugins(true, kb_version)
377
359
 
378
- say "Known plugin for KB version #{options[:version]}\n " + (plugins_info.map {|k,v| "#{k} #{v}"}).join("\n "), :green
360
+ if options[:as_json]
361
+ puts({ 'killbill' => versions_info, 'plugins' => plugins_info }.to_json)
362
+ else
363
+ say "Dependencies for version #{options[:version]}\n " + (versions_info.map { |k, v| "#{k} #{v}" }).join("\n "), :green
364
+ say "Known plugins for KB version #{options[:version]}\n " + (plugins_info.map { |k, v| "#{k} #{v}" }).join("\n "), :green
365
+ end
379
366
  end
380
367
 
381
368
  method_option :destination,
382
- :type => :string,
383
- :default => nil,
384
- :desc => 'Folder where to download migration files.'
369
+ type: :string,
370
+ default: nil,
371
+ desc: 'Folder where to download migration files.'
385
372
  method_option :token,
386
- :type => :string,
387
- :default => nil,
388
- :desc => 'GitHub OAuth token.'
373
+ type: :string,
374
+ default: nil,
375
+ desc: 'GitHub OAuth token.'
389
376
  desc 'migrations repository from to', 'Download migration files for Kill Bill or a plugin'
390
377
  def migrations(repository, from, to = nil)
391
378
  full_repo = repository.include?('/') ? repository : "killbill/#{repository}"
@@ -394,324 +381,264 @@ module KPM
394
381
  end
395
382
 
396
383
  method_option :destination,
397
- :type => :string,
398
- :default => nil,
399
- :desc => 'A different folder other than the default bundles directory.'
384
+ type: :string,
385
+ default: nil,
386
+ desc: 'A different folder other than the default bundles directory.'
387
+ method_option :as_json,
388
+ type: :boolean,
389
+ default: false,
390
+ desc: 'Set the output format as JSON when true'
400
391
  desc 'inspect', 'Inspect current deployment'
401
392
  def inspect
402
393
  inspector = KPM::Inspector.new
403
- puts options[:destination]
404
394
  all_plugins = inspector.inspect(options[:destination])
405
- #puts all_plugins.to_json
406
- inspector.format(all_plugins)
395
+ options[:as_json] ? puts(all_plugins.to_json) : inspector.format(all_plugins)
407
396
  end
408
397
 
409
398
  method_option :bundles_dir,
410
- :type => :string,
411
- :default => nil,
412
- :desc => 'A different folder other than the default bundles directory.'
399
+ type: :string,
400
+ default: nil,
401
+ desc: 'A different folder other than the default bundles directory.'
413
402
  method_option :config_file,
414
- :type => :string,
415
- :default => nil,
416
- :desc => 'KPM configuration file (yml file)'
403
+ type: :string,
404
+ default: nil,
405
+ desc: 'KPM configuration file (yml file)'
417
406
  method_option :as_json,
418
- :type => :boolean,
419
- :default => false,
420
- :desc => 'Set the output format as JSON when true'
407
+ type: :boolean,
408
+ default: false,
409
+ desc: 'Set the output format as JSON when true'
421
410
  method_option :kaui_web_path,
422
- :type => :string,
423
- :default => nil,
424
- :desc => 'Path for the KAUI web app'
411
+ type: :string,
412
+ default: nil,
413
+ desc: 'Path for the KAUI web app'
425
414
  method_option :killbill_web_path,
426
- :type => :string,
427
- :default => nil,
428
- :desc => 'Path for the killbill web app'
415
+ type: :string,
416
+ default: nil,
417
+ desc: 'Path for the killbill web app'
429
418
  desc 'system', 'Gather information about the system'
430
419
  def system
431
- system = KPM::System.new
420
+ system = KPM::System.new(logger)
432
421
  information = system.information(options[:bundles_dir], options[:as_json], options[:config_file], options[:kaui_web_path],
433
- options[:killbill_web_path])
434
-
435
- if options[:as_json]
436
- puts information
437
- end
422
+ options[:killbill_web_path])
438
423
 
424
+ puts information if options[:as_json]
439
425
  end
440
426
 
441
427
  method_option :export,
442
- :type => :string,
443
- :default => nil,
444
- :desc => 'export account for a provided id.'
428
+ type: :string,
429
+ default: nil,
430
+ desc: 'export account for a provided id.'
445
431
  method_option :import,
446
- :type => :string,
447
- :default => nil,
448
- :desc => 'import account for a previously exported file.'
432
+ type: :string,
433
+ default: nil,
434
+ desc: 'import account for a previously exported file.'
449
435
  method_option :tenant_record_id,
450
- :type => :numeric,
451
- :default => nil,
452
- :desc => 'replace the tenant_record_id before importing data.'
436
+ type: :numeric,
437
+ default: nil,
438
+ desc: 'replace the tenant_record_id before importing data.'
453
439
  method_option :generate_record_id,
454
- :type => :boolean,
455
- :default => false,
456
- :desc => 'The generate_record_id will instruct to generate the tables record_ids that were exported'
440
+ type: :boolean,
441
+ default: false,
442
+ desc: 'The generate_record_id will instruct to generate the tables record_ids that were exported'
457
443
  method_option :skip_payment_methods,
458
- :type => :boolean,
459
- :default => false,
460
- :desc => 'Skip or swap payment types other than __EXTERNAL_PAYMENT__.'
444
+ type: :boolean,
445
+ default: false,
446
+ desc: 'Skip or swap payment types other than __EXTERNAL_PAYMENT__.'
461
447
  method_option :config_file,
462
- :type => :string,
463
- :default => nil,
464
- :desc => 'Yml that contains killbill api connection and DB connection'
448
+ type: :string,
449
+ default: nil,
450
+ desc: 'Yml that contains killbill api connection and DB connection'
465
451
  method_option :killbill_api_credentials,
466
- :type => :array,
467
- :default => nil,
468
- :desc => 'Killbill api credentials <api_key> <api_secrets>'
452
+ type: :array,
453
+ default: nil,
454
+ desc: 'Killbill api credentials <api_key> <api_secrets>'
469
455
  method_option :killbill_credentials,
470
- :type => :array,
471
- :default => nil,
472
- :desc => 'Killbill credentials <user> <password>'
456
+ type: :array,
457
+ default: nil,
458
+ desc: 'Killbill credentials <user> <password>'
473
459
  method_option :killbill_url,
474
- :type => :string,
475
- :default => nil,
476
- :desc => 'Killbill URL ex. http://127.0.0.1:8080'
460
+ type: :string,
461
+ default: nil,
462
+ desc: 'Killbill URL ex. http://127.0.0.1:8080'
477
463
  method_option :database_name,
478
- :type => :string,
479
- :default => nil,
480
- :desc => 'DB name to connect'
464
+ type: :string,
465
+ default: nil,
466
+ desc: 'DB name to connect'
481
467
  method_option :database_credentials,
482
- :type => :array,
483
- :default => nil,
484
- :desc => 'DB credentials <user> <password>'
468
+ type: :array,
469
+ default: nil,
470
+ desc: 'DB credentials <user> <password>'
485
471
  method_option :data_delimiter,
486
- :type => :string,
487
- :default => "|",
488
- :desc => 'Data delimiter'
472
+ type: :string,
473
+ default: '|',
474
+ desc: 'Data delimiter'
489
475
  method_option :database_host,
490
- :type => :string,
491
- :default => nil,
492
- :desc => 'Database Host name'
476
+ type: :string,
477
+ default: nil,
478
+ desc: 'Database Host name'
493
479
  method_option :database_port,
494
- :type => :string,
495
- :default => nil,
496
- :desc => 'Database port'
480
+ type: :string,
481
+ default: nil,
482
+ desc: 'Database port'
497
483
  desc 'account', 'export/import accounts'
498
484
  def account
499
- logger.info 'Please wait processing the request!!!'
500
- begin
501
- config_file = nil
502
- if options[:killbill_url] && /https?:\/\/[\S]+/.match(options[:killbill_url]).nil?
503
- raise Interrupt,'--killbill_url, required format -> http(s)://something'
504
- end
505
-
506
- if options[:killbill_api_credentials] && options[:killbill_api_credentials].size != 2
507
- raise Interrupt,'--killbill_api_credentials, required format -> <api_key> <api_secrets>'
508
- end
485
+ config_file = nil
486
+ raise Interrupt, '--killbill_url, required format -> http(s)://something' if options[:killbill_url] && %r{https?://\S+}.match(options[:killbill_url]).nil?
509
487
 
510
- if options[:killbill_credentials] && options[:killbill_credentials].size != 2
511
- raise Interrupt,'--killbill_credentials, required format -> <user> <password>'
512
- end
488
+ raise Interrupt, '--killbill_api_credentials, required format -> <api_key> <api_secrets>' if options[:killbill_api_credentials] && options[:killbill_api_credentials].size != 2
513
489
 
514
- if options[:database_credentials] && options[:database_credentials].size != 2
515
- raise Interrupt,'--database_credentials, required format -> <user> <password>'
516
- end
490
+ raise Interrupt, '--killbill_credentials, required format -> <user> <password>' if options[:killbill_credentials] && options[:killbill_credentials].size != 2
517
491
 
518
- if options[:database_name] && options[:database_name] == :database_name.to_s
519
- raise Interrupt,'--database_credentials, please provide a valid database name'
520
- end
521
-
522
- if options[:config_file] && options[:config_file] == :config_file.to_s
523
- config_file = File.join(File.expand_path(File.dirname(__FILE__)), 'account_export_import.yml')
524
- end
492
+ raise Interrupt, '--database_credentials, required format -> <user> <password>' if options[:database_credentials] && options[:database_credentials].size != 2
525
493
 
526
- if options[:export].nil? && options[:import].nil?
527
- raise Interrupt,'Need to specify an action'
528
- end
494
+ raise Interrupt, '--database_credentials, please provide a valid database name' if options[:database_name] && options[:database_name] == :database_name.to_s
529
495
 
496
+ config_file = File.join(__dir__, 'account_export_import.yml') if options[:config_file] && options[:config_file] == :config_file.to_s
530
497
 
531
- account = KPM::Account.new(config_file || options[:config_file],options[:killbill_api_credentials],options[:killbill_credentials],
532
- options[:killbill_url],options[:database_name],options[:database_credentials],options[:database_host], options[:database_port],options[:data_delimiter], logger)
533
- export_file = nil
534
- round_trip_export_import = false
498
+ raise Interrupt, 'Need to specify an action' if options[:export].nil? && options[:import].nil?
535
499
 
536
- if not options[:export].nil?
537
- export_file = account.export_data(options[:export])
538
- round_trip_export_import = true
539
- end
500
+ account = KPM::Account.new(config_file || options[:config_file], options[:killbill_api_credentials], options[:killbill_credentials],
501
+ options[:killbill_url], options[:database_name], options[:database_credentials], options[:database_host], options[:database_port], options[:data_delimiter], logger)
502
+ export_file = nil
503
+ round_trip_export_import = false
540
504
 
541
- if not options[:import].nil?
542
- account.import_data(export_file || options[:import],options[:tenant_record_id], options[:skip_payment_methods],
543
- round_trip_export_import, options[:generate_record_id])
544
- end
505
+ unless options[:export].nil?
506
+ export_file = account.export_data(options[:export])
507
+ round_trip_export_import = true
508
+ end
545
509
 
546
- rescue Exception => e
547
- logger.error "\e[91;1m#{e.message}\e[0m"
548
- if not e.is_a?(Interrupt)
549
- logger.error e.backtrace.join("\n")
550
- end
510
+ unless options[:import].nil?
511
+ account.import_data(export_file || options[:import], options[:tenant_record_id], options[:skip_payment_methods],
512
+ round_trip_export_import, options[:generate_record_id])
551
513
  end
514
+ rescue StandardError => e
515
+ logger.error "\e[91;1m#{e.message}\e[0m"
516
+ logger.error e.backtrace.join("\n") unless e.is_a?(Interrupt)
552
517
  end
553
518
 
554
519
  method_option :key_prefix,
555
- :type => :string,
556
- :default => nil,
557
- :enum => KPM::TenantConfig::KEY_PREFIXES,
558
- :desc => 'Retrieve a per tenant key value based on key prefix'
520
+ type: :string,
521
+ default: nil,
522
+ enum: KPM::TenantConfig::KEY_PREFIXES,
523
+ desc: 'Retrieve a per tenant key value based on key prefix'
559
524
  method_option :killbill_api_credentials,
560
- :type => :array,
561
- :default => nil,
562
- :desc => 'Killbill api credentials <api_key> <api_secrets>'
525
+ type: :array,
526
+ default: nil,
527
+ desc: 'Killbill api credentials <api_key> <api_secrets>'
563
528
  method_option :killbill_credentials,
564
- :type => :array,
565
- :default => nil,
566
- :desc => 'Killbill credentials <user> <password>'
529
+ type: :array,
530
+ default: nil,
531
+ desc: 'Killbill credentials <user> <password>'
567
532
  method_option :killbill_url,
568
- :type => :string,
569
- :default => nil,
570
- :desc => 'Killbill URL ex. http://127.0.0.1:8080'
533
+ type: :string,
534
+ default: nil,
535
+ desc: 'Killbill URL ex. http://127.0.0.1:8080'
571
536
  desc 'tenant_config', 'export all tenant-level configs.'
572
537
  def tenant_config
573
- logger.info 'Please wait processing the request!!!'
574
- begin
538
+ raise Interrupt, '--killbill_url, required format -> http(s)://something' if options[:killbill_url] && %r{https?://\S+}.match(options[:killbill_url]).nil?
575
539
 
576
- if options[:killbill_url] && /https?:\/\/[\S]+/.match(options[:killbill_url]).nil?
577
- raise Interrupt,'--killbill_url, required format -> http(s)://something'
578
- end
579
-
580
- if options[:killbill_api_credentials] && options[:killbill_api_credentials].size != 2
581
- raise Interrupt,'--killbill_api_credentials, required format -> <api_key> <api_secrets>'
582
- end
583
-
584
- if options[:killbill_credentials] && options[:killbill_credentials].size != 2
585
- raise Interrupt,'--killbill_credentials, required format -> <user> <password>'
586
- end
540
+ raise Interrupt, '--killbill_api_credentials, required format -> <api_key> <api_secrets>' if options[:killbill_api_credentials] && options[:killbill_api_credentials].size != 2
587
541
 
588
- if options[:key_prefix] === :key_prefix.to_s
589
- raise Interrupt, "--key_prefix, posible values #{KPM::TenantConfig::KEY_PREFIXES.join(', ')}"
590
- end
542
+ raise Interrupt, '--killbill_credentials, required format -> <user> <password>' if options[:killbill_credentials] && options[:killbill_credentials].size != 2
591
543
 
592
- tenantConfig = KPM::TenantConfig.new(options[:killbill_api_credentials],options[:killbill_credentials],
593
- options[:killbill_url], logger)
544
+ raise Interrupt, "--key_prefix, posible values #{KPM::TenantConfig::KEY_PREFIXES.join(', ')}" if options[:key_prefix] == :key_prefix.to_s
594
545
 
595
- tenantConfig.export(options[:key_prefix])
546
+ tenant_config = KPM::TenantConfig.new(options[:killbill_api_credentials], options[:killbill_credentials],
547
+ options[:killbill_url], logger)
596
548
 
597
- rescue Exception => e
598
- logger.error "\e[91;1m#{e.message}\e[0m"
599
- if not e.is_a?(Interrupt)
600
- logger.error e.backtrace.join("\n")
601
- end
602
- end
549
+ tenant_config.export(options[:key_prefix])
550
+ rescue StandardError => e
551
+ logger.error "\e[91;1m#{e.message}\e[0m"
552
+ logger.error e.backtrace.join("\n") unless e.is_a?(Interrupt)
603
553
  end
604
554
 
605
-
606
555
  method_option :account_export,
607
- :type => :string,
608
- :default => nil,
609
- :desc => 'export account for a provided id.'
556
+ type: :string,
557
+ default: nil,
558
+ desc: 'export account for a provided id.'
610
559
  method_option :log_dir,
611
- :type => :string,
612
- :default => nil,
613
- :desc => '(Optional) Log directory if the default tomcat location has changed'
560
+ type: :string,
561
+ default: nil,
562
+ desc: '(Optional) Log directory if the default tomcat location has changed'
614
563
  method_option :config_file,
615
- :type => :string,
616
- :default => nil,
617
- :desc => 'Yml that contains killbill api connection and DB connection'
564
+ type: :string,
565
+ default: nil,
566
+ desc: 'Yml that contains killbill api connection and DB connection'
618
567
  method_option :killbill_api_credentials,
619
- :type => :array,
620
- :default => nil,
621
- :desc => 'Killbill api credentials <api_key> <api_secrets>'
568
+ type: :array,
569
+ default: nil,
570
+ desc: 'Killbill api credentials <api_key> <api_secrets>'
622
571
  method_option :killbill_credentials,
623
- :type => :array,
624
- :default => nil,
625
- :desc => 'Killbill credentials <user> <password>'
572
+ type: :array,
573
+ default: nil,
574
+ desc: 'Killbill credentials <user> <password>'
626
575
  method_option :killbill_url,
627
- :type => :string,
628
- :default => nil,
629
- :desc => 'Killbill URL ex. http://127.0.0.1:8080'
576
+ type: :string,
577
+ default: nil,
578
+ desc: 'Killbill URL ex. http://127.0.0.1:8080'
630
579
  method_option :database_name,
631
- :type => :string,
632
- :default => nil,
633
- :desc => 'DB name to connect'
580
+ type: :string,
581
+ default: nil,
582
+ desc: 'DB name to connect'
634
583
  method_option :database_credentials,
635
- :type => :array,
636
- :default => nil,
637
- :desc => 'DB credentials <user> <password>'
584
+ type: :array,
585
+ default: nil,
586
+ desc: 'DB credentials <user> <password>'
638
587
  method_option :database_host,
639
- :type => :string,
640
- :default => nil,
641
- :desc => 'Database Host name'
588
+ type: :string,
589
+ default: nil,
590
+ desc: 'Database Host name'
642
591
  method_option :database_port,
643
- :type => :string,
644
- :default => nil,
645
- :desc => 'Database port'
592
+ type: :string,
593
+ default: nil,
594
+ desc: 'Database port'
646
595
  method_option :kaui_web_path,
647
- :type => :string,
648
- :default => nil,
649
- :desc => 'Path for the KAUI web app'
596
+ type: :string,
597
+ default: nil,
598
+ desc: 'Path for the KAUI web app'
650
599
  method_option :killbill_web_path,
651
- :type => :string,
652
- :default => nil,
653
- :desc => 'Path for the killbill web app'
600
+ type: :string,
601
+ default: nil,
602
+ desc: 'Path for the killbill web app'
654
603
  method_option :bundles_dir,
655
- :type => :string,
656
- :default => nil,
657
- :desc => 'A different folder other than the default bundles directory.'
604
+ type: :string,
605
+ default: nil,
606
+ desc: 'A different folder other than the default bundles directory.'
658
607
  desc 'diagnostic', 'exports and \'zips\' the account data, system, logs and tenant configurations'
659
608
  def diagnostic
660
- logger.info 'Please wait processing the request!!!'
661
- begin
662
- if options[:account_export] && options[:account_export] == 'account_export'
663
- raise Interrupt,'--account_export, please provide a valid account id'
664
- end
609
+ raise Interrupt, '--account_export, please provide a valid account id' if options[:account_export] && options[:account_export] == 'account_export'
665
610
 
666
- if options[:killbill_url] && /https?:\/\/[\S]+/.match(options[:killbill_url]).nil?
667
- raise Interrupt,'--killbill_url, required format -> http(s)://something'
668
- end
611
+ raise Interrupt, '--killbill_url, required format -> http(s)://something' if options[:killbill_url] && %r{https?://\S+}.match(options[:killbill_url]).nil?
669
612
 
670
- if options[:killbill_api_credentials] && options[:killbill_api_credentials].size != 2
671
- raise Interrupt,'--killbill_api_credentials, required format -> <api_key> <api_secrets>'
672
- end
613
+ raise Interrupt, '--killbill_api_credentials, required format -> <api_key> <api_secrets>' if options[:killbill_api_credentials] && options[:killbill_api_credentials].size != 2
673
614
 
674
- if options[:killbill_credentials] && options[:killbill_credentials].size != 2
675
- raise Interrupt,'--killbill_credentials, required format -> <user> <password>'
676
- end
677
-
678
- if options[:database_credentials] && options[:database_credentials].size != 2
679
- raise Interrupt,'--database_credentials, required format -> <user> <password>'
680
- end
615
+ raise Interrupt, '--killbill_credentials, required format -> <user> <password>' if options[:killbill_credentials] && options[:killbill_credentials].size != 2
681
616
 
682
- if options[:database_name] && options[:database_name] == :database_name.to_s
683
- raise Interrupt,'--database_credentials, please provide a valid database name'
684
- end
617
+ raise Interrupt, '--database_credentials, required format -> <user> <password>' if options[:database_credentials] && options[:database_credentials].size != 2
685
618
 
686
- if options[:kaui_web_path] && options[:kaui_web_path] == :kaui_web_path.to_s
687
- raise Interrupt,'--kaui_web_path, please provide a valid kaui web path '
688
- end
619
+ raise Interrupt, '--database_credentials, please provide a valid database name' if options[:database_name] && options[:database_name] == :database_name.to_s
689
620
 
690
- if options[:killbill_web_path] && options[:killbill_web_path] == :killbill_web_path.to_s
691
- raise Interrupt,'--killbill_web_path, please provide a valid killbill web path'
692
- end
621
+ raise Interrupt, '--kaui_web_path, please provide a valid kaui web path ' if options[:kaui_web_path] && options[:kaui_web_path] == :kaui_web_path.to_s
693
622
 
694
- diagnostic = KPM::DiagnosticFile.new(options[:config_file],options[:killbill_api_credentials],options[:killbill_credentials],
695
- options[:killbill_url],options[:database_name],options[:database_credentials],
696
- options[:database_host], options[:database_port], options[:kaui_web_path], options[:killbill_web_path], options[:bundles_dir],logger)
697
- diagnostic.export_data(options[:account_export], options[:log_dir])
623
+ raise Interrupt, '--killbill_web_path, please provide a valid killbill web path' if options[:killbill_web_path] && options[:killbill_web_path] == :killbill_web_path.to_s
698
624
 
699
- rescue Exception => e
700
- logger.error "\e[91;1m#{e.message}\e[0m"
701
- if not e.is_a?(Interrupt)
702
- logger.error e.backtrace.join("\n")
703
- end
704
- end
625
+ diagnostic = KPM::DiagnosticFile.new(options[:config_file], options[:killbill_api_credentials], options[:killbill_credentials],
626
+ options[:killbill_url], options[:database_name], options[:database_credentials],
627
+ options[:database_host], options[:database_port], options[:kaui_web_path], options[:killbill_web_path], options[:bundles_dir], logger)
628
+ diagnostic.export_data(options[:account_export], options[:log_dir])
629
+ rescue StandardError => e
630
+ logger.error "\e[91;1m#{e.message}\e[0m"
631
+ logger.error e.backtrace.join("\n") unless e.is_a?(Interrupt)
705
632
  end
706
633
 
707
- map :pull_ruby_plugin => :install_ruby_plugin,
708
- :pull_java_plugin => :install_java_plugin
634
+ map pull_ruby_plugin: :install_ruby_plugin,
635
+ pull_java_plugin: :install_java_plugin
709
636
 
710
637
  private
711
638
 
712
639
  def logger
713
640
  logger = ::Logger.new(STDOUT)
714
- logger.level = Logger::INFO
641
+ logger.level = ENV['KPM_DEBUG'] ? Logger::DEBUG : Logger::INFO
715
642
  logger
716
643
  end
717
644
  end