@govuk-pay/cli 0.0.13 → 0.0.15
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
CHANGED
|
@@ -3,42 +3,4 @@ module PayCLI::Naming
|
|
|
3
3
|
microservice = 'www' if microservice == 'frontend'
|
|
4
4
|
"#{env}-#{microservice}-ecs-appserver"
|
|
5
5
|
end
|
|
6
|
-
|
|
7
|
-
def self.elb_names(env, services)
|
|
8
|
-
services
|
|
9
|
-
.map { |s| s.gsub(/notifications/, 'notices') }
|
|
10
|
-
.map { |s| "#{env}-#{s}-ecs-elb" }
|
|
11
|
-
.zip(services)
|
|
12
|
-
.to_h
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.domain_name(env)
|
|
16
|
-
acc = env.split('-').first
|
|
17
|
-
|
|
18
|
-
case acc
|
|
19
|
-
when 'deploy', 'staging', 'production'
|
|
20
|
-
'payments.service.gov.uk'
|
|
21
|
-
else
|
|
22
|
-
'pymnt.uk'
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def self.bucket_name(env)
|
|
27
|
-
acc = env.split('-').first
|
|
28
|
-
|
|
29
|
-
case acc
|
|
30
|
-
when 'dev', 'test'
|
|
31
|
-
'pay-govuk-terraform-state-ci'
|
|
32
|
-
when 'staging', 'production'
|
|
33
|
-
'pay-govuk-terraform-state-deploy'
|
|
34
|
-
else
|
|
35
|
-
"pay-govuk-terraform-state-#{acc}"
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def self.db_name(env, service)
|
|
40
|
-
microservice = service['service_name'].gsub(/_db$/, '')
|
|
41
|
-
version = service.dig('instance_version', env) || '0'
|
|
42
|
-
"#{env}-#{microservice}-rds-#{version}"
|
|
43
|
-
end
|
|
44
6
|
end
|
|
@@ -16,68 +16,4 @@ RSpec.describe 'pay naming' do
|
|
|
16
16
|
)).to eq('env-name-cardid-ecs-appserver')
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
|
-
|
|
20
|
-
context 'elb names' do
|
|
21
|
-
it 'elb names to be correct' do
|
|
22
|
-
names = PayCLI::Naming.elb_names(
|
|
23
|
-
'env-name',
|
|
24
|
-
%w(adminusers connector products publicauth notifications ledger)
|
|
25
|
-
)
|
|
26
|
-
expected_names = {
|
|
27
|
-
'env-name-adminusers-ecs-elb' => 'adminusers',
|
|
28
|
-
'env-name-connector-ecs-elb' => 'connector',
|
|
29
|
-
'env-name-products-ecs-elb' => 'products',
|
|
30
|
-
'env-name-publicauth-ecs-elb' => 'publicauth',
|
|
31
|
-
'env-name-notices-ecs-elb' => 'notifications',
|
|
32
|
-
'env-name-ledger-ecs-elb' => 'ledger',
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
expect(names).to eq(expected_names)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
context 'domain names' do
|
|
40
|
-
it 'domain names to be correct' do
|
|
41
|
-
expected_domain_names = %w(
|
|
42
|
-
pymnt.uk pymnt.uk pymnt.uk
|
|
43
|
-
payments.service.gov.uk payments.service.gov.uk payments.service.gov.uk
|
|
44
|
-
pymnt.uk
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
actual_domain_names = %w(
|
|
48
|
-
ci dev test deploy staging production blah
|
|
49
|
-
).map { |env| PayCLI::Naming.domain_name(env) }
|
|
50
|
-
|
|
51
|
-
expect(actual_domain_names).to eq(expected_domain_names)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
context 'bucket names' do
|
|
56
|
-
it 'ci bucket is correct' do
|
|
57
|
-
expected_name = 'pay-govuk-terraform-state-ci'
|
|
58
|
-
expect(%w( ci dev test ).all? do |e|
|
|
59
|
-
PayCLI::Naming.bucket_name(e) == expected_name
|
|
60
|
-
end).to eq(true)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it 'deploy bucket is correct' do
|
|
64
|
-
expected_name = 'pay-govuk-terraform-state-deploy'
|
|
65
|
-
expect(%w( staging production deploy ).all? do |e|
|
|
66
|
-
PayCLI::Naming.bucket_name(e) == expected_name
|
|
67
|
-
end).to eq(true)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it 'arbtrary-env bucket is correct' do
|
|
71
|
-
expect(PayCLI::Naming.bucket_name('arbitrary')).to eq('pay-govuk-terraform-state-arbitrary')
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
context 'db names' do
|
|
76
|
-
it 'resolves instance name with no version specified' do
|
|
77
|
-
service = { 'service_name' => 'connector' }
|
|
78
|
-
expect(
|
|
79
|
-
PayCLI::Naming.db_name('env-1', service)
|
|
80
|
-
).to eq('env-1-connector-rds-0')
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
19
|
end
|