govuk-connect 0.1.0 → 0.2.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 +4 -4
- data/lib/govuk_connect/cli.rb +47 -41
- data/lib/govuk_connect/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caebe6cb74e7454207be9c5415c147d5afc710bc2767b3784a0a314cba233762
|
4
|
+
data.tar.gz: 11cddb0747edba0ccb1a96ba45cbc454a4a19f37ef46395bc057a9eb7814ec52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bec29749ec1eb4024f91bffd6147594796b165556f98b5bfcb9c2be4a0b983cd01681ae9e3938e54c75a0d344661a8dc3bf198d4d7a59040fc4108cd2e4af19f
|
7
|
+
data.tar.gz: 2cb2274d0ef354af3639b76d4b0464f5b9fe2c663805e21177f9fa8a82e41b7b932aad46ce020418f136da1149154617ebfd6a34c00a70a8d0ab2e06fe4768ca
|
data/lib/govuk_connect/cli.rb
CHANGED
@@ -75,10 +75,13 @@ class GovukConnect::CLI
|
|
75
75
|
"sidekiq-monitoring" => "Setup port forwarding to the Sidekiq Monitoring application.",
|
76
76
|
}.freeze
|
77
77
|
|
78
|
-
RABBITMQ_PORT =
|
78
|
+
RABBITMQ_PORT = 15_672
|
79
79
|
SIDEKIQ_MONITORING_PORT = 3211
|
80
80
|
|
81
81
|
JUMPBOXES = {
|
82
|
+
test: {
|
83
|
+
aws: "jumpbox.pink.test.govuk.digital",
|
84
|
+
},
|
82
85
|
ci: {
|
83
86
|
carrenza: "ci-jumpbox.integration.publishing.service.gov.uk",
|
84
87
|
},
|
@@ -96,7 +99,7 @@ class GovukConnect::CLI
|
|
96
99
|
}.freeze
|
97
100
|
|
98
101
|
def log(message)
|
99
|
-
warn message if
|
102
|
+
warn message if @verbose
|
100
103
|
end
|
101
104
|
|
102
105
|
def print_empty_line
|
@@ -125,10 +128,12 @@ class GovukConnect::CLI
|
|
125
128
|
costs[0] = i
|
126
129
|
nw = i - 1 # j == 0; nw is lev(i-1, j)
|
127
130
|
(1..string2.length).each do |j|
|
128
|
-
costs[j]
|
129
|
-
costs[j] + 1,
|
130
|
-
|
131
|
-
|
131
|
+
costs[j] = [
|
132
|
+
costs[j] + 1,
|
133
|
+
costs[j - 1] + 1,
|
134
|
+
string1[i - 1] == string2[j - 1] ? nw : nw + 1,
|
135
|
+
].min
|
136
|
+
nw = costs[j]
|
132
137
|
end
|
133
138
|
end
|
134
139
|
costs[string2.length]
|
@@ -176,7 +181,7 @@ class GovukConnect::CLI
|
|
176
181
|
tries = 0
|
177
182
|
|
178
183
|
while tries <= 10
|
179
|
-
port = rand(
|
184
|
+
port = rand(32_768...61_000)
|
180
185
|
|
181
186
|
return port if port_free? port
|
182
187
|
|
@@ -228,7 +233,7 @@ class GovukConnect::CLI
|
|
228
233
|
def ssh_username
|
229
234
|
@ssh_username ||= begin
|
230
235
|
if File.exist? config_file
|
231
|
-
config_ssh_username = YAML
|
236
|
+
config_ssh_username = YAML.load_file(config_file)["ssh_username"]
|
232
237
|
end
|
233
238
|
|
234
239
|
config_ssh_username || ENV["USER"]
|
@@ -237,7 +242,7 @@ class GovukConnect::CLI
|
|
237
242
|
|
238
243
|
def ssh_identity_file
|
239
244
|
@ssh_identity_file ||= begin
|
240
|
-
YAML
|
245
|
+
YAML.load_file(config_file)["ssh_identity_file"] if File.exist? config_file
|
241
246
|
end
|
242
247
|
end
|
243
248
|
|
@@ -257,13 +262,14 @@ class GovukConnect::CLI
|
|
257
262
|
log "debug: looking up classes in #{hosting}/#{environment}"
|
258
263
|
command = [
|
259
264
|
"ssh",
|
260
|
-
"-o",
|
265
|
+
"-o",
|
266
|
+
"ConnectTimeout=2", # Show a failure quickly
|
261
267
|
*ssh_identity_arguments,
|
262
268
|
user_at_host(
|
263
269
|
ssh_username,
|
264
270
|
jumpbox_for_environment_and_hosting(environment, hosting),
|
265
271
|
),
|
266
|
-
"govuk_node_list --classes"
|
272
|
+
"govuk_node_list --classes",
|
267
273
|
].join(" ")
|
268
274
|
|
269
275
|
log "debug: running command: #{command}"
|
@@ -287,13 +293,14 @@ class GovukConnect::CLI
|
|
287
293
|
def get_domains_for_node_class(target, environment, hosting, ssh_username)
|
288
294
|
command = [
|
289
295
|
"ssh",
|
290
|
-
"-o",
|
296
|
+
"-o",
|
297
|
+
"ConnectTimeout=2", # Show a failure quickly
|
291
298
|
*ssh_identity_arguments,
|
292
299
|
user_at_host(
|
293
300
|
ssh_username,
|
294
301
|
jumpbox_for_environment_and_hosting(environment, hosting),
|
295
302
|
),
|
296
|
-
"govuk_node_list -c #{target}"
|
303
|
+
"govuk_node_list -c #{target}",
|
297
304
|
].join(" ")
|
298
305
|
|
299
306
|
output, status = Open3.capture2(command)
|
@@ -327,12 +334,12 @@ class GovukConnect::CLI
|
|
327
334
|
hieradata_file = File.join(local_hieradata_root, "#{environment}.yaml")
|
328
335
|
log "debug: reading #{hieradata_file}"
|
329
336
|
|
330
|
-
environment_specific_hieradata = YAML
|
337
|
+
environment_specific_hieradata = YAML.load_file(hieradata_file)
|
331
338
|
|
332
339
|
if environment_specific_hieradata["node_class"]
|
333
340
|
environment_specific_hieradata["node_class"]
|
334
341
|
else
|
335
|
-
common_hieradata = YAML
|
342
|
+
common_hieradata = YAML.load_file(
|
336
343
|
File.join(local_hieradata_root, "common.yaml"),
|
337
344
|
)
|
338
345
|
|
@@ -511,7 +518,7 @@ class GovukConnect::CLI
|
|
511
518
|
app_name,
|
512
519
|
environment,
|
513
520
|
hosting,
|
514
|
-
|
521
|
+
)
|
515
522
|
|
516
523
|
unless node_class
|
517
524
|
error "error: application '#{app_name}' not found."
|
@@ -551,11 +558,11 @@ class GovukConnect::CLI
|
|
551
558
|
|
552
559
|
def ssh(
|
553
560
|
target,
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
561
|
+
environment,
|
562
|
+
command: false,
|
563
|
+
port_forward: false,
|
564
|
+
additional_arguments: []
|
565
|
+
)
|
559
566
|
log "debug: ssh to #{target} in #{environment}"
|
560
567
|
|
561
568
|
# Split something like aws/backend:2 in to :aws, 'backend', 2
|
@@ -627,14 +634,15 @@ class GovukConnect::CLI
|
|
627
634
|
ssh_command = [
|
628
635
|
"ssh",
|
629
636
|
*ssh_identity_arguments,
|
630
|
-
"-J",
|
637
|
+
"-J",
|
638
|
+
user_at_host(
|
631
639
|
ssh_username,
|
632
640
|
jumpbox_for_environment_and_hosting(environment, hosting),
|
633
641
|
),
|
634
642
|
user_at_host(
|
635
643
|
ssh_username,
|
636
644
|
ssh_target,
|
637
|
-
)
|
645
|
+
),
|
638
646
|
]
|
639
647
|
|
640
648
|
if command
|
@@ -647,7 +655,8 @@ class GovukConnect::CLI
|
|
647
655
|
|
648
656
|
ssh_command += [
|
649
657
|
"-N",
|
650
|
-
"-L",
|
658
|
+
"-L",
|
659
|
+
"#{localhost_port}:127.0.0.1:#{port_forward}",
|
651
660
|
]
|
652
661
|
|
653
662
|
info "Port forwarding setup, access:\n\n http://127.0.0.1:#{localhost_port}/\n\n"
|
@@ -679,14 +688,14 @@ class GovukConnect::CLI
|
|
679
688
|
uri = URI(url)
|
680
689
|
|
681
690
|
host_to_hosting_and_environment = {
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
691
|
+
"ci-alert.integration.publishing.service.gov.uk" => %i[carrenza ci],
|
692
|
+
"alert.integration.publishing.service.gov.uk" => %i[aws integration],
|
693
|
+
"alert.staging.govuk.digital" => %i[aws staging],
|
694
|
+
"alert.blue.staging.govuk.digital" => %i[aws staging],
|
695
|
+
"alert.staging.publishing.service.gov.uk" => %i[carrenza staging],
|
696
|
+
"alert.production.govuk.digital" => %i[aws production],
|
697
|
+
"alert.blue.production.govuk.digital" => %i[aws production],
|
698
|
+
"alert.publishing.service.gov.uk" => %i[carrenza production],
|
690
699
|
}
|
691
700
|
|
692
701
|
unless host_to_hosting_and_environment.key? uri.host
|
@@ -699,8 +708,6 @@ class GovukConnect::CLI
|
|
699
708
|
|
700
709
|
def parse_options(argv)
|
701
710
|
options = {}
|
702
|
-
|
703
|
-
# rubocop:disable Metrics/BlockLength
|
704
711
|
@option_parser = OptionParser.new do |opts|
|
705
712
|
opts.banner = USAGE_BANNER
|
706
713
|
|
@@ -723,7 +730,7 @@ class GovukConnect::CLI
|
|
723
730
|
options[:port_forward] = o
|
724
731
|
end
|
725
732
|
opts.on("-v", "--verbose", "Enable more detailed logging") do
|
726
|
-
|
733
|
+
@verbose = true
|
727
734
|
end
|
728
735
|
|
729
736
|
opts.on("-h", "--help", "Prints usage information and examples") do
|
@@ -751,7 +758,6 @@ class GovukConnect::CLI
|
|
751
758
|
exit
|
752
759
|
end
|
753
760
|
end
|
754
|
-
# rubocop:enable Metrics/BlockLength
|
755
761
|
|
756
762
|
@option_parser.parse!(argv)
|
757
763
|
|
@@ -842,19 +848,19 @@ class GovukConnect::CLI
|
|
842
848
|
|
843
849
|
def types
|
844
850
|
@types ||= {
|
845
|
-
"app-console" =>
|
851
|
+
"app-console" => proc do |target, environment, args, _options|
|
846
852
|
check_for_target(target)
|
847
853
|
check_for_additional_arguments("app-console", args)
|
848
854
|
govuk_app_command(target, environment, "console")
|
849
855
|
end,
|
850
856
|
|
851
|
-
"app-dbconsole" =>
|
857
|
+
"app-dbconsole" => proc do |target, environment, args, _options|
|
852
858
|
check_for_target(target)
|
853
859
|
check_for_additional_arguments("app-dbconsole", args)
|
854
860
|
govuk_app_command(target, environment, "dbconsole")
|
855
861
|
end,
|
856
862
|
|
857
|
-
"rabbitmq" =>
|
863
|
+
"rabbitmq" => proc do |target, environment, args, _options|
|
858
864
|
check_for_additional_arguments("rabbitmq", args)
|
859
865
|
|
860
866
|
target ||= "rabbitmq"
|
@@ -876,7 +882,7 @@ class GovukConnect::CLI
|
|
876
882
|
)
|
877
883
|
end,
|
878
884
|
|
879
|
-
"sidekiq-monitoring" =>
|
885
|
+
"sidekiq-monitoring" => proc do |target, environment, args, _options|
|
880
886
|
check_for_additional_arguments("sidekiq-monitoring", args)
|
881
887
|
ssh(
|
882
888
|
target || "backend",
|
@@ -885,7 +891,7 @@ class GovukConnect::CLI
|
|
885
891
|
)
|
886
892
|
end,
|
887
893
|
|
888
|
-
"ssh" =>
|
894
|
+
"ssh" => proc do |target, environment, args, options|
|
889
895
|
check_for_target(target)
|
890
896
|
|
891
897
|
if options.key? :hosting
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk-connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Government Digital Service
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: climate_control
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.
|
61
|
+
version: 3.16.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 3.
|
68
|
+
version: 3.16.0
|
69
69
|
description: Command line tool to connect to GOV.UK infrastructure
|
70
70
|
email:
|
71
71
|
- govuk-dev@digital.cabinet-office.gov.uk
|
@@ -82,7 +82,7 @@ homepage: https://github.com/alphagov/govuk-connect
|
|
82
82
|
licenses:
|
83
83
|
- MIT
|
84
84
|
metadata: {}
|
85
|
-
post_install_message:
|
85
|
+
post_install_message:
|
86
86
|
rdoc_options: []
|
87
87
|
require_paths:
|
88
88
|
- lib
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
100
|
rubygems_version: 3.0.3
|
101
|
-
signing_key:
|
101
|
+
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: govuk-connect command line tool
|
104
104
|
test_files: []
|