govuk-connect 0.3.3 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a1b3a80c3eec55973d5a21f131f0a12d836578d702488f9eed8cf20acf1042d
4
- data.tar.gz: d91a53b4f152ba3609e71b4e4bdbe0918bb8090443b950ddefd3811dc19cbe6d
3
+ metadata.gz: 96fcd456119377e987a030728e2a35d21ae6fb97200de1337df929822d9b56a5
4
+ data.tar.gz: 9e16ea46cb21a8226495da7d85025bfb30958f5a0be07c5e9ea4ee25ff48659d
5
5
  SHA512:
6
- metadata.gz: ff8f442e71c562b001119fb5c5eb92958d3e1b2a1da7dd31f9ca2d6483e693a62ca383797ced30d2130662ef1ce94a8aa3c5d6e890124066bbc914edfdcef52e
7
- data.tar.gz: fa0ecc08631861e15aa2cfd6dacb3299e1783df665b2e3e4b0b9eec9c45019819fbb40c7e9a491fc66bf03a72b44da1bb88428efebadbe5955f58676e2cbd69c
6
+ metadata.gz: 3aa7936fca2f9749fffbc1464707a0b5102504d656d49d0f10ad9dafc226700831fcc74e78d72cc01cae6ddfe520e2f087cfed86e25b968458fbe5ed92986fcf
7
+ data.tar.gz: a041ef55618929e10456cda3e8fd59bc15fb3f2910fc0074885cdeeabe894cce7835f4a438a3d5e618aa33d6a0eeadc92e1aade12694ab8a52b7a85a5667b3ec
@@ -29,13 +29,10 @@ class GovukConnect::CLI
29
29
  gds govuk connect app-dbconsole -e integration whitehall_backend/whitehall
30
30
 
31
31
  gds govuk connect rabbitmq -e staging aws/rabbitmq
32
-
33
- gds govuk connect sidekiq-monitoring -e integration
34
32
  EXAMPLES
35
33
 
36
34
  MACHINE_TARGET_DESCRIPTION = <<-DOCS.freeze
37
- The ssh, scp-*, rabbitmq and sidekiq-monitoring connection types target
38
- machines.
35
+ The ssh, scp-*, rabbitmq connection types target machines.
39
36
 
40
37
  The machine can be specified by name, for example:
41
38
 
@@ -76,28 +73,21 @@ class GovukConnect::CLI
76
73
  "app-console" => "Launch a console for an application. For example, a rails console when connecting to a Rails application.",
77
74
  "app-dbconsole" => "Launch a console for the database for an application.",
78
75
  "rabbitmq" => "Setup port forwarding to the RabbitMQ admin interface.",
79
- "sidekiq-monitoring" => "Setup port forwarding to the Sidekiq Monitoring application.",
80
76
  }.freeze
81
77
 
82
78
  RABBITMQ_PORT = 15_672
83
- SIDEKIQ_MONITORING_PORT = 3211
84
79
 
85
80
  JUMPBOXES = {
86
81
  test: {
87
82
  aws: "jumpbox.pink.test.govuk.digital",
88
83
  },
89
- ci: {
90
- carrenza: "ci-jumpbox.integration.publishing.service.gov.uk",
91
- },
92
84
  integration: {
93
85
  aws: "jumpbox.integration.publishing.service.gov.uk",
94
86
  },
95
87
  staging: {
96
- carrenza: "jumpbox.staging.publishing.service.gov.uk",
97
88
  aws: "jumpbox.staging.govuk.digital",
98
89
  },
99
90
  production: {
100
- carrenza: "jumpbox.publishing.service.gov.uk",
101
91
  aws: "jumpbox.production.govuk.digital",
102
92
  },
103
93
  }.freeze
@@ -264,29 +254,7 @@ class GovukConnect::CLI
264
254
 
265
255
  def govuk_node_list_classes(environment, hosting)
266
256
  log "debug: looking up classes in #{hosting}/#{environment}"
