knife-ec2 1.0.7 → 1.0.8

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: 37c08a54649fd441e8a497e268d512da71aa52c1b868196cd672297cb3535685
4
- data.tar.gz: 92b071136caf3bd82c6c47ed4970a815a6e3590de358d737234c3d7067cadbf2
3
+ metadata.gz: 10d2009ca1b8decd1be69f2c0ba04eb3316010c6d99c0a6ed88a2018c0c5bd1b
4
+ data.tar.gz: 610d660db9b532dd282d135e1885324ed6ec44a6c458d6d403af11479195c19a
5
5
  SHA512:
6
- metadata.gz: 493bae78b6be752198bff0d1b6f9a6001f1f9be4fbfecf67d04e05a54351f9fdeadae50fa17db0e941cce63a0737d52897b912c793b9a2cacedeba0386238fbc
7
- data.tar.gz: 6dbdbfc483c9a7b870d0c472de48ad460913f3e90eedbedb30a04f4f14998d9eb8a308ab102cc666f2849ff7ff2f209fe4c7f86469a7a4fd0d8bf8322ba04c4a
6
+ metadata.gz: e8adadfcba613c816fdf61badf3877f0e618f8db713400ff569b5bb9328af695d2821cdd42fcf18b2aaf395b271361d739983777353bb375211536e06a32e032
7
+ data.tar.gz: 5ad31dc527d678d6cb71cc23326bb1003aeef22645a56b33751905e29c725e12d21d3750a2060ef287a237d62299ef1543f8e5aea71aee75505984f4823c9024
@@ -43,12 +43,14 @@ class Chef
43
43
  option :platform,
44
44
  short: "-p PLATFORM",
45
45
  long: "--platform PLATFORM",
46
- description: "Platform of the server. Allowed values are windows, ubuntu, debian, centos, fedora, rhel, nginx, turnkey, jumpbox, coreos, cisco, amazon, nessus"
47
-
46
+ description: "Platform of the server",
47
+ in: Chef::Knife::Ec2Base::VALID_PLATFORMS
48
48
  option :owner,
49
49
  short: "-o OWNER",
50
50
  long: "--owner OWNER",
51
- description: "The AMI owner (self, aws-marketplace, microsoft). Default is aws-marketplace"
51
+ description: "The AMI owner. Default is aws-marketplace",
52
+ default: "aws-marketplace",
53
+ in: %w{self aws-marketplace microsoft}
52
54
 
53
55
  option :search,
54
56
  short: "-s SEARCH",
@@ -67,7 +69,7 @@ class Chef
67
69
  ui.color("Architecture", :bold),
68
70
  ui.color("Size", :bold),
69
71
  ui.color("Name", :bold),
70
- ui.color("Description", :bold)
72
+ ui.color("Description", :bold),
71
73
  ].flatten.compact
72
74
 
73
75
  output_column_count = servers_list.length
@@ -110,8 +112,7 @@ class Chef
110
112
 
111
113
  def image_params
112
114
  params = {}
113
- owner = locate_config_value(:owner) || "aws-marketplace" # aws-marketplace, microsoft
114
- params["owners"] = [owner.to_s]
115
+ params["owners"] = [locate_config_value(:owner).to_s]
115
116
 
116
117
  filters = []
117
118
  filters << { platform: locate_config_value(:platform) } if locate_config_value(:platform)
@@ -21,6 +21,8 @@ require "chef/knife"
21
21
  class Chef
22
22
  class Knife
23
23
  module Ec2Base
24
+ # All valid platforms
25
+ VALID_PLATFORMS ||= %w{windows ubuntu debian centos fedora rhel nginx turnkey jumpbox coreos cisco amazon nessus}.freeze
24
26
 
25
27
  # @todo Would prefer to do this in a rational way, but can't be done b/c of Mixlib::CLI's design :(
26
28
  def self.included(includer)
