Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
(CLOUD-256) Fix blank name tags for all resources
Browse files Browse the repository at this point in the history
This was previously fixed for instances only but this commit generalises
the fix to other resources. Tags do not have to contain content, so it's
possible for an account to contain resources with a Name tag which is
blank. Previously we checked for the presence of name, and not whether
it was empty.
  • Loading branch information
garethr authored and Colleen Murphy committed Mar 20, 2015
1 parent 5e48527 commit 6e9ec7a
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/provider/ec2_instance/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def self.instances
response.data.reservations.each do |reservation|
reservation.instances.each do |instance|
hash = instance_to_hash(region, instance)
instances << new(hash) if (hash[:name] and ! hash[:name].empty?)
instances << new(hash) if has_name?(hash)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/ec2_vpc/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.instances
vpcs = []
response.data.vpcs.each do |vpc|
hash = vpc_to_hash(region, vpc)
vpcs << new(hash) if hash[:name]
vpcs << new(hash) if has_name?(hash)
end
vpcs
end.flatten
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/ec2_vpc_dhcp_options/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.instances
ec2_client(region).describe_dhcp_options.collect do |response|
response.data.dhcp_options.each do |item|
hash = dhcp_option_to_hash(region, item)
options << new(hash) if hash[:name]
options << new(hash) if has_name?(hash)
end
end
options
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/ec2_vpc_internet_gateway/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.instances
gateways = []
response.data.internet_gateways.each do |gateway|
hash = gateway_to_hash(region, gateway)
gateways << new(hash) if hash[:name]
gateways << new(hash) if has_name?(hash)
end
gateways
end.flatten
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/ec2_vpc_routetable/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.instances
tables = []
response.data.route_tables.each do |table|
hash = route_table_to_hash(region, table)
tables << new(hash) if hash[:name]
tables << new(hash) if has_name?(hash)
end
tables
end.flatten
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/ec2_vpc_subnet/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.instances
subnets = []
response.data.subnets.each do |subnet|
hash = subnet_to_hash(region, subnet)
subnets << new(hash) if hash[:name]
subnets << new(hash) if has_name?(hash)
end
subnets
end.flatten
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/ec2_vpc_vpn/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def self.instances()
]).each do |response|
response.data.vpn_connections.each do |connection|
hash = connection_to_hash(region, connection)
connections << new(hash) if hash[:name]
connections << new(hash) if has_name?(hash)
end
end
connections
Expand Down
4 changes: 1 addition & 3 deletions lib/puppet/provider/ec2_vpc_vpn_gateway/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ def self.instances()
]).each do |response|
response.data.vpn_gateways.each do |gateway|
hash = gateway_to_hash(region, gateway)
if hash[:name]
gateways << new(hash)
end
gateways << new(hash) if has_name?(hash)
end
end
gateways
Expand Down
4 changes: 4 additions & 0 deletions lib/puppet_x/puppetlabs/aws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ def tags=(value)
) unless missing_tags.empty?
end

def self.has_name?(hash)
!hash[:name].nil? && !hash[:name].empty?
end

end
end
end

0 comments on commit 6e9ec7a

Please sign in to comment.