267
- command = [
268
- "ssh",
269
- "-o",
270
- "ConnectTimeout=2", # Show a failure quickly
271
- *ssh_identity_arguments,
272
- user_at_host(
273
- ssh_username,
274
- jumpbox_for_environment_and_hosting(environment, hosting),
275
- ),
276
- "govuk_node_list --classes",
277
- ].join(" ")
278
-
279
- log "debug: running command: #{command}"
280
- output, status = Open3.capture2(command)
281
-
282
- unless status.success?
283
- error "\nerror: command failed: #{command}"
284
- print_empty_line
285
- print_ssh_username_configuration_help
286
- exit 1
287
- end
288
-
289
- classes = output.split("\n").sort
257
+ classes = ssh_capture(environment, hosting, "govuk_node_list --classes").sort
290
258
 
291
259
  log "debug: classes:"
292
260
  classes.each { |c| log " - #{c}" }
@@ -294,7 +262,16 @@ class GovukConnect::CLI
294
262
  classes
295
263
  end
296
264
 
297
- def get_domains_for_node_class(target, environment, hosting, ssh_username)
265
+ def get_domains_for_node_class(target, environment, hosting)
266
+ domains = ssh_capture(environment, hosting, "govuk_node_list -c #{target}")
267
+ if hosting == :aws
268
+ domains
269
+ else
270
+ domains.sort
271
+ end
272
+ end
273
+
274
+ def ssh_capture(environment, hosting, remote_command)
298
275
  command = [
299
276
  "ssh",
300
277
  "-o",
@@ -304,23 +281,20 @@ class GovukConnect::CLI
304
281
  ssh_username,
305
282
  jumpbox_for_environment_and_hosting(environment, hosting),
306
283
  ),
307
- "govuk_node_list -c #{target}",
284
+ remote_command,
308
285
  ].join(" ")
309
286
 
287
+ log "debug: running command: #{command}"
310
288
  output, status = Open3.capture2(command)
311
289
 
312
290
  unless status.success?
313
- error "error: command failed: #{command}"
291
+ error "\nerror: command failed: #{command}"
314
292
  print_empty_line
315
293
  print_ssh_username_configuration_help
316
294
  exit 1
317
295
  end
318
296
 
319
- if hosting == :aws
320
- output.split("\n")
321
- else
322
- output.split("\n").sort
323
- end
297
+ output.split("\n")
324
298
  end
325
299
 
326
300
  def govuk_directory
@@ -334,7 +308,6 @@ class GovukConnect::CLI
334
308
  govuk_directory,
335
309
  "govuk-puppet",
336
310
  {
337
- carrenza: "hieradata",
338
311
  aws: "hieradata_aws",
339
312
  }[hosting],
340
313
  )
@@ -440,29 +413,13 @@ class GovukConnect::CLI
440
413
  return hosting if hosting
441
414
 
442
415
  aws_node_types = govuk_node_list_classes(environment, :aws)
443
- carrenza_node_types = govuk_node_list_classes(environment, :carrenza)
444
416
 
445
- if aws_node_types.include?(node_type) &&
446
- carrenza_node_types.include?(node_type)
447
-
448
- error "error: ambiguous hosting for #{node_type} in #{environment}"
449
- print_empty_line
450
- info "specify the hosting provider and node type, for example: "
451
- hosting_providers.each do |hosting_provider|
452
- info "\n gds govuk connect ssh #{bold(hosting_provider)}/#{node_type}"
453
- end
454
- info "\n"
455
-
456
- exit 1
457
- elsif aws_node_types.include?(node_type)
417
+ if aws_node_types.include?(node_type)
458
418
  :aws
459
- elsif carrenza_node_types.include?(node_type)
460
- :carrenza
461
419
  else
462
420
  error "error: couldn't find #{node_type} in #{environment}"
463
421
 
464
- all_node_types = (aws_node_types + carrenza_node_types).uniq.sort
465
- similar_node_types = strings_similar_to(node_type, all_node_types)
422
+ similar_node_types = strings_similar_to(node_type, aws_node_types)
466
423
 
467
424
  if similar_node_types.any?
468
425
  info "\ndid you mean:"
@@ -497,17 +454,6 @@ class GovukConnect::CLI
497
454
  return :aws
498
455
  end
499
456
 