@@ -98,7 +100,8 @@ class Chef
98
100
  end
99
101
 
100
102
  def fetch_ami(image_id)
101
- return {} unless image_id
103
+ return nil unless image_id
104
+
102
105
  ec2_connection.describe_images({
103
106
  image_ids: [image_id],
104
107
  }).images.first
@@ -144,15 +147,15 @@ class Chef
144
147
  end
145
148
 
146
149
  server_data["availability_zone"] = server_obj.instances[0].placement.availability_zone
147
- server_data["groups"] = server_obj.groups.map { |grp| grp.name }
148
- server_data["iam_instance_profile"] = ( server_obj.instances[0].iam_instance_profile.nil? ? nil : server_obj.instances[0].iam_instance_profile.arn[/instance-profile\/(.*)/] )
150
+ server_data["groups"] = server_obj.groups.map(&:name)
151
+ server_data["iam_instance_profile"] = ( server_obj.instances[0].iam_instance_profile.nil? ? nil : server_obj.instances[0].iam_instance_profile.arn[%r{instance-profile/(.*)}] )
149
152
  server_data["id"] = server_data["instance_id"]
150
153
 
151
- tags = server_obj.instances[0].tags.map { |x| x.value }
154
+ tags = server_obj.instances[0].tags.map(&:value)
152
155
  server_data["name"] = tags[0]
153
156
  server_data["placement_group"] = server_obj.instances[0].placement.group_name
154
- server_data["security_groups"] = server_obj.instances[0].security_groups.map { |x| x.group_name }
155
- server_data["security_group_ids"] = server_obj.instances[0].security_groups.map { |x| x.group_id }
157
+ server_data["security_groups"] = server_obj.instances[0].security_groups.map(&:group_name)
158
+ server_data["security_group_ids"] = server_obj.instances[0].security_groups.map(&:group_id)
156
159
  server_data["state"] = server_obj.instances[0].state.name
157
160
  server_data["subnet_id"] = server_obj.instances[0].network_interfaces[0].subnet_id
158
161
  server_data["tags"] = tags
@@ -164,7 +167,7 @@ class Chef
164
167
 
165
168
  # @return [Struct]
166
169
  def normalize_server_data(server_hashes)
167
- require "ostruct"
170
+ require "ostruct" unless defined?(OpenStruct)
168
171
  OpenStruct.new(server_hashes)
169
172
  end
170
173
 
@@ -191,12 +194,12 @@ class Chef
191
194
  # Platform value return for Windows AMIs; otherwise, it is blank.
192
195
  # @return [Boolean]
193
196
  def is_image_windows?
194
- ami.platform == "windows"
197
+ ami && ami.platform == "windows"
195
198
  end
196
199
 
197
200
  # validate the config options that were passed since some of them cannot be used together
198
201
  # also validate the aws configuration file contents if present
199
- def validate_aws_config!(keys = [:aws_access_key_id, :aws_secret_access_key])
202
+ def validate_aws_config!(keys = %i{aws_access_key_id aws_secret_access_key})
200
203
  errors = [] # track all errors so we report on all of them
201
204
 
202
205
  validate_aws_config_file! if locate_config_value(:aws_config_file)
@@ -206,10 +209,10 @@ class Chef
206
209
  # aws keys have not been passed in config / CLI and the default cred file location does exist
207
210
  # OR
208
211
  # the user passed aws_credential_file
209
- if (Chef::Config[:knife].keys & [:aws_access_key_id, :aws_secret_access_key]).empty? && aws_cred_file_location ||
212
+ if (Chef::Config[:knife].keys & %i{aws_access_key_id aws_secret_access_key}).empty? && aws_cred_file_location ||
210
213
  locate_config_value(:aws_credential_file)
211
214
 
212
- unless (Chef::Config[:knife].keys & [:aws_access_key_id, :aws_secret_access_key]).empty?
215
+ unless (Chef::Config[:knife].keys & %i{aws_access_key_id aws_secret_access_key}).empty?
213
216
  errors << "Either provide a credentials file or the access key and secret keys but not both."
