Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importas rule for all k8s.io/api imports #2811

Open
lahabana opened this issue Sep 21, 2021 · 19 comments
Open

importas rule for all k8s.io/api imports #2811

lahabana opened this issue Sep 21, 2021 · 19 comments
Labels
area/ci-cd good first issue Good for newcomers kind/improvement Improvement on an existing feature triage/accepted The issue was reviewed and is complete enough to start working on it

Comments

@lahabana
Copy link
Contributor

Summary

We currently don't good import rules for this. It would simplify readability if these were standardised.

@jpeach
Copy link
Contributor

jpeach commented Sep 22, 2021

IMHO, not all imports, just common or conventional ones. I don't think that we should go down the path of always requiring import aliases everywhere :)

@lahabana
Copy link
Contributor Author

Yes I was thing metav1/corev1/appv1 something like this.

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Nov 22, 2021
@github-actions
Copy link
Contributor

This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant please comment on it promptly or attend the next triage meeting.

@lahabana lahabana added kind/cleanup Cleanup/refactor an existing component/code and removed code-quality labels Nov 22, 2021
@jpeach jpeach removed the triage/stale Inactive for some time. It will be triaged again label Nov 22, 2021
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Dec 24, 2021
@github-actions
Copy link
Contributor

This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant please comment on it promptly or attend the next triage meeting.

@lahabana lahabana added area/ci-cd triage/accepted The issue was reviewed and is complete enough to start working on it and removed triage/stale Inactive for some time. It will be triaged again labels Jan 21, 2022
@github-actions
Copy link
Contributor

This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant please comment on it promptly or attend the next triage meeting.

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Feb 21, 2022
@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Apr 26, 2022
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label May 27, 2022
@github-actions
Copy link
Contributor

This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant please comment on it promptly or attend the next triage meeting.

@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label May 27, 2022
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Jun 27, 2022
@github-actions
Copy link
Contributor

This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant please comment on it promptly or attend the next triage meeting.

@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Jun 27, 2022
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Jul 28, 2022
@github-actions
Copy link
Contributor

This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant please comment on it promptly or attend the next triage meeting.

@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Jul 28, 2022
@afzal442
Copy link

Any clue here how to approach here?

@lahabana
Copy link
Contributor Author

Just a matter at adding some entries there: https://github.com/kumahq/kuma/blob/master/.golangci.yml#L25-L42

Looking at it we're not talking about a LOT of them:

➜  kuma git:(fix5005) git grep k8s.io/api  | grep '\.go'  | sed -E 's/[^"]+"(.+)"/\1/g' | sort | uniq -c | sort
   1 k8s.io/api/batch/v1
   1 k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1
   1 k8s.io/apimachinery/pkg/fields
   1 k8s.io/apimachinery/pkg/runtime/serializer/json
   1 k8s.io/apimachinery/pkg/selection
   1 k8s.io/apimachinery/pkg/util/yaml
   1 k8s.io/apimachinery/pkg/version
   2 k8s.io/apimachinery/pkg/watch
   3 k8s.io/api/authentication/v1
   3 k8s.io/apimachinery/pkg/apis/meta/v1/unstructured
   4 k8s.io/api/apps/v1
   4 k8s.io/apimachinery/pkg/api/resource
   4 k8s.io/apimachinery/pkg/labels
   7 k8s.io/apimachinery/pkg/runtime/serializer
   9 k8s.io/apimachinery/pkg/util/intstr
  11 k8s.io/apimachinery/pkg/api/meta
  12 k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
  16 k8s.io/api/admission/v1
  16 k8s.io/apimachinery/pkg/runtime/schema
  30 k8s.io/apimachinery/pkg/api/errors
  38 k8s.io/apimachinery/pkg/types
  42 k8s.io/apimachinery/pkg/runtime
  59 k8s.io/api/core/v1
  81 k8s.io/apimachinery/pkg/apis/meta/v1

But for example if you take the most commonly used it's imported as metav1/kube_meta/v1 adding these in the linter would force always using the same alias:

➜  kuma git:(fix5005) git grep k8s.io/api  | grep '\.go'  | grep k8s.io/apimachinery/pkg/apis/meta/v1
app/cni/pkg/cni/kubernetes.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
app/kuma-cp/cmd/run_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
app/kumactl/cmd/install/install_crds.go:	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/bootstrap/k8s/cache/informer_cache.go:	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
pkg/plugins/bootstrap/k8s/cache/internal/deleg_map.go:	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
pkg/plugins/bootstrap/k8s/cache/internal/informers_map.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/bootstrap/k8s/plugin.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/common/k8s/composite_validator_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/config/k8s/store.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/config/k8s/store_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/policies/donothingpolicy/k8s/v1alpha1/zz_generated.types.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/policies/meshaccesslog/k8s/v1alpha1/zz_generated.types.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/policies/meshtrafficpermission/k8s/v1alpha1/zz_generated.types.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/events/listener.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/k8s_suite_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/circuitbreaker_types_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/container_patch.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/dataplane_insight_types_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/dataplane_types_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/externalservice_types_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/healthcheck_types_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/mesh_gateway_config.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/mesh_gateway_instance.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/mesh_types_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/proxytemplate_types_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/retry_types_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/trafficroute_types_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/zone_insight_types_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/zz_generated.deepcopy.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/zz_generated.mesh.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/api/v1alpha1/zz_generated.system.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/pkg/model/resources.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/test/api/sample/v1alpha1/sample_types.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/native/test/api/sample/v1alpha1/sample_types_helpers.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/store.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/resources/k8s/store_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/apis/k8s.cni.cncf.io/v1/types.go:import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/configmap_controller_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/gateway_converter.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/gateway_instance_controller.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/gatewayapi/attachment/attachment.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/gatewayapi/attachment/attachment_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/gatewayapi/common/reconcile.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/gatewayapi/gateway_class_controller.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/gatewayapi/gateway_controller.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/gatewayapi/gateway_conversion.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/gatewayapi/gateway_conversion_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/gatewayapi/gateway_status.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/gatewayapi/http_route_controller.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/gatewayapi/http_route_conversion.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/gatewayapi/policy/policy_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/namespace_controller.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/namespace_controller_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/pod_controller.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/pod_controller_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/pod_converter_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/pod_status_controller_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/service_controller_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/controllers/util/controlled.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/util/util.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/util/util_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/webhooks/defaulter_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/webhooks/gatewayapi_multizone_validator_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/webhooks/injector/injector_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/webhooks/owner_reference_mutator_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/webhooks/secret_validator_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/webhooks/validation.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/webhooks/validation_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/runtime/k8s/webhooks/webhook_suite_test.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/secrets/k8s/store.go:	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/plugins/secrets/k8s/store_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkg/transparentproxy/kubernetes/kubernetes_test.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
test/e2e_env/kubernetes/gateway/utils.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
test/framework/deployments/externalservice/kubernetes.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
test/framework/deployments/kic/kubernetes.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
test/framework/deployments/observability/kubernetes.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
test/framework/deployments/testserver/kubernetes.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
test/framework/k8s.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
test/framework/k8s_cluster.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
test/framework/k8s_controlplane.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
test/framework/k8s_controlplane.go:	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
test/framework/setup.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
tools/policy-gen/protoc-gen-kumapolicy/crd.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
tools/resource-gen/main.go:	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Dec 20, 2022
@github-actions
Copy link
Contributor

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Dec 20, 2022
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Mar 21, 2023
@github-actions
Copy link
Contributor

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Mar 21, 2023
@github-actions
Copy link
Contributor

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Jun 20, 2023
@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Jun 20, 2023
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Sep 19, 2023
@github-actions
Copy link
Contributor

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Sep 22, 2023
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Dec 22, 2023
Copy link
Contributor

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@jakubdyszkiewicz jakubdyszkiewicz removed the triage/stale Inactive for some time. It will be triaged again label Jan 2, 2024
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Apr 2, 2024
Copy link
Contributor

github-actions bot commented Apr 2, 2024

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@slonka slonka removed the triage/stale Inactive for some time. It will be triaged again label Apr 2, 2024
@lahabana lahabana added kind/improvement Improvement on an existing feature and removed kind/cleanup Cleanup/refactor an existing component/code labels Apr 5, 2024
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Jul 5, 2024
Copy link
Contributor

github-actions bot commented Jul 5, 2024

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@jakubdyszkiewicz jakubdyszkiewicz removed the triage/stale Inactive for some time. It will be triaged again label Jul 10, 2024
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Oct 10, 2024
Copy link
Contributor

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@lukidzi lukidzi removed the triage/stale Inactive for some time. It will be triaged again label Oct 21, 2024
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Feb 19, 2025
Copy link
Contributor

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@bartsmykla bartsmykla removed the triage/stale Inactive for some time. It will be triaged again label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ci-cd good first issue Good for newcomers kind/improvement Improvement on an existing feature triage/accepted The issue was reviewed and is complete enough to start working on it
Projects
None yet
Development

No branches or pull requests

7 participants