aws / aws-application-networking-k8s

A Kubernetes controller for Amazon VPC Lattice
https://www.gateway-api-controller.eks.aws.dev/
Apache License 2.0
164 stars 49 forks source link

Enforce Import Naming Schemes With Linter #433

Open xWink opened 11 months ago

xWink commented 11 months ago

Currently, the naming schemes for imports are enforced through PR. We can improve this process by using a linter like golangci-lint as part of the vet/presubmit script. This way, developers will be informed of improperly named imports before the PR goes up.

Example YAML for golangci-lint:

linters:
  enable:
    - importas

linters-settings:
  importas:
    sigs.k8s.io/gateway-api/apis/v1alpha2: gwv1alpha2

We would want to set up rules for all known/common imports in the repo, such as apimachineryv1, anv1alpha1, etc.

When a new dependency is added, it will be up to the developer + reviewers to determine an import name that fits the scheme and add it to the linter's rules.

From my understanding, utilizing this linter would not automatically edit the existing import names, so the PR that introduces this would likely also require fixing all the misnamed imports too.

mikhail-aws commented 11 months ago

321