214
217
  end
215
218
 
@@ -227,20 +230,7 @@ class Chef
227
230
  exit 1
228
231
  end
229
232
  end
230
-
231
- if locate_config_value(:platform)
232
- unless valid_platforms.include? (locate_config_value(:platform))
233
- raise ArgumentError, "Invalid platform: #{locate_config_value(:platform)}. Allowed platforms are: #{valid_platforms.join(", ")}."
234
- end
235
- end
236
-
237
- if locate_config_value(:owner)
238
- unless ["self", "aws-marketplace", "microsoft"].include? (locate_config_value(:owner)) # rubocop:disable Style/WordArray
239
- raise ArgumentError, "Invalid owner: #{locate_config_value(:owner)}. Allowed owners are self, aws-marketplace or microsoft."
240
- end
241
- end
242
233
  end
243
-
244
234
  end
245
235
 
246
236
  # the path to the aws credentials file.
@@ -285,16 +275,10 @@ class Chef
285
275
  map
286
276
  end
287
277
 
288
- # All valid platforms
289
- # @return [Array]
290
- def valid_platforms
291
- %w{windows ubuntu debian centos fedora rhel nginx turnkey jumpbox coreos cisco amazon nessus}
292
- end
293
-
294
278
  # Get the platform from server name
295
279
  # @return [String]
296
280
  def find_server_platform(server_name)
297
- get_platform = valid_platforms.select { |name| server_name.downcase.include?(name) }
281
+ get_platform = VALID_PLATFORMS.select { |name| server_name.downcase.include?(name) }
298
282
  get_platform.first
299
283
  end
300
284
 
@@ -38,7 +38,7 @@ class Chef
38
38
  ui.color("Private IPs", :bold),
39
39
  ui.color("IPv6 IPs", :bold),
40
40
  ui.color("Subnet ID", :bold),
41
- ui.color("VPC ID", :bold)
41
+ ui.color("VPC ID", :bold),
42
42
  ].flatten.compact
43
43
 
44
44
  output_column_count = eni_list.length
@@ -33,7 +33,7 @@ class Chef
33
33
  sg_list = [
34
34
  ui.color("ID", :bold),
35
35
  ui.color("Name", :bold),
36
- ui.color("VPC ID", :bold)
36
+ ui.color("VPC ID", :bold),
37
37
  ].flatten.compact
38
38
 
39
39
  output_column_count = sg_list.length
@@ -61,20 +61,6 @@ class Chef
61
61
  description: "The security groups for this server; not allowed when using VPC",
62
62
  proc: Proc.new { |groups| groups.split(",") }
63
63
 
64
- option :security_group_ids,
65
- long: "--security-group-ids 'X,Y,Z'",
66
- description: "The security group ids for this server; required when using VPC. Provide values in format --security-group-ids 'X,Y,Z'. [DEPRECATED] This option will be removed in future release. Use the new --security-group-id option. ",
67
- proc: Proc.new { |security_group_ids|
68
- ui.warn("[DEPRECATED] This option will be removed in future release. Use the new --security-group-id option multiple times when specifying multiple groups for e.g. -g sg-e985168d -g sg-e7f06383 -g sg-ec1b7e88.")
69
- if security_group_ids.delete(" ").split(",").size > 1
70
- Chef::Config[:knife][:security_group_ids] = security_group_ids.delete(" ").split(",")
71
- else
72
- Chef::Config[:knife][:security_group_ids] ||= []
73
- Chef::Config[:knife][:security_group_ids].push(security_group_ids)
74
- Chef::Config[:knife][:security_group_ids]
75
- end
76
- }
77
-
78
64
  option :security_group_id,
79
65
  short: "-g SECURITY_GROUP_ID",
