Skip to content

Commit

Permalink
Enable navigation to azure portal feature. (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatsinnit authored May 9, 2022
1 parent b8bfd3c commit 844c090
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"onCommand:aks.aksBestPracticesDiagnostics",
"onCommand:aks.configureHelmStarterWorkflow",
"onCommand:aks.configureKomposeStarterWorkflow",
"onCommand:aks.configureKustomizeStarterWorkflow"
"onCommand:aks.configureKustomizeStarterWorkflow",
"onCommand:aks.showInPortal"
],
"main": "./dist/extension",
"contributes": {
Expand Down Expand Up @@ -97,6 +98,10 @@
{
"command": "aks.configureKustomizeStarterWorkflow",
"title": "Kustomize Workflow"
},
{
"command": "aks.showInPortal",
"title": "Show In Azure Portal"
}
],
"menus": {
Expand All @@ -122,6 +127,11 @@
"when": "view == kubernetes.cloudExplorer && viewItem =~ /aks\\.cluster/i",
"group": "8@2"
},
{
"command": "aks.showInPortal",
"when": "view == kubernetes.cloudExplorer && viewItem =~ /aks\\.cluster/i",
"group": "8@3"
},
{
"command": "aks.installAzureServiceOperator",
"when": "view == kubernetes.cloudExplorer && viewItem =~ /aks\\.cluster/i"
Expand Down
28 changes: 28 additions & 0 deletions src/commands/aksNavToPortal/aksNavToPortal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as vscode from 'vscode';
import * as k8s from 'vscode-kubernetes-tools-api';
import { IActionContext } from "vscode-azureextensionui";
import { getAksClusterTreeItem } from '../utils/clusters';
import { getExtensionPath } from '../utils/host';
import { failed } from '../utils/errorable';

export default async function aksNavToPortal(
_context: IActionContext,
target: any
): Promise<void> {
const cloudExplorer = await k8s.extension.cloudExplorer.v1;

const cluster = getAksClusterTreeItem(target, cloudExplorer);
if (failed(cluster)) {
vscode.window.showErrorMessage(cluster.error);
return;
}

const extensionPath = getExtensionPath();
if (failed(extensionPath)) {
vscode.window.showErrorMessage(extensionPath.error);
return;
}

// armid is in the format: /subscriptions/<sub_id>/resourceGroups/<resource_group>/providers/<container_service>/managedClusters/<aks_clustername>
vscode.env.openExternal(vscode.Uri.parse(`https://portal.azure.com/#resource${cluster.result.armId}/overview`));
}
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import aksBestPracticesDiagnostics from './commands/aksBestPractices/aksBestPrac
import aksIdentitySecurityDiagnostics from './commands/aksIdentitySecurity/aksIdentitySecurity';
import aksNodeHealth from './commands/aksNodeHealth/aksNodeHealth';
import aksKnownIssuesAvailabilityPerformanceDiagnostics from './commands/aksKnownIssuesAvailabilityPerformance/aksKnownIssuesAvailabilityPerformance';
import aksNavToPortal from './commands/aksNavToPortal/aksNavToPortal';

export async function activate(context: vscode.ExtensionContext) {
const cloudExplorer = await k8s.extension.cloudExplorer.v1;
Expand Down Expand Up @@ -50,6 +51,7 @@ export async function activate(context: vscode.ExtensionContext) {
registerCommandWithTelemetry('aks.configureKustomizeStarterWorkflow', configureKustomizeStarterWorkflow );
registerCommandWithTelemetry('aks.aksNodeHealthDiagnostics', aksNodeHealth );
registerCommandWithTelemetry('aks.aksKnownIssuesAvailabilityPerformanceDiagnostics', aksKnownIssuesAvailabilityPerformanceDiagnostics );
registerCommandWithTelemetry('aks.showInPortal', aksNavToPortal );

await registerAzureServiceNodes(context);

Expand Down

0 comments on commit 844c090

Please sign in to comment.