Skip to content

Commit

Permalink
Merge pull request #550 from k1LoW/fix-549
Browse files Browse the repository at this point in the history
Fix: undefined method `by_cidr'
  • Loading branch information
k1LoW authored Oct 8, 2021
2 parents bae2330 + 33e6653 commit 634fe13
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/awspec/helper/finder/subnet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ def has_subnet?(subnet_id_symbol)
@subnet_ids.key?(subnet_id_symbol)
end

# Check if a IPv4 CIDR (as a symbol) exists in the cache.
def has_cidr?(cidr_symbol)
@by_cidr.key?(cidr_symbol)
end

# Return a +Aws::EC2::Types::Subnet+ that matches the given CIDR.
def subnet_by_cidr(cidr_symbol)
@subnet_ids[@by_cidr[cidr_symbol]]
Expand Down Expand Up @@ -109,7 +114,7 @@ def find_subnet(subnet_id)

id_key = subnet_id.to_sym
return cache.subnet_by_id(id_key) if subnet_id.start_with?('subnet-') && cache.has_subnet?(id_key)
return cache.subnet_by_cidr(id_key) if cache.is_cidr?(subnet_id) && cache.by_cidr.key?(id_key)
return cache.subnet_by_cidr(id_key) if cache.is_cidr?(subnet_id) && cache.has_cidr?(id_key)
cache.subnet_by_tag(id_key)
end
end
Expand Down

0 comments on commit 634fe13

Please sign in to comment.