80
66
  long: "--security-group-id ID",
@@ -102,15 +88,6 @@ class Chef
102
88
  long: "--primary-eni ENI_ID",
103
89
  description: "Specify a pre-existing eni to use when building the instance."
104
90
 
105
- option :tags,
106
- short: "-T T=V[,T=V,...]",
107
- long: "--tags Tag=Value[,Tag=Value...]",
108
- description: "The tags for this server. [DEPRECATED] Use --aws-tag instead.",
109
- proc: Proc.new { |tags|
110
- Chef::Log.warn("[DEPRECATED] --tags option is deprecated. Use --aws-tag option instead.")
111
- tags.split(",")
112
- }
113
-
114
91
  option :availability_zone,
115
92
  short: "-Z ZONE",
116
93
  long: "--availability-zone ZONE",
@@ -270,16 +247,6 @@ class Chef
270
247
  description: "Tag the Root volume",
271
248
  proc: Proc.new { |volume_tags| volume_tags.split(",") }
272
249
 
273
- option :tag_node_in_chef,
274
- long: "--tag-node-in-chef",
275
- description: "Flag for tagging node in ec2 and chef both. [DEPRECATED] Use --chef-tag instead.",
276
- proc: Proc.new { |v|
277
- Chef::Log.warn("[DEPRECATED] --tag-node-in-chef option is deprecated. Use --chef-tag option instead.")
278
- v
279
- },
280
- boolean: true,
281
- default: false
282
-
283
250
  option :instance_initiated_shutdown_behavior,
284
251
  long: "--instance-initiated-shutdown-behavior SHUTDOWN_BEHAVIOR",
285
252
  description: "Indicates whether an instance stops or terminates when you initiate shutdown from the instance. Possible values are 'stop' and 'terminate', default is 'stop'."
@@ -379,6 +346,7 @@ class Chef
379
346
  enable_classic_link(config[:classic_link_vpc_id], config[:classic_link_vpc_security_group_ids]) if config[:classic_link_vpc_id]
380
347
  rescue Aws::EC2::Errors::ServiceError, Aws::EC2::Errors::Error
381
348
  raise if (tries -= 1) <= 0
349
+
382
350
  ui.warn("server not ready, retrying tag application (retries left: #{tries})")
383
351
  sleep 5
384
352
  retry
@@ -462,7 +430,7 @@ class Chef
462
430
  msg_pair("IAM Profile", config_value(:iam_instance_profile)) if config_value(:iam_instance_profile)
463
431
  msg_pair("Primary ENI", config_value(:primary_eni)) if config_value(:primary_eni)
464
432
  msg_pair("AWS Tags", printed_aws_tags)
465
- msg_pair("Chef Tags", config_value(:chef_tag)) if config_value(:chef_tag)
433
+ msg_pair("Chef Tags", config_value(:tags)) if config_value(:tags).any?
466
434
  msg_pair("SSH Key", server.key_name)
467
435
  msg_pair("Root Device Type", server.root_device_type)
468
436
  msg_pair("Root Volume Tags", printed_volume_tags)
@@ -560,6 +528,7 @@ class Chef
560
528
  def s3_secret
561
529
  @s3_secret ||= begin
562
530
  return false unless config_value(:s3_secret)
531
+
563
532
  Chef::Knife::S3Source.fetch(config_value(:s3_secret))
564
533
  end
565
534
  end
@@ -573,12 +542,6 @@ class Chef
573
542
  Chef::Knife::DataBagSecretOptions.set_cl_secret(s3_secret) if config_value(:s3_secret)
574
543
  config[:secret] = s3_secret || config_value(:secret)
575
544
 
576
- # If --chef-tag is provided then it will be set in chef as single value e.g. --chef-tag "myTag"
577
- # Otherwise if --tag-node-in-chef is provided then it will tag the chef in key=value pair of --tags option
578
- # e.g. --tags "key=value"
579
- if config_value(:chef_tag)
580
- config[:tags] = config_value(:chef_tag)
581
- end
582
545
  # Modify global configuration state to ensure hint gets set by
