@govuk-pay/cli 0.0.2 → 0.0.4
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.
- package/package.json +1 -1
- package/resources/legacy-ruby-cli/.rspec +1 -0
- package/resources/legacy-ruby-cli/.rubocop.yml +26 -0
- package/resources/legacy-ruby-cli/.ruby-version +1 -0
- package/resources/legacy-ruby-cli/Gemfile +24 -0
- package/resources/legacy-ruby-cli/Gemfile.lock +1431 -0
- package/resources/legacy-ruby-cli/README.md +142 -0
- package/resources/legacy-ruby-cli/bin/pay +31 -0
- package/resources/legacy-ruby-cli/config/generate-secrets.yml +9 -0
- package/resources/legacy-ruby-cli/config/secrets.yml +581 -0
- package/resources/legacy-ruby-cli/config/service_secrets.yml +174 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/aws/document.rb +23 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/aws/services.rb +47 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/aws/tokens.rb +161 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/aws.rb +51 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/browse.rb +31 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/doctor.rb +154 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/app_client.rb +216 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/config.rb +138 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/config.yaml +192 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/docker.rb +36 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/docker-compose.erb +270 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/end-to-end.erb +30 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/localstack/init-aws.sh +70 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/naxsi/readme.md +1 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/postgres/docker-entrypoint-initdb.d/make_payments_databases.sql +26 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/adminusers.env +49 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/cardid.env +2 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/connector.env +70 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/demo-service.env +10 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/frontend.env +12 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/java_app.env +1 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ledger.env +7 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/products-ui.env +14 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/products.env +25 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/publicapi.env +13 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/publicauth.env +13 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/selfservice.env +21 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/certs/frontend-proxy.crt +18 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/certs/products-ui-proxy.crt +20 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/certs/selfservice-proxy.crt +20 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/certs/stubs-proxy.crt +18 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/keys/frontend-proxy.key +28 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/keys/products-ui-proxy.key +28 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/keys/selfservice-proxy.key +28 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/keys/stubs-proxy.key +28 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/make-selfsigned.sh +2 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/stubs.env +12 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/toolbox.env +5 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/webhooks.env +9 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/image_extractor.rb +20 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/local.rb +430 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/schema.rb +36 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/secrets.rb +114 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/ssm.rb +111 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/tf.rb +90 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/commands/tunnel/services.yml +49 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/config.rb +27 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/ec2.rb +38 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/entry_point.rb +52 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/environment.rb +25 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/logger.rb +3 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/logs.rb +248 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/naming.rb +44 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/secrets.rb +276 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/stop_yubico_authenticator.rb +10 -0
- package/resources/legacy-ruby-cli/lib/pay_cli/ykman_oath_credential_config.rb +70 -0
- package/resources/legacy-ruby-cli/lib/zeitwerk_setup.rb +5 -0
- package/resources/legacy-ruby-cli/package-lock.json +6 -0
- package/resources/legacy-ruby-cli/rds_access/connect.sh +149 -0
- package/resources/legacy-ruby-cli/spec/.rubocop.yml +2 -0
- package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.complex +34 -0
- package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.complex_differing_froms +33 -0
- package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.no_from +3 -0
- package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.simple +5 -0
- package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.simple_no_tag +5 -0
- package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.with_sha +5 -0
- package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.with_sha_no_tag +5 -0
- package/resources/legacy-ruby-cli/spec/lib/pay_cli/commands/local/image_extractor_spec.rb +55 -0
- package/resources/legacy-ruby-cli/spec/naming_spec.rb +83 -0
- package/resources/legacy-ruby-cli/spec/spec_helper.rb +106 -0
- package/resources/legacy-ruby-cli/vulnerability_scan/.nvmrc +1 -0
- package/resources/legacy-ruby-cli/vulnerability_scan/generate_vulnerability_report.js +91 -0
- package/resources/legacy-ruby-cli/vulnerability_scan/reports/.gitkeep +0 -0
- package/resources/legacy-ruby-cli/vulnerability_scan/scan.sh +57 -0
- package/src/commands/browse.js +2 -2
- package/src/commands/legacy.js +5 -2
- package/src/core/constants.js +7 -10
- package/src/util/payCliExec.js +18 -1
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
module PayCLI::Commands::Local::AppClient
|
|
2
|
+
Config = PayCLI::Commands::Local::Config
|
|
3
|
+
|
|
4
|
+
def self.create_account(service_id = nil, email_settings = { email_collection_mode: 'MANDATORY' })
|
|
5
|
+
gateway_account_data = {
|
|
6
|
+
payment_provider: 'sandbox',
|
|
7
|
+
service_name: 'My service',
|
|
8
|
+
type: 'test',
|
|
9
|
+
service_id: service_id
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
patch_email_collection_mode_data = {
|
|
14
|
+
op: 'replace',
|
|
15
|
+
path: 'email_collection_mode',
|
|
16
|
+
value: email_settings[:email_collection_mode]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
account = post("#{base_url 'connector'}/v1/api/accounts", gateway_account_data)
|
|
20
|
+
|
|
21
|
+
patch("#{base_url 'connector'}/v1/api/accounts/#{account["gateway_account_id"]}", patch_email_collection_mode_data)
|
|
22
|
+
patch("#{base_url 'adminusers'}/v1/api/services/#{service_id}", {
|
|
23
|
+
op: 'add',
|
|
24
|
+
path: 'gateway_account_ids',
|
|
25
|
+
value: [ account.fetch('gateway_account_id') ]
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
return account
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.create_token(gateway_account_id)
|
|
33
|
+
token_data = {
|
|
34
|
+
account_id: gateway_account_id,
|
|
35
|
+
description: 'my token',
|
|
36
|
+
created_by: 'system generated',
|
|
37
|
+
token_type: 'CARD'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
post("#{base_url 'publicauth'}/v1/frontend/auth", token_data)
|
|
41
|
+
.fetch('token')
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def self.create_payment(api_token)
|
|
45
|
+
payment_data = {
|
|
46
|
+
amount: 1000,
|
|
47
|
+
description: 'my payment',
|
|
48
|
+
reference: 'my payment reference',
|
|
49
|
+
return_url: 'https://www.payments.service.gov.uk'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
post_with_token("#{base_url('publicapi')}/v1/payments", payment_data, api_token)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def self.create_user(gateway_account_ids: [], role_name: 'admin')
|
|
56
|
+
username = SecureRandom.hex
|
|
57
|
+
user_data = {
|
|
58
|
+
gateway_account_ids: gateway_account_ids,
|
|
59
|
+
email: "#{username}@example.com",
|
|
60
|
+
password: 'aaaaaaaaaa',
|
|
61
|
+
telephone_number: '01134960000',
|
|
62
|
+
role_name: role_name
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
post("#{base_url 'adminusers'}/v1/api/users", user_data)
|
|
66
|
+
.merge(user_data)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def self.create_payment_link(api_token)
|
|
70
|
+
product_data = {
|
|
71
|
+
pay_api_token: api_token,
|
|
72
|
+
name: 'exampleName',
|
|
73
|
+
price: 100,
|
|
74
|
+
gateway_account_id: 1,
|
|
75
|
+
return_url: 'https://test.test/some_reference',
|
|
76
|
+
service_name: 'aServiceName',
|
|
77
|
+
type: 'ADHOC',
|
|
78
|
+
service_name_path: 'aServiceNamePath',
|
|
79
|
+
product_name_path: SecureRandom.hex,
|
|
80
|
+
reference_enabled: false
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
post("#{base_url 'products'}/v1/api/products/", product_data)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def self.create_service()
|
|
87
|
+
service_data = {
|
|
88
|
+
service_name: 'My service'
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
post("#{base_url 'adminusers'}/v1/api/services", service_data)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def self.post(url, data, custom_headers={}, exit_on_error = true)
|
|
95
|
+
headers = {content_type: :json, accept: :json}.merge(custom_headers)
|
|
96
|
+
begin
|
|
97
|
+
[url]
|
|
98
|
+
.map {|url| RestClient.post(url, data.to_json, headers).body}
|
|
99
|
+
.map {|response| JSON.parse(response)}
|
|
100
|
+
.first
|
|
101
|
+
rescue => e
|
|
102
|
+
begin
|
|
103
|
+
STDERR.puts "😬 Calling #{url} got error #{e.response}... sssorry about that"
|
|
104
|
+
rescue
|
|
105
|
+
STDERR.puts "🤔 Hmm, seems we cannot connect to #{url}. Here is what's up at the moment:"
|
|
106
|
+
report_state Config::all, false
|
|
107
|
+
end
|
|
108
|
+
exit 1 if exit_on_error
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def self.patch(url, data, custom_headers={}, exit_on_error = true)
|
|
113
|
+
headers = {content_type: :json, accept: :json}.merge(custom_headers)
|
|
114
|
+
begin
|
|
115
|
+
RestClient.patch(url, data.to_json, headers)
|
|
116
|
+
rescue => e
|
|
117
|
+
begin
|
|
118
|
+
STDERR.puts "😬 Calling #{url} got error #{e.response}... sssorry about that"
|
|
119
|
+
rescue
|
|
120
|
+
STDERR.puts "🤔 Hmm, seems we cannot connect to #{url}. Here is what's up at the moment:"
|
|
121
|
+
report_state Config::all, false
|
|
122
|
+
end
|
|
123
|
+
exit 1 if exit_on_error
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def self.wait_for_apps(apps)
|
|
128
|
+
timeout = 0
|
|
129
|
+
app_states = list_app_states apps
|
|
130
|
+
|
|
131
|
+
until all_up_states?(app_states) || timeout > 60 do
|
|
132
|
+
STDERR.print [
|
|
133
|
+
'🙄 Waiting for',
|
|
134
|
+
app_states
|
|
135
|
+
.reject {|app_state| app_state[:healthy]}
|
|
136
|
+
.map {|app_state| ' ' + app_state[:app_name]}.join(','),
|
|
137
|
+
+ " \r"
|
|
138
|
+
].join('')
|
|
139
|
+
|
|
140
|
+
$stdout.flush
|
|
141
|
+
timeout += 1
|
|
142
|
+
app_states = list_app_states apps
|
|
143
|
+
sleep 1
|
|
144
|
+
end
|
|
145
|
+
STDERR.puts "\n\n"
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def self.report_state(apps, summarise = true)
|
|
149
|
+
app_states = list_app_states apps
|
|
150
|
+
STDERR.puts app_states.map {|app_state| "#{app_state[:healthy] ? '✅' : '🔴'} #{app_state[:app_name]}"}
|
|
151
|
+
if all_up_states?(app_states)
|
|
152
|
+
STDERR.puts "\n🎉 Ready to roll\n\n"
|
|
153
|
+
else
|
|
154
|
+
STDERR.puts "\n💥 Hmmm, something not quite right"
|
|
155
|
+
STDERR.puts "ℹ️ It may have just timed out waiting so you could just try again"
|
|
156
|
+
STDERR.puts "ℹ️ Make sure you have the latest pay-infra"
|
|
157
|
+
STDERR.puts "ℹ️ docker logs <app> should tell you if an app failed to launch"
|
|
158
|
+
STDERR.puts "ℹ️ docker inspect <app> may give some clues under State"
|
|
159
|
+
STDERR.puts "ℹ️ pay local nuke is drastic but may help"
|
|
160
|
+
STDERR.puts "ℹ️ docker system prune --all is also drastic but may get things working"
|
|
161
|
+
STDERR.puts "ℹ️ You may need to increase the memory in Docker Desktop settings\n\n"
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
end if summarise
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def self.get(url)
|
|
168
|
+
RestClient::Request.execute(
|
|
169
|
+
:url => url,
|
|
170
|
+
:method => :get,
|
|
171
|
+
:headers => {accept: :json},
|
|
172
|
+
:verify_ssl => false
|
|
173
|
+
)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def self.post_with_token(url, data, token, exit_on_error = true)
|
|
177
|
+
post(url, data, {authorization: "Bearer #{token}"}, exit_on_error)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def self.is_app_up?(app_name)
|
|
181
|
+
return true unless Config::has_healthcheck(app_name)
|
|
182
|
+
begin
|
|
183
|
+
get("#{base_url app_name}/healthcheck").code.equal? 200
|
|
184
|
+
rescue
|
|
185
|
+
false
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def self.is_proxy_up?(app_name)
|
|
190
|
+
begin
|
|
191
|
+
get("#{base_proxy_url app_name}/healthcheck").code.equal? 200
|
|
192
|
+
rescue
|
|
193
|
+
false
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def self.all_up?(apps)
|
|
198
|
+
all_up_states? list_app_states apps
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def self.all_up_states?(app_states)
|
|
202
|
+
app_states.reject {|app| app[:healthy]}.length.equal? 0
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def self.list_app_states(apps)
|
|
206
|
+
apps.map {|app| {app_name: app[:name], healthy: is_app_up?(app[:name])}}
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def self.base_url(app_name)
|
|
210
|
+
"http://localhost:#{Config::port app_name}"
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def self.base_proxy_url(app_name)
|
|
214
|
+
"https://localhost:#{Config::proxy_port app_name}"
|
|
215
|
+
end
|
|
216
|
+
end
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
module PayCLI::Commands::Local::Config
|
|
2
|
+
@apps = ActiveSupport::HashWithIndifferentAccess.new(YAML.load_file("#{File.dirname(__FILE__)}/config.yaml")).values
|
|
3
|
+
|
|
4
|
+
def self.all
|
|
5
|
+
@apps
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.boring
|
|
9
|
+
@apps.select {|app| app[:experimental] != true }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.port(app_name)
|
|
13
|
+
self.get_config app_name, :port
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.admin_port(app_name)
|
|
17
|
+
self.get_config app_name, :admin_port
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.get_config(app_name, field)
|
|
21
|
+
@apps.select {|app| app[:name] == app_name}.map {|app| app[field]}.first
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.has_healthcheck(app_name)
|
|
25
|
+
@apps.select {|app| app[:name] == app_name}.map {|app| app[:healthcheck]}.first
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.uses_redis(app_name)
|
|
29
|
+
@apps.select {|app| app[:name] == app_name}.any? {|app| app.fetch(:uses_redis, false)}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.proxy_port(app_name)
|
|
33
|
+
@apps.select {|app| app[:name] == app_name}.map {|app| app[:proxy_port]}.first
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.cluster( cluster, apps)
|
|
37
|
+
apps.select {|app| app[:clusters].include?(cluster)}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.local(local_app_names, apps)
|
|
41
|
+
apps.select {|app| local_app_names.include? app[:name]}
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def self.remote(local_app_names, apps)
|
|
45
|
+
apps.select {|app| !local_app_names.include? app[:name]}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.filter(app_names, apps)
|
|
49
|
+
apps.select {|app| app_names.include? app[:name]}
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def self.node(apps)
|
|
53
|
+
apps.select { |app| app[:type] == 'node'}
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.java(apps)
|
|
57
|
+
apps.select { |app| app[:type] == 'java'}
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def self.has_db(apps)
|
|
61
|
+
apps.select {|app| app[:db]}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def self.has_proxy(apps)
|
|
65
|
+
apps.select {|app| app[:proxy]}
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def self.has_queue(apps)
|
|
69
|
+
apps.select {|app| app[:queues]}
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def self.has_sns_topics(apps)
|
|
73
|
+
apps.select { |app| app[:sns_topics] }
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def self.uses_localstack(apps)
|
|
77
|
+
has_queue(apps).any? || has_sns_topics(apps).any?
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def self.db_configs(apps)
|
|
81
|
+
apps.map {|app| {
|
|
82
|
+
name: app[:name] + '_db',
|
|
83
|
+
port: app[:db_port]
|
|
84
|
+
}}
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def self.app_by_name(name)
|
|
88
|
+
@apps.select do |app|
|
|
89
|
+
app[:name] == name
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def self.proxy_configs(apps)
|
|
94
|
+
apps.map {|app|
|
|
95
|
+
if app[:naxsi]
|
|
96
|
+
md5 = copy_naxsi_rules(app).hexdigest
|
|
97
|
+
end
|
|
98
|
+
{
|
|
99
|
+
name: app[:name] + '-proxy',
|
|
100
|
+
port: app[:proxy_port],
|
|
101
|
+
proxy_port: app[:port],
|
|
102
|
+
proxy_host: app[:name],
|
|
103
|
+
naxsi_md5: md5
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def self.copy_naxsi_rules(app)
|
|
109
|
+
naxsi_rule_dest = File.join(
|
|
110
|
+
File.dirname(__FILE__),
|
|
111
|
+
"files/naxsi/#{app[:name]}.rules")
|
|
112
|
+
|
|
113
|
+
naxsi_rule_source = File.join(
|
|
114
|
+
File.dirname(__FILE__),
|
|
115
|
+
'..', '..', '..', '..', '..',
|
|
116
|
+
'provisioning',
|
|
117
|
+
'terraform',
|
|
118
|
+
'modules',
|
|
119
|
+
'pay_microservices_v2',
|
|
120
|
+
app[:name],
|
|
121
|
+
'files',
|
|
122
|
+
"#{app[:name]}.naxsi")
|
|
123
|
+
|
|
124
|
+
FileUtils.copy(naxsi_rule_source, naxsi_rule_dest)
|
|
125
|
+
|
|
126
|
+
Digest::MD5.file naxsi_rule_dest
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def self.write_end_to_end_config(binding)
|
|
130
|
+
erb = ERB.new(File.read(File.join(
|
|
131
|
+
File.dirname(__FILE__),
|
|
132
|
+
'files',
|
|
133
|
+
'end-to-end.erb')), trim_mode: '-')
|
|
134
|
+
|
|
135
|
+
erb.result(binding)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
end
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
adminusers:
|
|
2
|
+
name: adminusers
|
|
3
|
+
type: java
|
|
4
|
+
db: true
|
|
5
|
+
db_port: 19700
|
|
6
|
+
port: 9700
|
|
7
|
+
admin_port: 9701
|
|
8
|
+
healthcheck: true
|
|
9
|
+
queues:
|
|
10
|
+
AWS_SQS_CONNECTOR_TASKS_QUEUE_URL: connector_tasks_queue
|
|
11
|
+
clusters:
|
|
12
|
+
- admin
|
|
13
|
+
- paymentlinks
|
|
14
|
+
- card
|
|
15
|
+
- endtoend
|
|
16
|
+
- java
|
|
17
|
+
- toolbox
|
|
18
|
+
connector:
|
|
19
|
+
name: connector
|
|
20
|
+
type: java
|
|
21
|
+
db: true
|
|
22
|
+
db_port: 19300
|
|
23
|
+
port: 9300
|
|
24
|
+
admin_port: 9301
|
|
25
|
+
healthcheck: true
|
|
26
|
+
queues:
|
|
27
|
+
AWS_SQS_CAPTURE_QUEUE_URL: pay_capture_queue
|
|
28
|
+
AWS_SQS_PAYMENT_EVENT_QUEUE_URL: pay_event_queue
|
|
29
|
+
AWS_SQS_PAYOUT_RECONCILE_QUEUE_URL: payout_reconcile_queue
|
|
30
|
+
AWS_SQS_CONNECTOR_TASKS_QUEUE_URL: connector_tasks_queue
|
|
31
|
+
clusters:
|
|
32
|
+
- admin
|
|
33
|
+
- paymentlinks
|
|
34
|
+
- card
|
|
35
|
+
- endtoend
|
|
36
|
+
- java
|
|
37
|
+
- toolbox
|
|
38
|
+
cardid:
|
|
39
|
+
name: cardid
|
|
40
|
+
type: java
|
|
41
|
+
port: 9900
|
|
42
|
+
admin_port: 9901
|
|
43
|
+
healthcheck: true
|
|
44
|
+
clusters:
|
|
45
|
+
- paymentlinks
|
|
46
|
+
- card
|
|
47
|
+
- endtoend
|
|
48
|
+
- java
|
|
49
|
+
publicauth:
|
|
50
|
+
name: publicauth
|
|
51
|
+
type: java
|
|
52
|
+
db: true
|
|
53
|
+
db_port: 19600
|
|
54
|
+
port: 9600
|
|
55
|
+
admin_port: 9601
|
|
56
|
+
healthcheck: true
|
|
57
|
+
clusters:
|
|
58
|
+
- admin
|
|
59
|
+
- paymentlinks
|
|
60
|
+
- card
|
|
61
|
+
- endtoend
|
|
62
|
+
- java
|
|
63
|
+
- toolbox
|
|
64
|
+
publicapi:
|
|
65
|
+
name: publicapi
|
|
66
|
+
type: java
|
|
67
|
+
port: 9100
|
|
68
|
+
admin_port: 9101
|
|
69
|
+
healthcheck: true
|
|
70
|
+
uses_redis: true
|
|
71
|
+
environment_overrides:
|
|
72
|
+
REDIS_URL: "redis"
|
|
73
|
+
clusters:
|
|
74
|
+
- paymentlinks
|
|
75
|
+
- card
|
|
76
|
+
- endtoend
|
|
77
|
+
- java
|
|
78
|
+
products:
|
|
79
|
+
name: products
|
|
80
|
+
type: java
|
|
81
|
+
db: true
|
|
82
|
+
db_port: 19800
|
|
83
|
+
port: 18000
|
|
84
|
+
admin_port: 18001
|
|
85
|
+
healthcheck: true
|
|
86
|
+
clusters:
|
|
87
|
+
- admin
|
|
88
|
+
- paymentlinks
|
|
89
|
+
- endtoend
|
|
90
|
+
- java
|
|
91
|
+
- toolbox
|
|
92
|
+
frontend:
|
|
93
|
+
name: frontend
|
|
94
|
+
proxy: true
|
|
95
|
+
naxsi: true
|
|
96
|
+
type: node
|
|
97
|
+
db: false
|
|
98
|
+
port: 9000
|
|
99
|
+
debug_port: 9001
|
|
100
|
+
proxy_port: 29000
|
|
101
|
+
healthcheck: true
|
|
102
|
+
clusters:
|
|
103
|
+
- paymentlinks
|
|
104
|
+
- card
|
|
105
|
+
- endtoend
|
|
106
|
+
selfservice:
|
|
107
|
+
proxy: true
|
|
108
|
+
naxsi: true
|
|
109
|
+
name: selfservice
|
|
110
|
+
type: node
|
|
111
|
+
db: false
|
|
112
|
+
port: 9400
|
|
113
|
+
debug_port: 9401
|
|
114
|
+
healthcheck: true
|
|
115
|
+
proxy_port: 39000
|
|
116
|
+
clusters:
|
|
117
|
+
- admin
|
|
118
|
+
- endtoend
|
|
119
|
+
- webhooks
|
|
120
|
+
products-ui:
|
|
121
|
+
name: products-ui
|
|
122
|
+
proxy: true
|
|
123
|
+
type: node
|
|
124
|
+
db: false
|
|
125
|
+
port: 10400
|
|
126
|
+
debug_port: 10401
|
|
127
|
+
proxy_port: 19000
|
|
128
|
+
healthcheck: true
|
|
129
|
+
clusters:
|
|
130
|
+
- paymentlinks
|
|
131
|
+
- endtoend
|
|
132
|
+
stubs:
|
|
133
|
+
name: stubs
|
|
134
|
+
proxy: true
|
|
135
|
+
type: node
|
|
136
|
+
db: false
|
|
137
|
+
port: 3030
|
|
138
|
+
debug_port: 3031
|
|
139
|
+
proxy_port: 29100
|
|
140
|
+
healthcheck: false
|
|
141
|
+
clusters:
|
|
142
|
+
- endtoend
|
|
143
|
+
ledger:
|
|
144
|
+
name: ledger
|
|
145
|
+
type: java
|
|
146
|
+
db: true
|
|
147
|
+
db_port: 20700
|
|
148
|
+
port: 10700
|
|
149
|
+
admin_port: 10701
|
|
150
|
+
healthcheck: true
|
|
151
|
+
queues:
|
|
152
|
+
AWS_SQS_PAYMENT_EVENT_QUEUE_URL: pay_event_queue
|
|
153
|
+
sns_topics:
|
|
154
|
+
SNS_TOPIC_CARD_PAYMENT_EVENTS: card-payment-events-topic
|
|
155
|
+
SNS_TOPIC_CARD_PAYMENT_DISPUTE_EVENTS: card-payment-dispute-events-topic
|
|
156
|
+
environment_overrides:
|
|
157
|
+
SNS_ENABLED: "true"
|
|
158
|
+
PUBLISH_CARD_PAYMENT_EVENTS_TO_SNS: "true"
|
|
159
|
+
PUBLISH_CARD_PAYMENT_DISPUTE_EVENTS_TO_SNS: "true"
|
|
160
|
+
clusters:
|
|
161
|
+
- admin
|
|
162
|
+
- card
|
|
163
|
+
- endtoend
|
|
164
|
+
- java
|
|
165
|
+
- toolbox
|
|
166
|
+
toolbox:
|
|
167
|
+
name: toolbox
|
|
168
|
+
type: node
|
|
169
|
+
db: false
|
|
170
|
+
port: 3040
|
|
171
|
+
debug_port: 3041
|
|
172
|
+
healthcheck: true
|
|
173
|
+
entrypoint_override_local: 'sh -c "npm run build:copy && npm --inspect=0.0.0.0:3041 start"'
|
|
174
|
+
clusters:
|
|
175
|
+
- toolbox
|
|
176
|
+
webhooks:
|
|
177
|
+
name: webhooks
|
|
178
|
+
type: java
|
|
179
|
+
db: true
|
|
180
|
+
db_port: 20800
|
|
181
|
+
port: 10800
|
|
182
|
+
admin_port: 10801
|
|
183
|
+
healthcheck: true
|
|
184
|
+
queues:
|
|
185
|
+
AWS_SQS_PAYMENT_EVENT_QUEUE_URL: webhooks-events-subscriber-queue
|
|
186
|
+
clusters:
|
|
187
|
+
- admin
|
|
188
|
+
- card
|
|
189
|
+
- endtoend
|
|
190
|
+
- java
|
|
191
|
+
- toolbox
|
|
192
|
+
- webhooks
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module PayCLI::Commands::Local::Docker
|
|
2
|
+
def self.remove(app, force=true)
|
|
3
|
+
`docker rm #{'-f' if force} -v #{app} 2>/dev/null`
|
|
4
|
+
STDERR.puts " 💀 #{app}"
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def self.write_compose_file(cluster, binding)
|
|
8
|
+
compose_file = compose_file cluster
|
|
9
|
+
|
|
10
|
+
erb = ERB.new(File.read(File.join(
|
|
11
|
+
File.dirname(__FILE__),
|
|
12
|
+
'files',
|
|
13
|
+
'docker-compose.erb')), trim_mode: '-')
|
|
14
|
+
|
|
15
|
+
File.write(compose_file, erb.result(binding))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.pull(cluster)
|
|
19
|
+
`docker-compose -f #{compose_file cluster} pull`
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.up(cluster)
|
|
23
|
+
`docker-compose -f #{compose_file cluster} up --detach`
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.down(cluster)
|
|
27
|
+
`docker-compose --log-level ERROR -f #{compose_file cluster} down`
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.compose_file(cluster)
|
|
31
|
+
File.join(
|
|
32
|
+
File.dirname(__FILE__),
|
|
33
|
+
'files',
|
|
34
|
+
"#{cluster}.yaml")
|
|
35
|
+
end
|
|
36
|
+
end
|