govuk-connect 0.4.0 → 0.5.0

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: '096b7cb049b267a72e935948281996415e3ae278b852aa3c6f1b3ae40f7b741e'
4
- data.tar.gz: a95b78383bfdc129292cf361e4786da5a4cb8f1092131a4fa9a28c49413bc3d5
3
+ metadata.gz: 71cb0967c5cf0450aa63b5abbf25ce9d964d7ddfcb97a57fea0c011f59961624
4
+ data.tar.gz: ee788418b7e3e127bc4f5bd8ceb7cf35b37a9df889a4200f20fa392b37701882
5
5
  SHA512:
6
- metadata.gz: eef49fdd9c99d481f605f499e417a18b996d17e4a8a46fb2cba820bd26a5329c2bc2d1f2657e4bf6a14754c9c5e6e63ec6e6a54b92f86a7aca71ec09f6752621
7
- data.tar.gz: c81efd962e1e7075dc89ee2626f0dd2a0165503cc4d5753e1d897428965b36bdff9c514869c2f4f7323ffd6df4a0f00b0a0a73f99ce04cf520380d3f5b928b88
6
+ metadata.gz: 9d684a2ef79be515cdb3c1f71abb8dc5ce34fe7ca4315d2e62403a583a8e220e03cfc7c5ef1980211a741e1ca7603b0063d20d35b4974eec378ecd26e67af242
7
+ data.tar.gz: d811b9e5403750cc048e78d8c440bddb0bf206690301b22a7d76f2ab306a2967078f0932d785f757366bd977a45d0befc01c2a6f4202edce79d41d0386d1df18
@@ -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,19 +73,14 @@ 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
  },
@@ -96,7 +88,6 @@ class GovukConnect::CLI
96
88
  aws: "jumpbox.staging.govuk.digital",
97
89
  },
98
90
  production: {
99
- carrenza: "jumpbox.publishing.service.gov.uk",
100
91
  aws: "jumpbox.production.govuk.digital",
101
92
  },
102
93
  }.freeze
@@ -263,29 +254,7 @@ class GovukConnect::CLI
263
254
 
264
255
  def govuk_node_list_classes(environment, hosting)
265
256
  log "debug: looking up classes in #{hosting}/#{environment}"
266
- command = [
267
- "ssh",
268
- "-o",
269
- "ConnectTimeout=2", # Show a failure quickly
270
- *ssh_identity_arguments,
271
- user_at_host(
272
- ssh_username,
273
- jumpbox_for_environment_and_hosting(environment, hosting),
274
- ),
275
- "govuk_node_list --classes",
276
- ].join(" ")
277
-
278
- log "debug: running command: #{command}"
279
- output, status = Open3.capture2(command)
280
-
281
- unless status.success?
282
- error "\nerror: command failed: #{command}"
283
- print_empty_line
284
- print_ssh_username_configuration_help
285
- exit 1
286
- end
287
-
288
- classes = output.split("\n").sort
257
+ classes = ssh_capture("govuk_node_list --classes").sort
289
258
 
290
259
  log "debug: classes:"
291
260
  classes.each { |c| log " - #{c}" }
@@ -293,7 +262,16 @@ class GovukConnect::CLI
293
262
  classes
294
263
  end
295
264
 
296
- 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)
297
275
  command = [
298
276
  "ssh",
299
277
  "-o",
@@ -303,23 +281,20 @@ class GovukConnect::CLI
303
281
  ssh_username,
304
282
  jumpbox_for_environment_and_hosting(environment, hosting),
305
283
  ),
306
- "govuk_node_list -c #{target}",
284
+ remote_command,
307
285
  ].join(" ")
308
286
 
287
+ log "debug: running command: #{command}"
309
288
  output, status = Open3.capture2(command)
310
289
 
311
290
  unless status.success?
312
- error "error: command failed: #{command}"
291
+ error "\nerror: command failed: #{command}"
313
292
  print_empty_line
314
293
  print_ssh_username_configuration_help
315
294
  exit 1
316
295
  end
317
296
 
318
- if hosting == :aws
319
- output.split("\n")
320
- else
321
- output.split("\n").sort
322
- end
297
+ output.split("\n")
323
298
  end
324
299
 
325
300
  def govuk_directory
@@ -333,7 +308,6 @@ class GovukConnect::CLI
333
308
  govuk_directory,
334
309
  "govuk-puppet",
335
310
  {
336
- carrenza: "hieradata",
337
311
  aws: "hieradata_aws",
338
312
  }[hosting],
339
313
  )
@@ -439,29 +413,13 @@ class GovukConnect::CLI
439
413
  return hosting if hosting
440
414
 
441
415
  aws_node_types = govuk_node_list_classes(environment, :aws)
442
- carrenza_node_types = govuk_node_list_classes(environment, :carrenza)
443
416
 
