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