583
546
  # knife-bootstrap
584
547
  Chef::Config[:knife][:hints] ||= {}
@@ -602,12 +565,12 @@ class Chef
602
565
 
603
566
  def plugin_validate_options!
604
567
  if Chef::Config[:knife].keys.include? :aws_ssh_key_id
605
- Chef::Config[:knife][:ssh_key_name] = Chef::Config[:knife][:aws_ssh_key_id] if !Chef::Config[:knife][:ssh_key_name]
568
+ Chef::Config[:knife][:ssh_key_name] = Chef::Config[:knife][:aws_ssh_key_id] unless Chef::Config[:knife][:ssh_key_name]
606
569
  Chef::Config[:knife].delete(:aws_ssh_key_id)
607
570
  ui.warn("Use of aws_ssh_key_id option in knife.rb/config.rb config is deprecated, use ssh_key_name option instead.")
608
571
  end
609
572
 
610
- validate_aws_config!([:image, :ssh_key_name, :aws_access_key_id, :aws_secret_access_key])
573
+ validate_aws_config!(%i{image ssh_key_name aws_access_key_id aws_secret_access_key})
611
574
 
612
575
  validate_nics! if config_value(:network_interfaces)
613
576
 
@@ -725,7 +688,7 @@ class Chef
725
688
  end
726
689
 
727
690
  if config_value(:spot_price).nil? && config_value(:spot_wait_mode)
728
- if !(config_value(:spot_wait_mode).casecmp("prompt") == 0)
691
+ unless config_value(:spot_wait_mode).casecmp("prompt") == 0
729
692
  ui.error("spot-wait-mode option requires that a spot-price option is set.")
730
693
  exit 1
731
694
  end
@@ -749,17 +712,16 @@ class Chef
749
712
  end
750
713
  end
751
714
 
752
- if config_value(:tag_node_in_chef)
753
- ui.warn("[DEPRECATED] --tag-node-in-chef option is deprecated. Use --chef-tag option instead.")
754
- end
755
-
756
- if config_value(:tags)
757
- ui.warn("[DEPRECATED] --tags option is deprecated. Use --aws-tag option instead.")
715
+ if config_value(:chef_tag)
716
+ # If --chef-tag is provided then it will be set in chef as single value e.g. --chef-tag "myTag"
717
+ # --tags has been removed from knife-ec2, now it's available in core
718
+ config[:tags] += config_value(:chef_tag)
719
+ ui.warn("[DEPRECATED] --chef-tag option is deprecated and will be removed in future release. Use --tags TAGS option instead.")
758
720
  end
759
721
  end
760
722
 
761
- def tags
762
- tags = config_value(:tags) || config_value(:aws_tag)
723
+ def parse_aws_tags
724
+ tags = config_value(:aws_tag)
763
725
  if !tags.nil? && (tags.length != tags.to_s.count("="))
764
726
  ui.error("AWS Tags should be entered in a key = value pair")
765
727
  exit 1
@@ -837,7 +799,7 @@ class Chef
837
799
  end
838
800
 
839
801
  def process_user_data(script_lines)
840
- if !ssl_config_data_already_exist?
802
+ unless ssl_config_data_already_exist?
841
803
  ps_start_tag = "<powershell>\n"
842
804
  ps_end_tag = "</powershell>\n"
843
805
  ps_start_tag_index = script_lines.index(ps_start_tag) || script_lines.index(ps_start_tag.strip)
@@ -996,7 +958,7 @@ class Chef
996
958
  attributes[:disable_api_termination] = config_value(:disable_api_termination) if config_value(:spot_price).nil?
997
959
 
998
960
  attributes[:instance_initiated_shutdown_behavior] = config_value(:instance_initiated_shutdown_behavior)
