govuk-connect 0.5.0 → 0.6.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: 71cb0967c5cf0450aa63b5abbf25ce9d964d7ddfcb97a57fea0c011f59961624
4
- data.tar.gz: ee788418b7e3e127bc4f5bd8ceb7cf35b37a9df889a4200f20fa392b37701882
3
+ metadata.gz: 40b05abfbca40a3b8f8729a78372915eec32ab961f6f6906b46239929dbf3425
4
+ data.tar.gz: 17210ea67f872030a904f674a24635f9d39f4077386e779755b5674f737623fa
5
5
  SHA512:
6
- metadata.gz: 9d684a2ef79be515cdb3c1f71abb8dc5ce34fe7ca4315d2e62403a583a8e220e03cfc7c5ef1980211a741e1ca7603b0063d20d35b4974eec378ecd26e67af242
7
- data.tar.gz: d811b9e5403750cc048e78d8c440bddb0bf206690301b22a7d76f2ab306a2967078f0932d785f757366bd977a45d0befc01c2a6f4202edce79d41d0386d1df18
6
+ metadata.gz: 91c2408222918dc7557b326a612c580027a8b2e81d375c5d35af2dca875557ae882078df1e743874118f5b3feff6671d50b0009f55d0e30a6bbf4d55aedd398b
7
+ data.tar.gz: d205e9baf15907debb7be37205fc58d1a8322d82379dad5be5c8e931351f2a9ec51e525f2b7783e243afed6af62d4d9a1633dc71503ee2f77496b052ab0bde5f
@@ -227,7 +227,7 @@ class GovukConnect::CLI
227
227
  def ssh_username
228
228
  @ssh_username ||= begin
229
229
  if File.exist? config_file
230
- config_ssh_username = YAML.load_file(config_file)["ssh_username"]
230
+ config_ssh_username = load_yaml(config_file)["ssh_username"]
231
231
  end
232
232
 
233
233
  config_ssh_username || ENV["USER"]
@@ -235,9 +235,7 @@ class GovukConnect::CLI
235
235
  end
236
236
 
237
237
  def ssh_identity_file
238
- @ssh_identity_file ||= begin
239
- YAML.load_file(config_file)["ssh_identity_file"] if File.exist? config_file
240
- end
238
+ @ssh_identity_file ||= (load_yaml(config_file)["ssh_identity_file"] if File.exist? config_file)
241
239
  end
242
240
 
243
241
  def ssh_identity_arguments
@@ -254,7 +252,7 @@ class GovukConnect::CLI
254
252
 
255
253
  def govuk_node_list_classes(environment, hosting)
256
254
  log "debug: looking up classes in #{hosting}/#{environment}"
257
- classes = ssh_capture("govuk_node_list --classes").sort
255
+ classes = ssh_capture(environment, hosting, "govuk_node_list --classes").sort
258
256
 
259
257
  log "debug: classes:"
260
258
  classes.each { |c| log " - #{c}" }
@@ -315,12 +313,12 @@ class GovukConnect::CLI
315
313
  hieradata_file = File.join(local_hieradata_root, "#{environment}.yaml")
316
314
  log "debug: reading #{hieradata_file}"
317
315
 
318
- environment_specific_hieradata = YAML.load_file(hieradata_file)
316
+ environment_specific_hieradata = load_yaml(hieradata_file)
319
317
 
320
318
  if environment_specific_hieradata["node_class"]
321
319
  environment_specific_hieradata["node_class"]
322
320
  else
323
- common_hieradata = YAML.load_file(
321
+ common_hieradata = load_yaml(
324
322
  File.join(local_hieradata_root, "common.yaml"),
325
323
  )
326
324
 
@@ -328,6 +326,21 @@ class GovukConnect::CLI
328
326
  end
329
327
  end
330
328
 
329
+ def load_yaml(file_path)
330
+ # Psych (the gem that provides YAML parsing) introduced a new method,
331
+ # safe_load_file, in version 3.3 (which shipped with Ruby 3.0) and in
332
+ # version 4 (shipped with Ruby 3.1) the API for load_file changed and will
333
+ # error with GOV.UK hieradata.
334
+ #
335
+ # Once this gem no longer supports Ruby 2.x (or pins to a version of Psych)
336
+ # we can remove this conditional and use YAML.safe_load_file only
337
+ if YAML.respond_to?(:safe_load_file)
338
+ YAML.safe_load_file(file_path, aliases: true)
339
+ else
340
+ YAML.load_file(file_path)
341
+ end
342
+ end
343
+
331
344
  def node_classes_for_environment_and_hosting(environment, hosting)
332
345
  govuk_puppet_node_class_data(
333
346
  environment,
@@ -664,7 +677,7 @@ class GovukConnect::CLI
664
677
  info EXAMPLES
665
678
  print_empty_line
666
679
  info bold("CONNECTION TYPES")
667
- types.keys.each do |x|
680
+ types.each_key do |x|
668
681
  info " #{x}"
669
682
  description = CONNECTION_TYPE_DESCRIPTIONS[x]
670
683
  info " #{description}" if description
@@ -741,7 +754,7 @@ class GovukConnect::CLI
741
754
  end
742
755
 
743
756
  if app_name_and_number.include? ":"
744
- app_name, number = name_and_number.split ":"
757
+ app_name, number = app_name_and_number.split ":"
745
758
 
746
759
  number = number.to_i
747
760
  else
@@ -966,7 +979,7 @@ class GovukConnect::CLI
966
979
  warn @option_parser.help
967
980
 
968
981
  warn "\nValid connection types are:\n"
969
- types.keys.each do |x|
982
+ types.each_key do |x|
970
983
  warn " - #{x}"
971
984
  end
972
985
  print_empty_line
@@ -982,7 +995,7 @@ class GovukConnect::CLI
982
995
  error "error: unknown connection type: #{type}\n"
983
996
 
984
997
  warn "Valid connection types are:\n"
985
- types.keys.each do |x|
998
+ types.each_key do |x|
986
999
  warn " - #{x}"
987
1000
  end
988
1001
  print_empty_line
@@ -1004,7 +1017,7 @@ class GovukConnect::CLI
1004
1017
  error "error: unknown environment '#{environment}'"
1005
1018
  print_empty_line
1006
1019
  info "Valid environments are:"
1007
- JUMPBOXES.keys.each { |e| info " - #{e}" }
1020
+ JUMPBOXES.each_key { |e| info " - #{e}" }
1008
1021
  exit 1
1009
1022
  end
1010
1023
 
@@ -1,3 +1,3 @@
1
1
  module GovukConnect
2
- VERSION = "0.5.0".freeze
2
+ VERSION = "0.6.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.5.0
4
+ version: 0.6.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: 2021-04-07 00:00:00.000000000 Z
11
+ date: 2022-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rubocop-govuk
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 3.17.0
61
+ version: 4.3.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.17.0
68
+ version: 4.3.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: '2.5'
93
+ version: '2.6'
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.0.3.1
100
+ rubygems_version: 3.3.7
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: govuk-connect command line tool