k8s: move portforward functionality to separate sub-package #38060
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The k8s package currently is a catch-all package for all kind of k8s-related functionality. By itself it already has a prettly large list of (transitive) dependencies, among them packages specific to the datapath or the underlying operating system. This becomes problematic once cross-built tools such as Cilium CLI or Hubble CLI start depending on pkg/k8s as is the case since the portforward functionality was added in commit ae0d2f3 ("cilium-cli: extract portforward logic into new PortForwarder type") and they transitively start depending on the platform-specific pacakges such as pkg/datapath.
This commit fixes that by moving the portforward functionality to pkg/k8s/portforward which is easy because it doesn't depend on any other code in pkg/k8s. This should help to break these transitive dependencies.
Towards #37598