444
- if aws_node_types.include?(node_type) &&
445
- carrenza_node_types.include?(node_type)
446
-
447
- error "error: ambiguous hosting for #{node_type} in #{environment}"
448
- print_empty_line
449
- info "specify the hosting provider and node type, for example: "
450
- hosting_providers.each do |hosting_provider|
451
- info "\n gds govuk connect ssh #{bold(hosting_provider)}/#{node_type}"
452
- end
453
- info "\n"
454
-
455
- exit 1
456
- elsif aws_node_types.include?(node_type)
417
+ if aws_node_types.include?(node_type)
457
418
  :aws
458
- elsif carrenza_node_types.include?(node_type)
459
- :carrenza
460
419
  else
461
420
  error "error: couldn't find #{node_type} in #{environment}"
462
421
 
463
- all_node_types = (aws_node_types + carrenza_node_types).uniq.sort
464
- similar_node_types = strings_similar_to(node_type, all_node_types)
422
+ similar_node_types = strings_similar_to(node_type, aws_node_types)
465
423
 
466
424
  if similar_node_types.any?
467
425
  info "\ndid you mean:"
@@ -496,17 +454,6 @@ class GovukConnect::CLI
496
454
  return :aws
497
455
  end
498
456
 
499
- carrenza_app_names = application_names_from_node_class_data(
500
- environment,
501
- :carrenza,
502
- )
503
-
504
- if carrenza_app_names.include? app_name
505
- log "debug: #{app_name} is hosted in Carrenza"
506
-
507
- return :carrenza
508
- end
509
-
510
457
  error "error: unknown hosting value '#{hosting}' for #{app_name}"
511
458
  exit 1
512
459
  end
@@ -653,7 +600,6 @@ class GovukConnect::CLI
653
600
  def rabbitmq_root_password_command(hosting, environment)
654
601
  hieradata_directory = {
655
602
  aws: "puppet_aws",
656
- carrenza: "puppet",
657
603
  }[hosting]
658
604
 
659
605
  directory = File.join(
@@ -669,14 +615,11 @@ class GovukConnect::CLI
669
615
  uri = URI(url)
670
616
 
671
617
  host_to_hosting_and_environment = {
672
- "ci-alert.integration.publishing.service.gov.uk" => %i[carrenza ci],
673
618
  "alert.integration.publishing.service.gov.uk" => %i[aws integration],
674
619
  "alert.staging.govuk.digital" => %i[aws staging],
675
620
  "alert.blue.staging.govuk.digital" => %i[aws staging],
676
- "alert.staging.publishing.service.gov.uk" => %i[carrenza staging],
677
621
  "alert.production.govuk.digital" => %i[aws production],
678
622
  "alert.blue.production.govuk.digital" => %i[aws production],
679
- "alert.publishing.service.gov.uk" => %i[carrenza production],
680
623
  }
681
624
 
682
625
  unless host_to_hosting_and_environment.key? uri.host
@@ -758,7 +701,7 @@ class GovukConnect::CLI
758
701
 
759
702
  hosting = hosting.to_sym
760
703
 
761
- unless %i[carrenza aws].include? hosting
704
+ unless %i[aws].include? hosting
762
705
  error "error: unknown hosting provider: #{hosting}"
763
706
  print_empty_line
764
707
  info "available hosting providers are:"
@@ -835,9 +778,6 @@ class GovukConnect::CLI
835
778
  if name.end_with? ".internal"
836
779
  target = name
837
780
  hosting = :aws
838
- elsif name.end_with? ".gov.uk"
839
- target = name
840
- hosting = :carrenza
841
781
  else
842
782
  # The hosting might not have been provided, so check if necessary
843
783
  hosting ||= hosting_for_target_and_environment(target, environment)
@@ -846,7 +786,6 @@ class GovukConnect::CLI
846
786
  name,
847
787
  environment,
848
788
  hosting,
849
- ssh_username,
850
789
  )
851
790
 
852
791
  if domains.length.zero?
@@ -954,16 +893,6 @@ class GovukConnect::CLI
954
893
  )
955
894
  end,
956
895
 
957
- "sidekiq-monitoring" => proc do |target, environment, args, extra_args, _options|
958
- check_for_additional_arguments("sidekiq-monitoring", args)
959
- check_for_additional_arguments("sidekiq-monitoring", extra_args)
960
- ssh(
961
- target || "backend",
962
- environment,
963
- port_forward: SIDEKIQ_MONITORING_PORT,
964
- )
965
- end,
966
-
967
896
  "ssh" => proc do |target, environment, args, extra_args, options|
968
897
  check_for_target(target)
969
898
  target = target_from_options(target, options)
@@ -1,3 +1,3 @@
1
1
  module GovukConnect
2
- VERSION = "0.4.0".freeze
2
+ VERSION = "0.5.0".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.4.0
4
+ version: 0.5.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-09-15 00:00:00.000000000 Z
11
+ date: 2021-04-07 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.0.3
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: []