Skip to content

Commit

Permalink
Sort import regex's (#1550)
Browse files Browse the repository at this point in the history
Merged PR #1550.
  • Loading branch information
chrisst authored and modular-magician committed Mar 20, 2019
1 parent d693e64 commit f11706a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
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 f11706a

Please sign in to comment.