govuk-connect 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/govuk_connect/cli.rb +99 -18
- data/lib/govuk_connect/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3809f92432d9568040b786cea22448406da43403917459d8bf96210457be9cd6
|
4
|
+
data.tar.gz: a606f53b33df1e4baa5c95f265c4fd078c886ec2f9d853c3950f087eb19b0201
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d47dce35c946feb4c5869eb3cbc3b7a6ac1796cdb668ecd79d79e4d19e19cd39800e9e593336239120d6681a6016e2f0c9a3561e7e6c6484f18eb1275ed002ed
|
7
|
+
data.tar.gz: 343c1544abe716c63783591c3a6d33a2cc83c03ad2bab7cb3ed273526c523dd8d46a362bd9d6333b513ea250b4c2655f2009f77d80c84cb4b6362aafbe27eb54
|
data/lib/govuk_connect/cli.rb
CHANGED
@@ -24,11 +24,9 @@ class GovukConnect::CLI
|
|
24
24
|
|
25
25
|
gds govuk connect scp-pull --environment integration backend /tmp/filename.txt ~/Downloads/
|
26
26
|
|
27
|
-
gds govuk connect app-console --environment staging publishing-api
|
28
|
-
|
29
|
-
gds govuk connect app-dbconsole -e integration whitehall_backend/whitehall
|
30
|
-
|
31
27
|
gds govuk connect rabbitmq -e staging aws/rabbitmq
|
28
|
+
|
29
|
+
gds govuk connect amazonmq -e integration
|
32
30
|
EXAMPLES
|
33
31
|
|
34
32
|
MACHINE_TARGET_DESCRIPTION = <<-DOCS.freeze
|
@@ -70,12 +68,14 @@ class GovukConnect::CLI
|
|
70
68
|
|
71
69
|
CONNECTION_TYPE_DESCRIPTIONS = {
|
72
70
|
"ssh" => "Connect to a machine through SSH.",
|
73
|
-
"app-console" => "
|
74
|
-
"app-dbconsole" => "Launch a
|
71
|
+
"app-console" => "(DEPRECATED; use kubectl instead) Launch a Rails console for an application.",
|
72
|
+
"app-dbconsole" => "(DEPRECATED; use kubectl instead) Launch a Rails database console for an application.",
|
75
73
|
"rabbitmq" => "Setup port forwarding to the RabbitMQ admin interface.",
|
74
|
+
"amazonmq" => "Setup port forwarding to the AmazonMQ admin interface.",
|
76
75
|
}.freeze
|
77
76
|
|
78
77
|
RABBITMQ_PORT = 15_672
|
78
|
+
AMAZONMQ_PORT = 443
|
79
79
|
|
80
80
|
JUMPBOXES = {
|
81
81
|
test: {
|
@@ -113,6 +113,15 @@ class GovukConnect::CLI
|
|
113
113
|
info "Check this is correct, and if it isn't, set the `USER` environment variable to the correct username."
|
114
114
|
end
|
115
115
|
|
116
|
+
def print_vpn_help_info
|
117
|
+
info "You may also wish to check that you are connected to the VPN, as attempting to SSH into an instance when NOT on the VPN can result in an operation timed out error"
|
118
|
+
end
|
119
|
+
|
120
|
+
def print_k8s_setup_info
|
121
|
+
info "If that doesn't work for you, follow the setup instructions at"
|
122
|
+
info "https://govuk-k8s-user-docs.publishing.service.gov.uk/get-started/access-eks-cluster\n"
|
123
|
+
end
|
124
|
+
|
116
125
|
# From Rosetta Code: https://rosettacode.org/wiki/Levenshtein_distance#Ruby
|
117
126
|
def levenshtein_distance(string1, string2)
|
118
127
|
string1 = string1.downcase
|
@@ -289,6 +298,8 @@ class GovukConnect::CLI
|
|
289
298
|
error "\nerror: command failed: #{command}"
|
290
299
|
print_empty_line
|
291
300
|
print_ssh_username_configuration_help
|
301
|
+
print_empty_line
|
302
|
+
print_vpn_help_info
|
292
303
|
exit 1
|
293
304
|
end
|
294
305
|
|
@@ -572,6 +583,40 @@ class GovukConnect::CLI
|
|
572
583
|
exec(*ssh_command)
|
573
584
|
end
|
574
585
|
|
586
|
+
def remote_port_forward(
|
587
|
+
target,
|
588
|
+
environment,
|
589
|
+
port_forward,
|
590
|
+
additional_arguments: []
|
591
|
+
)
|
592
|
+
log "debug: remote port-forward to #{target} in #{environment}"
|
593
|
+
|
594
|
+
target, hosting = ssh_target(target, environment)
|
595
|
+
|
596
|
+
localhost_port = random_free_port
|
597
|
+
|
598
|
+
ssh_command = [
|
599
|
+
"ssh",
|
600
|
+
*ssh_identity_arguments,
|
601
|
+
"-N",
|
602
|
+
"-L",
|
603
|
+
"#{localhost_port}:#{target}:#{port_forward}",
|
604
|
+
user_at_host(
|
605
|
+
ssh_username,
|
606
|
+
jumpbox_for_environment_and_hosting(environment, hosting),
|
607
|
+
),
|
608
|
+
]
|
609
|
+
|
610
|
+
info "Port forwarding setup, access:\n\n https://127.0.0.1:#{localhost_port}/\n\n"
|
611
|
+
info "(ignore any warnings about certificate mis-match - this is expected and OK)"
|
612
|
+
|
613
|
+
ssh_command += additional_arguments
|
614
|
+
|
615
|
+
info "\n#{bold('Running command:')} #{ssh_command.join(' ')}\n\n"
|
616
|
+
|
617
|
+
exec(*ssh_command)
|
618
|
+
end
|
619
|
+
|
575
620
|
def scp(
|
576
621
|
target,
|
577
622
|
environment,
|
@@ -624,6 +669,10 @@ class GovukConnect::CLI
|
|
624
669
|
"cd #{directory} && rake eyaml:decrypt_value[#{environment},govuk_rabbitmq::root_password]"
|
625
670
|
end
|
626
671
|
|
672
|
+
def amazonmq_root_password_command(environment)
|
673
|
+
"sops data/app-amazonmq/#{environment}/common.secret.tfvars"
|
674
|
+
end
|
675
|
+
|
627
676
|
def hosting_and_environment_from_url(url)
|
628
677
|
uri = URI(url)
|
629
678
|
|
@@ -788,7 +837,7 @@ class GovukConnect::CLI
|
|
788
837
|
# Split something like aws/backend:2 in to :aws, 'backend', 2
|
789
838
|
hosting, name, number = parse_hosting_name_and_number(target)
|
790
839
|
|
791
|
-
if name.end_with? ".internal"
|
840
|
+
if name.end_with?(".internal") || name.end_with?(".govuk-internal.digital")
|
792
841
|
target = name
|
793
842
|
hosting = :aws
|
794
843
|
else
|
@@ -801,7 +850,7 @@ class GovukConnect::CLI
|
|
801
850
|
hosting,
|
802
851
|
)
|
803
852
|
|
804
|
-
if domains.
|
853
|
+
if domains.empty?
|
805
854
|
error "error: couldn't find #{name} in #{hosting}/#{environment}"
|
806
855
|
|
807
856
|
node_types = govuk_node_list_classes(environment, hosting)
|
@@ -867,20 +916,33 @@ class GovukConnect::CLI
|
|
867
916
|
end
|
868
917
|
end
|
869
918
|
|
919
|
+
def target_name_to_k8s_deployment(target_name)
|
920
|
+
{
|
921
|
+
/draft_[a-z_]+\/([a-z_-]+)/ => "draft-\\1",
|
922
|
+
/.*\// => "", # If not draft, drop the Puppet class prefix.
|
923
|
+
"whitehall_backend/whitehall" => "whitehall-admin",
|
924
|
+
"whitehall_frontend/whitehall" => "whitehall-frontend",
|
925
|
+
}.reduce(target_name) do |result, (pattern, replacement)|
|
926
|
+
result.sub(pattern, replacement)
|
927
|
+
end
|
928
|
+
end
|
929
|
+
|
870
930
|
def types
|
871
931
|
@types ||= {
|
872
|
-
"app-console" => proc do |target,
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
932
|
+
"app-console" => proc do |target, _environment, _args, _extra_args, _options|
|
933
|
+
target ||= "<app-name>"
|
934
|
+
deployment = target_name_to_k8s_deployment(target)
|
935
|
+
info "#{bold('The command for opening a Rails console has changed. Run this instead:')}\n\n"
|
936
|
+
info " k exec -it deploy/#{deployment} -- rails c\n\n"
|
937
|
+
print_k8s_setup_info
|
877
938
|
end,
|
878
939
|
|
879
|
-
"app-dbconsole" => proc do |target,
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
940
|
+
"app-dbconsole" => proc do |target, _environment, _args, _extra_args, _options|
|
941
|
+
target ||= "<app-name>"
|
942
|
+
deployment = target_name_to_k8s_deployment(target)
|
943
|
+
info "#{bold('The command for opening a Rails dbconsole has changed. Run this instead:')}\n\n"
|
944
|
+
info " k exec -it deploy/#{deployment} -- rails db\n\n"
|
945
|
+
print_k8s_setup_info
|
884
946
|
end,
|
885
947
|
|
886
948
|
"rabbitmq" => proc do |target, environment, args, extra_args, _options|
|
@@ -906,6 +968,25 @@ class GovukConnect::CLI
|
|
906
968
|
)
|
907
969
|
end,
|
908
970
|
|
971
|
+
"amazonmq" => proc do |target, environment, args, extra_args, _options|
|
972
|
+
check_for_additional_arguments("amazonmq", args)
|
973
|
+
check_for_additional_arguments("amazonmq", extra_args)
|
974
|
+
|
975
|
+
target ||= "publishingmq.#{environment}.govuk-internal.digital"
|
976
|
+
|
977
|
+
info "You'll need to login as the RabbitMQ #{bold('root')} user."
|
978
|
+
info "Get the password from govuk-aws-data, for example:\n\n"
|
979
|
+
info " # from the root directory of govuk-aws-data repository\n\n"
|
980
|
+
info " #{bold(amazonmq_root_password_command(environment))}"
|
981
|
+
print_empty_line
|
982
|
+
|
983
|
+
remote_port_forward(
|
984
|
+
target,
|
985
|
+
environment,
|
986
|
+
AMAZONMQ_PORT,
|
987
|
+
)
|
988
|
+
end,
|
989
|
+
|
909
990
|
"ssh" => proc do |target, environment, args, extra_args, options|
|
910
991
|
check_for_target(target)
|
911
992
|
target = target_from_options(target, options)
|
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.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Government Digital Service
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-26 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: 4.
|
61
|
+
version: 4.10.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: 4.
|
68
|
+
version: 4.10.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
|
@@ -90,14 +90,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
90
|
requirements:
|
91
91
|
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: '
|
93
|
+
version: '3.0'
|
94
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
96
|
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
100
|
+
rubygems_version: 3.4.13
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: govuk-connect command line tool
|