-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable Policy Debugging Feature (#118)
* debug refactor * temp * connect to cloud * temp * fix bugs * connect to cloud update * temp change * Use bearer token * Refactor code * temp change * comment code * UpdateOne * Change dogfood endpoint * Fix more issues * temp changes * Neat code * Fix lint error
- Loading branch information
Showing
22 changed files
with
2,229 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as vscode from 'vscode'; | ||
import { ApiOperationTreeItem } from '../../explorer/ApiOperationTreeItem'; | ||
import { IOperationTreeRoot } from '../../explorer/IOperationTreeRoot'; | ||
import { ext } from "../../extensionVariables"; | ||
import { nameUtil } from '../../utils/nameUtil'; | ||
|
||
export async function debugPolicy(node?: ApiOperationTreeItem): Promise<void> { | ||
if (!node) { | ||
node = <ApiOperationTreeItem>await ext.tree.showTreeItemPicker(ApiOperationTreeItem.contextValue); | ||
} | ||
|
||
const operationData = await node.getOperationDebugInfo(); | ||
const debugConfig: vscode.DebugConfiguration = { | ||
type: "apim-policy", | ||
request: "launch", | ||
name: "Attach to APIM", | ||
stopOnEntry: true, | ||
// tslint:disable-next-line: no-non-null-assertion | ||
gatewayAddress: getDebugGatewayAddressUrl(node!.root.serviceName), | ||
managementAddress: getManagementUrl(node.root), | ||
subscriptionId: node.root.subscriptionId, | ||
operationData: operationData, | ||
fileName: `${nameUtil(node.root)}.http` | ||
}; | ||
|
||
// const debugConfig3: vscode.DebugConfiguration = { | ||
// type: "apim-policy", | ||
// request: "launch", | ||
// name: "Attach to APIM", | ||
// stopOnEntry: true, | ||
// gatewayAddress: 'wss://proxy.apim.net/debug-0123456789abcdef', | ||
// managementAddress: 'https://management.apim.net/subscriptions/x/resourceGroups/x/providers/microsoft.apimanagement/service/x', | ||
// managementAuth: '', | ||
// operationData: getLocalDebugOperationData2(), | ||
// fileName: `${nameUtil(node.root)}.http` | ||
// }; | ||
|
||
if (!vscode.debug.activeDebugSession) { | ||
await vscode.debug.startDebugging(undefined, debugConfig); | ||
// await vscode.debug.startDebugging(undefined, debugConfig3); | ||
vscode.debug.onDidTerminateDebugSession(_ => { | ||
const editors = vscode.window.visibleTextEditors; | ||
editors.forEach(editor => { | ||
editor.hide(); | ||
}); | ||
}, vscode.debug.activeDebugSession); | ||
} | ||
} | ||
|
||
function getManagementUrl(root: IOperationTreeRoot): string { | ||
return `${root.environment.resourceManagerEndpointUrl}/subscriptions/${root.subscriptionId}/resourceGroups/${root.resourceGroupName}/providers/microsoft.apimanagement/service/${root.serviceName}`; | ||
} | ||
|
||
function getDebugGatewayAddressUrl(serviceName: string): string { | ||
return `wss://${serviceName}.azure-api.net/debug-0123456789abcdef`; | ||
} | ||
|
||
// function getLocalDebugOperationData2(): string { | ||
// return ` | ||
// GET https://proxy.apim.net/echo/resource | ||
// Ocp-Apim-Subscription-Key: | ||
// Ocp-Apim-Debug:`; | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.