999
- attributes[:chef_tag] = config_value(:chef_tag)
961
+ attributes[:chef_tag] = config_value(:tags)
1000
962
  attributes
1001
963
  end
1002
964
 
@@ -1137,6 +1099,7 @@ class Chef
1137
1099
  # @return [Boolean]
1138
1100
  def subnet_public_ip_on_launch?
1139
1101
  return false unless server.subnet_id
1102
+
1140
1103
  subnet = fetch_subnet(server.subnet_id)
1141
1104
  subnet.map_public_ip_on_launch
1142
1105
  end
@@ -1204,7 +1167,7 @@ class Chef
1204
1167
  return true if invalid_nic_ids.empty?
1205
1168
 
1206
1169
  ui.error "The following network interfaces are invalid: " \
1207
- "#{invalid_nic_ids.join(', ')}"
1170
+ "#{invalid_nic_ids.join(", ")}"
1208
1171
  exit 1
1209
1172
  end
1210
1173
 
@@ -1313,6 +1276,7 @@ class Chef
1313
1276
  sleep 10
1314
1277
  response = fetch_password_data(server_id)
1315
1278
  return false unless response.password_data
1279
+
1316
1280
  true
1317
1281
  end
1318
1282
 
@@ -1345,8 +1309,7 @@ class Chef
1345
1309
 
1346
1310
  # TODO: connection_protocol and connection_port used to choose winrm/ssh or 5985/22 based on the image chosen
1347
1311
  def connection_port
1348
- port = config_value(:connection_port,
1349
- knife_key_for_protocol(connection_protocol, :port))
1312
+ port = config_value(:connection_port, knife_key_for_protocol(connection_protocol, :port))
1350
1313
  return port if port
1351
1314
 
1352
1315
  assign_default_port
@@ -1370,7 +1333,7 @@ class Chef
1370
1333
 
1371
1334
  default_protocol = is_image_windows? ? "winrm" : "ssh"
1372
1335
 
