Skip to content

Add support for PortForward. #91

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 1 commit into from
Oct 10, 2017

Conversation

brendandburns
Copy link
Contributor

Fixes #11

Uses WebSocket for Port Forward as added by kubernetes/kubernetes#33684

@mbohlool @lwander

streamRequest(request, client, listener);
}

/** If we ever upgrade to okhttp 3...
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might get interpreted as a javadoc with that extra *

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

public OutputStream getOutboundStream(int port) {
int portIndex = findPortIndex(port);
if (portIndex == -1) {
throw new IllegalArgumentException("No such port!");
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be neater to have findPortIndex(..) throw this exception instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

switched to return null instead of throw.

WebSocketStreamHandler handler = new WebSocketStreamHandler();
PortForwardResult result = new PortForwardResult(handler, ports);
List<Pair> queryParams = new ArrayList<>();
queryParams.add(new Pair("ports", "80"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it always '80' or just once for the example you gave above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ugh! good catch, fixed.

* I/O for first port (80) is on Channel 0
* Err for first port (80) is on Channel 1
* I/O for second port (8080) is on Channel 2
* Err for second port (8080) is on Channel 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Channel 2 or 3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, fixed.

*
* @param namespace The namespace of the Pod
* @param name The name of the Pod
* @param ports The ports to forward
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add @return, I don't think our linter is catching it but the release will fail w/o it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

* PortForward to a container
*
* @param pod The pod where the port forward is run.
* @param ports The ports to forward
Copy link
Contributor

Choose a reason for hiding this comment

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

@return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.


/**
* Get the API client for these PortForward operations.
* @returns The API client that will be used.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/returns/return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

@brendandburns
Copy link
Contributor Author

@lwander comments addressed, please take another look.

Thanks!

Copy link
Contributor

@lwander lwander left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

3 participants