kubernetes-sylixos/cmd/preferredimports
Patrick Ohly a00a1c99d5 preferredimports: support regular expressions for the import path
Having to list all packages isn't very manageable and requires constant
maintenance that is easy to miss. For example, test/e2e/framework/daemonset was
created without adding an entry for it. Promptly one file doesn't use the
intended e2edaemonset alias.

A simpler solution is to support matching the import path against a regular
expression and deriving the intended alias by expanding placeholders (${name},
$1, etc.) with the corresponding submatches from the import path. Example:

   k8s.io/kubernetes/test/e2e/framework/([^/]*) -> e2e$1

This support is backwards compatible because normal import paths don't contain
characters that are special in a regular expression and normal aliases don't
contain placeholders.

A regular expression must match the entire import path, otherwise it is
skipped.
2022-09-08 18:37:52 +02:00
..
OWNERS verify import aliases 2019-06-15 22:31:39 -04:00
preferredimports.go preferredimports: support regular expressions for the import path 2022-09-08 18:37:52 +02:00