1373
- from_url = host_descriptor =~ /^(.*):\/\// ? $1 : nil
1336
+ from_url = host_descriptor =~ %r{^(.*)://} ? $1 : nil
1374
1337
  from_cli = config[:connection_protocol]
1375
1338
  from_knife = Chef::Config[:knife][:connection_protocol]
1376
1339
  @connection_protocol = from_url || from_cli || from_knife || default_protocol
@@ -1382,6 +1345,7 @@ class Chef
1382
1345
 
1383
1346
  def server_name
1384
1347
  return nil unless server
1348
+
1385
1349
  server.public_dns_name || server.private_dns_name || server.private_ip_address
1386
1350
  end
1387
1351
 
@@ -1421,7 +1385,7 @@ class Chef
1421
1385
 
1422
1386
  def hashed_tags
1423
1387
  ht = {}
1424
- tags.map { |t| key, val = t.split("="); ht[key] = val } unless tags.nil?
1388
+ parse_aws_tags.map { |t| key, val = t.split("="); ht[key] = val } unless parse_aws_tags.nil?
1425
1389
 
1426
1390
  # Always set the Name tag
1427
1391
  unless ht.keys.include? "Name"
@@ -150,8 +150,8 @@ class Chef
150
150
 
151
151
  server_data["name"] = i.instances[0].tags[0].value
152
152
  server_data["az"] = i.instances[0].placement.availability_zone
153
- server_data["iam_instance_profile"] = ( i.instances[0].iam_instance_profile.nil? ? nil : i.instances[0].iam_instance_profile.arn[/instance-profile\/(.*)/] )
154
- server_data["security_groups"] = i.instances[0].security_groups.map { |x| x.group_name }.join(", ")
153
+ server_data["iam_instance_profile"] = ( i.instances[0].iam_instance_profile.nil? ? nil : i.instances[0].iam_instance_profile.arn[%r{instance-profile/(.*)}] )
154
+ server_data["security_groups"] = i.instances[0].security_groups.map(&:group_name).join(", ")
155
155
 
156
156
  all_data << server_data
157
157
  end
@@ -161,6 +161,7 @@ class Chef
161
161
  # Delete the server instance
162
162
  def delete_instance(instance_id)
163
163
  return nil unless instance_id || instance_id.is_a?(String)
164
+
164
165
  ec2_connection.terminate_instances({
165
166
  instance_ids: [
166
167
  instance_id,
@@ -117,7 +117,7 @@ class Chef
117
117
  ui.color("IAM Profile", :bold)
118
118
  end,
119
119
 
120
- ui.color("State", :bold)
120
+ ui.color("State", :bold),
121
121
  ].flatten.compact
122
122
 
123
123
  output_column_count = servers_list.length
@@ -173,7 +173,7 @@ class Chef
173
173
  server_data["az"] = ui.color(i.instances[0].placement.availability_zone, azcolor(i.instances[0].placement.availability_zone))
174
174
  end
175
175
 
176
- server_data["iam_instance_profile"] = ( i.instances[0].iam_instance_profile.nil? ? nil : i.instances[0].iam_instance_profile.arn[/instance-profile\/(.*)/] )
176
+ server_data["iam_instance_profile"] = ( i.instances[0].iam_instance_profile.nil? ? nil : i.instances[0].iam_instance_profile.arn[%r{instance-profile/(.*)}] )
177
177
 
178
178
  server_data["state"] = ui.color(i.instances[0].state.name, state_color(i.instances[0].state.name))
179
179
 
@@ -182,7 +182,7 @@ class Chef
182
182
  end
183
183
 
184
184
  # dig into security_groups struct
185
- server_data["security_groups"] = i.instances[0].security_groups.map { |x| x.group_name }
185
+ server_data["security_groups"] = i.instances[0].security_groups.map(&:group_name)
186
186
 
187
187
  all_data << server_data
188
188
  end
@@ -191,7 +191,7 @@ class Chef
191
191
 
192
192
  # @return [Array<String>]
193
193
  def extract_tags(tags_struct)
194
- tags_struct.map { |x| x.value }
194
+ tags_struct.map(&:value)
195
195
  end
196
196
  end
197
197
  end
@@ -38,7 +38,7 @@ class Chef
38
38
  ui.color("Available IPs", :bold),
39
39
  ui.color("AZ Default?", :bold),
40
40
  ui.color("Maps Public IP?", :bold),
41
- ui.color("VPC ID", :bold)
41
+ ui.color("VPC ID", :bold),
42
42
  ].flatten.compact
43
43
 
44
44
  output_column_count = subnet_list.length
@@ -36,7 +36,7 @@ class Chef
36
36
  ui.color("CIDR Block", :bold),
37
37
  ui.color("Instance Tenancy", :bold),
38
38
  ui.color("DHCP Options ID", :bold),
39
- ui.color("Default VPC?", :bold)
39
+ ui.color("Default VPC?", :bold),
40
40
  ].flatten.compact
41
41
 
42
42
  output_column_count = vpcs_list.length
@@ -52,9 +52,9 @@ class Chef
52
52
  def path
53
53
  uri = URI(@url)
54
54
  if uri.scheme == "s3"
55
- URI(@url).path.sub(/^\//, "")
55
+ URI(@url).path.sub(%r{^/}, "")
56
56
  else
57
- URI(@url).path.split(bucket).last.sub(/^\//, "")
57
+ URI(@url).path.split(bucket).last.sub(%r{^/}, "")
58
58
  end
59
59
  end
60
60
 
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Ec2
3
- VERSION = "1.0.7".freeze
3
+ VERSION = "1.0.8".freeze
4
4
  MAJOR, MINOR, TINY = VERSION.split(".")
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-08 00:00:00.000000000 Z
11
+ date: 2019-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef