Skip to content

feat: add ports autocompletion for kubectl port-forward command#124683

Merged
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
TessaIO:feat-add-portforward-autocompletion
May 13, 2024
Merged

feat: add ports autocompletion for kubectl port-forward command#124683
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
TessaIO:feat-add-portforward-autocompletion

Conversation

@TessaIO
Copy link
Member

@TessaIO TessaIO commented May 2, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR aims to add ports autocompletion for kubectl port-forward command

Which issue(s) this PR fixes:

Fixes kubernetes/kubectl#1536

Special notes for your reviewer:

For now, it just outputs the port number. If you want to support also port names let me know.

Does this PR introduce a user-facing change?

Added ports autocompletion for kubectl port-foward command

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

N/A

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels May 2, 2024
@k8s-ci-robot k8s-ci-robot requested review from brianpursley and enj May 2, 2024 20:10
@k8s-ci-robot k8s-ci-robot added area/kubectl sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 2, 2024
@TessaIO
Copy link
Member Author

TessaIO commented May 2, 2024

/retest

@gnufred
Copy link

gnufred commented May 5, 2024

I am able to test the new feature by:

  • Compiling kubectl from this PR.
  • Sourcing kubectl completion <shell>
  • Creating an NGINX deployment
  • Adding containerPort: 80 to the container specification
  • Typing kubectl port-forward pods/nx1-********* <TAB> which causes 80 to appear.

https://github.com/kubernetes/kubectl/issues/1536 requested, to autocomplete local_port:remote_port, that being said, specifying a single port like 80 is interpreted as 80:80, which works just fine.

If I edit the deployment to configure port 8080, here's the result:

~ $ kubectl port-forward pods/nx1-84f54865b5-vjtrx <TAB>
~ $ kubectl port-forward pods/nx1-84f54865b5-vjtrx 8080
Forwarding from 127.0.0.1:8080 -> 8080
Forwarding from [::1]:8080 -> 8080

Looks good to me.

@TessaIO TessaIO force-pushed the feat-add-portforward-autocompletion branch from c424233 to a81ce8b Compare May 6, 2024 07:52
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 6, 2024
@TessaIO
Copy link
Member Author

TessaIO commented May 6, 2024

/retest

@gnufred
Copy link

gnufred commented May 6, 2024

/lgtm

Code has comments.
Code is clear/clean.
New functions are covered by tests.

@k8s-ci-robot
Copy link
Contributor

@gnufred: changing LGTM is restricted to collaborators

Details

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ardaguclu
Copy link
Member

What is the difference between this PR and #122752?

@TessaIO
Copy link
Member Author

TessaIO commented May 6, 2024

What is the difference between this PR and #122752?

I don't get your point exactly, but it was open for quite some time and there's no activity there. Also, you can see that there are some differences in terms of implementation + I have some tests here

@ardaguclu
Copy link
Member

What is the difference between this PR and #122752?

I don't get your point exactly, but it was open for quite some time and there's no activity there. Also, you can see that there are some differences in terms of implementation + I have some tests here

I think, in such cases it is better to notify the authors (e.g. #122752) that your PR is based on their code to prevent duplicate efforts and share the credits of the overall work.

@lucasrod16
Copy link

What is the difference between this PR and #122752?

I don't get your point exactly, but it was open for quite some time and there's no activity there. Also, you can see that there are some differences in terms of implementation + I have some tests here

I think, in such cases it is better to notify the authors (e.g. #122752) that your PR is based on their code to prevent duplicate efforts and share the credits of the overall work.

@ardaguclu I'm okay with @TessaIO taking over the implementation in this PR. I will close #122752 in favor of this PR. I appreciate it

@TessaIO TessaIO force-pushed the feat-add-portforward-autocompletion branch from a81ce8b to aa0c978 Compare May 6, 2024 21:13
@TessaIO TessaIO requested a review from ardaguclu May 6, 2024 21:14
@brianpursley
Copy link
Member

Completion working as expected.

See comments about unit test.

@TessaIO TessaIO force-pushed the feat-add-portforward-autocompletion branch 2 times, most recently from f3f2e32 to e81b4aa Compare May 10, 2024 22:21
@TessaIO TessaIO requested a review from ah8ad3 May 10, 2024 22:22
@TessaIO
Copy link
Member Author

TessaIO commented May 10, 2024

@brianpursley @ah8ad3 @ardaguclu Tests added. Feel free to do another round of review.

Copy link
Member

@ah8ad3 ah8ad3 left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@ah8ad3
Copy link
Member

ah8ad3 commented May 11, 2024

/lgtm

/cc @ardaguclu @brianpursley for review and approve

@k8s-ci-robot
Copy link
Contributor

@ah8ad3: GitHub didn't allow me to request PR reviews from the following users: for, review, and, approve.

Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

/lgtm

/cc @ardaguclu @brianpursley for review and approve

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 11, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

DetailsGit tree hash: e40e707393544dda6a0355b00fd8797ab4ac7bc7

Copy link
Member

@ardaguclu ardaguclu left a comment

Choose a reason for hiding this comment

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

Actual code implementation looks good to me. Left a few comments for tests.

Signed-off-by: TessaIO <ahmedgrati1999@gmail.com>
@TessaIO TessaIO force-pushed the feat-add-portforward-autocompletion branch from e81b4aa to a84e893 Compare May 13, 2024 06:16
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 13, 2024
@k8s-ci-robot k8s-ci-robot requested a review from ah8ad3 May 13, 2024 06:16
@TessaIO TessaIO requested a review from ardaguclu May 13, 2024 06:17
@ardaguclu
Copy link
Member

@TessaIO thanks for spending time and effort on this PR.

LGTM

Copy link
Member

@ah8ad3 ah8ad3 left a comment

Choose a reason for hiding this comment

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

Thanks for effort. /lgtm

@TessaIO
Copy link
Member Author

TessaIO commented May 13, 2024

/assign @brianpursley

Copy link
Member

@brianpursley brianpursley left a comment

Choose a reason for hiding this comment

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

/lgtm

Thanks!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 13, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

DetailsGit tree hash: cb9c46516a5b6112406a65026baf4bde9060c6c2

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ah8ad3, brianpursley, TessaIO

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

The pull request process is described here

Details 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 13, 2024
@brianpursley
Copy link
Member

/remove-sig auth

@k8s-ci-robot k8s-ci-robot removed the sig/auth Categorizes an issue or PR as relevant to SIG Auth. label May 13, 2024
@k8s-ci-robot k8s-ci-robot merged commit 5e1a1db into kubernetes:master May 13, 2024
@k8s-ci-robot k8s-ci-robot added this to the v1.31 milestone May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Projects

Archived in project
Archived in project

Development

Successfully merging this pull request may close these issues.

cmd/port-forward: port number completion

8 participants