Skip to content

Commit

Permalink
Option to display port forwarding in status bar (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
itowlson authored May 8, 2019
1 parent ebd88fa commit d3585b4
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 0.0.8

* Updated Kubectl API with option of showing forwarded ports in user interface.

## 0.0.7

* Updated Cluster Explorer API to offer re-use of built-in resource folder and grouping folder

## 0.0.6

* Updated Cluster Explorer API to support customising the appearance of existing nodes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-kubernetes-tools-api",
"version": "0.0.7",
"version": "0.0.8",
"description": "Documents and encapsulates the API for the Kubernetes extension for Visual Studio Code",
"main": "js/index.js",
"types": "js/index.d.ts",
Expand Down
57 changes: 56 additions & 1 deletion ts/kubectl/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ export interface KubectlV1 {
* @param podNamespace The namespace containing the pod.
* @param localPort The local port to be forwarded.
* @param remotePort The port on the pod to which to forward.
* @param options Options for port forwarding.
* @returns A Disposable which can be used to terminate port forwarding, or undefined
* if port forwarding failed.
*/
portForward(podName: string, podNamespace: string | undefined, localPort: number, remotePort: number): Promise<vscode.Disposable | undefined>;
portForward(podName: string, podNamespace: string | undefined, localPort: number, remotePort: number, options?: KubectlV1.PortForwardOptions): Promise<vscode.Disposable | undefined>;
}

export namespace KubectlV1 {
Expand All @@ -45,4 +46,58 @@ export namespace KubectlV1 {
*/
readonly stderr: string;
}

/**
* Options for performing port forwarding using kubectl.
*/
export interface PortForwardOptions {
/**
* Specifies whether and how to display the forwarded port in the Visual Studio
* Code user interface. If not present, the forwarded port is not shown.
*/
readonly showInUI?: PortForwardUIOptions;
}

/**
* Specifies that the forwarded port should not be shown in the Visual Studio Code
* user interface. This is equivalent to omitting the PortForwardOptions.showInUI property.
*/
export interface PortForwardNoUIOptions {
/**
* Specifies that the port-forward should not be displayed in any location.
*/
readonly location: 'none';
}

/**
* Specifies that the forwarded port should be shown in the Visual Studio Code
* status bar. When any forwarded ports have this set, the status bar displays
* a "Kubectl Port Forwarding" indicator which the user can click to see a
* list of active port-forwards.
*/
export interface PortForwardStatusBarUIOptions {
/**
* Specifies the status bar as the display location.
*/
readonly location: 'status-bar';
/**
* A string to be shown alongside the port-forward if the user displays the
* list. This helps the user to identify the purpose of the port-forward.
*/
readonly description?: string;
/**
* A function to be called if the user cancels port forwarding via the
* list of active port-forwards. This can be used to clean up associated
* state (for example, to note that the port will need to be re-forwarded
* if the user wants to perform whatever operation was using the forwarded
* port again), to provide information to the user, etc.
*/
readonly onCancel?: () => void;
}

/**
* Specifies whether and how to display a forwarded port in the Visual Studio
* Code user interface.
*/
export type PortForwardUIOptions = PortForwardNoUIOptions | PortForwardStatusBarUIOptions;
}

0 comments on commit d3585b4

Please sign in to comment.