500
- carrenza_app_names = application_names_from_node_class_data(
501
- environment,
502
- :carrenza,
503
- )
504
-
505
- if carrenza_app_names.include? app_name
506
- log "debug: #{app_name} is hosted in Carrenza"
507
-
508
- return :carrenza
509
- end
510
-
511
457
  error "error: unknown hosting value '#{hosting}' for #{app_name}"
512
458
  exit 1
513
459
  end
@@ -654,7 +600,6 @@ class GovukConnect::CLI
654
600
  def rabbitmq_root_password_command(hosting, environment)
655
601
  hieradata_directory = {
656
602
  aws: "puppet_aws",
657
- carrenza: "puppet",
658
603
  }[hosting]
659
604
 
660
605
  directory = File.join(
@@ -670,14 +615,11 @@ class GovukConnect::CLI
670
615
  uri = URI(url)
671
616
 
672
617
  host_to_hosting_and_environment = {
673
- "ci-alert.integration.publishing.service.gov.uk" => %i[carrenza ci],
674
618
  "alert.integration.publishing.service.gov.uk" => %i[aws integration],
675
619
  "alert.staging.govuk.digital" => %i[aws staging],
676
620
  "alert.blue.staging.govuk.digital" => %i[aws staging],
677
- "alert.staging.publishing.service.gov.uk" => %i[carrenza staging],
678
621
  "alert.production.govuk.digital" => %i[aws production],
679
622
  "alert.blue.production.govuk.digital" => %i[aws production],
680
- "alert.publishing.service.gov.uk" => %i[carrenza production],
681
623
  }
682
624
 
683
625
  unless host_to_hosting_and_environment.key? uri.host
@@ -759,7 +701,7 @@ class GovukConnect::CLI
759
701
 
760
702
  hosting = hosting.to_sym
761
703
 
762
- unless %i[carrenza aws].include? hosting
704
+ unless %i[aws].include? hosting
763
705
  error "error: unknown hosting provider: #{hosting}"
764
706
  print_empty_line
765
707
  info "available hosting providers are:"
@@ -799,7 +741,7 @@ class GovukConnect::CLI
799
741
  end
800
742
 
801
743
  if app_name_and_number.include? ":"
802
- app_name, number = name_and_number.split ":"
744
+ app_name, number = app_name_and_number.split ":"
803
745
 
804
746
  number = number.to_i
805
747
  else
@@ -836,9 +778,6 @@ class GovukConnect::CLI
836
778
  if name.end_with? ".internal"
837
779
  target = name
838
780
  hosting = :aws
839
- elsif name.end_with? ".gov.uk"
840
- target = name
841
- hosting = :carrenza
842
781
  else
843
782
  # The hosting might not have been provided, so check if necessary
844
783
  hosting ||= hosting_for_target_and_environment(target, environment)
@@ -847,7 +786,6 @@ class GovukConnect::CLI
847
786
  name,
848
787
  environment,
849
788
  hosting,
850
- ssh_username,
851
789
  )
852
790
 
853
791
  if domains.length.zero?
@@ -955,16 +893,6 @@ class GovukConnect::CLI
955
893
  )
956
894
  end,
957
895
 
958
- "sidekiq-monitoring" => proc do |target, environment, args, extra_args, _options|
959
- check_for_additional_arguments("sidekiq-monitoring", args)
960
- check_for_additional_arguments("sidekiq-monitoring", extra_args)
961
- ssh(
962
- target || "backend",
963
- environment,
964
- port_forward: SIDEKIQ_MONITORING_PORT,
965
- )
966
- end,
967
-
968
896
  "ssh" => proc do |target, environment, args, extra_args, options|
969
897
  check_for_target(target)
970
898
  target = target_from_options(target, options)
@@ -1,3 +1,3 @@
1
1
  module GovukConnect
2
- VERSION = "0.3.3".freeze
2
+ VERSION = "0.5.2".freeze
3
3
  end
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.3.3
4
+ version: 0.5.2
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-09-10 00:00:00.000000000 Z
11
+ date: 2021-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control
@@ -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
@@ -97,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
- rubygems_version: 3.1.2
101
- signing_key:
100
+ rubygems_version: 3.0.3.1
101
+ signing_key:
102
102
  specification_version: 4
103
103
  summary: govuk-connect command line tool
104
104
  test_files: []