Skip to content

Commit

Permalink
Sort import regex's
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisst committed Mar 19, 2019
1 parent dd8ba72 commit f27f70f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion provider/terraform/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def import_id_formats(resource)
field_markers -= ['{{project}}', '{{region}}', '{{zone}}']
short_id_default_format = field_markers.join('/')

(id_formats + [short_id_format, short_id_default_format]).uniq.reject(&:empty?)
# Regexes should be unique and ordered from most specific to least specific
(id_formats + [short_id_format, short_id_default_format]).
uniq.reject(&:empty?).sort_by{|i| i.count('/')}.reverse
end
end
end
Expand Down

0 comments on commit f27f70f

Please sign in to comment.