Skip to content

backend: pkg: portforward: Fix cache implementation and refactor shorten PortForward #3284

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fromsaurav
Copy link
Contributor

Refactor(backend/portforward): Shorten startPortForward function

This PR addresses issue #3279 by refactoring the internal startPortForward function in backend/pkg/portforward/handler.go.

Changes Made:

  • The startPortForward function was broken down into smaller, more manageable helper functions:
    • getKubeClientAndConfig
    • initPortForwarder
    • handlePortForwardReadiness
    • runAndMonitorPortForward
    • monitorPodAndManagePortForward
  • This refactoring resolves the funlen linter warning previously associated with this function.
  • The primary goal was to improve code readability, maintainability, and reduce complexity without altering existing functionality.
  • The //nolint:funlen directive has been removed from the refactored startPortForward function.

Testing:

  • All backend linters (make backend-lint) pass.
  • All backend unit and integration tests (make backend-test with HEADLAMP_RUN_INTEGRATION_TESTS=true against a Minikube cluster) pass.

Fixes #3279

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 18, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fromsaurav
Once this PR has been reviewed and has the lgtm label, please assign joaquimrocha for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 18, 2025
@fromsaurav fromsaurav force-pushed the refactor/3279-shorten-startportforward branch from 28eeac6 to 967aa8a Compare May 18, 2025 19:52
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 18, 2025
@fromsaurav fromsaurav changed the title backend: pkg: portforward: Fix cache implementation and refactor startPortForward backend: pkg: portforward: Fix cache implementation and refactor shorten PortForward May 18, 2025
@illume
Copy link
Contributor

illume commented May 20, 2025

We follow a linux kernel style of commit messages. With the context at the front followed by an action word and the rest.

Would you mind changing them to something like this? (but probably you can write them better).

backend: portforward: Function: Shorten function

See git log for some more examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

backend: Refactor release.go startPortForward to be shorter
3 participants