Skip to content

fix: Respect port selection by name by services in ForwardPortE #1557

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

Merged
merged 2 commits into from
May 21, 2025

Conversation

s-diez
Copy link
Contributor

@s-diez s-diez commented May 12, 2025

Description

Fixes #1556.

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Include release notes. If this PR is backward incompatible, include a migration guide.
  • Make a plan for release of the functionality in this PR. If it delivers value to an end user, you are responsible for ensuring it is released promptly, and correctly. If you are not a maintainer, you are responsible for finding a maintainer to do this for you.

Release Notes

Added mapping of port selection by name by services to tunnel.ForwardPortE.

Copy link
Contributor

@james03160927 james03160927 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM. Let me run the tests.

@@ -323,3 +338,14 @@ func GetAvailablePortE(t testing.TestingT) (int, error) {
}
return port, err
}

func getPodPortByName(pod *corev1.Pod, portName string) (int, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we ensure that the function handles cases like pod = nil or pod.Spec gracefully?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a check for pod = nil. pod.Spec, pod.Spec.Containers etc. should be enforced by type system.

@s-diez s-diez force-pushed the service-tunnel-port-name branch from c334d70 to 1099c25 Compare May 14, 2025 12:51
@s-diez s-diez force-pushed the service-tunnel-port-name branch from 1099c25 to cb26c91 Compare May 14, 2025 12:54
@james03160927
Copy link
Contributor

Thanks for addressing the comments. Will re-trigger the test. Can you update the branch with the latest change by clicking the button "update branch" as well?

Copy link
Contributor

@james03160927 james03160927 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@james03160927 james03160927 merged commit c3ca221 into gruntwork-io:main May 21, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tunnel.ForwardPortE no longer works with named targetPort
2 participants