diff --git a/src/commands/periscope/helpers/periscopehelper.ts b/src/commands/periscope/helpers/periscopehelper.ts index 4140baf21..2750255c8 100644 --- a/src/commands/periscope/helpers/periscopehelper.ts +++ b/src/commands/periscope/helpers/periscopehelper.ts @@ -17,25 +17,9 @@ import { ContainerServiceClient } from "@azure/arm-containerservice"; import { getWindowsNodePoolKubernetesVersions } from "../../utils/clusters"; import { BlobServiceClient, StorageSharedKeyCredential } from "@azure/storage-blob"; import { dirSync } from "tmp"; -import { getMonitorClient, getStorageManagementClient } from "../../utils/arm"; +import { getStorageManagementClient } from "../../utils/arm"; import { ReadyAzureSessionProvider } from "../../../auth/types"; -export async function getClusterDiagnosticSettings( - sessionProvider: ReadyAzureSessionProvider, - clusterNode: AksClusterTreeNode, -): Promise { - try { - // Get diagnostic setting via diagnostic monitor - const client = getMonitorClient(sessionProvider, clusterNode.subscriptionId); - const diagnosticSettings = await client.diagnosticSettings.list(clusterNode.armId); - - return diagnosticSettings; - } catch (e) { - vscode.window.showErrorMessage(`Error fetching cluster diagnostic monitor: ${e}`); - return undefined; - } -} - export async function chooseStorageAccount( diagnosticSettings: DiagnosticSettingsResourceCollection, ): Promise { diff --git a/src/commands/periscope/periscope.ts b/src/commands/periscope/periscope.ts index d811cd0e1..2acd60e9c 100644 --- a/src/commands/periscope/periscope.ts +++ b/src/commands/periscope/periscope.ts @@ -2,11 +2,15 @@ import * as vscode from "vscode"; import * as k8s from "vscode-kubernetes-tools-api"; import { IActionContext } from "@microsoft/vscode-azext-utils"; import * as tmpfile from "../utils/tempfile"; -import { getAksClusterTreeNode, getKubeconfigYaml, getManagedCluster } from "../utils/clusters"; +import { + getAksClusterTreeNode, + getClusterDiagnosticSettings, + getKubeconfigYaml, + getManagedCluster, +} from "../utils/clusters"; import { getKustomizeConfig } from "../utils/config"; import { getExtension, longRunning } from "../utils/host"; import { - getClusterDiagnosticSettings, chooseStorageAccount, getStorageInfo, prepareAKSPeriscopeKustomizeOverlay, diff --git a/src/commands/utils/clusters.ts b/src/commands/utils/clusters.ts index 2b4d110fb..f46ad7138 100644 --- a/src/commands/utils/clusters.ts +++ b/src/commands/utils/clusters.ts @@ -4,6 +4,7 @@ import * as yaml from "js-yaml"; import * as path from "path"; import { dirSync } from "tmp"; import { AuthenticationSession, QuickPickItem, authentication, window } from "vscode"; +import * as vscode from "vscode"; import { API, APIAvailable, @@ -17,7 +18,7 @@ import { getTokenInfo } from "../../auth/azureAuth"; import { ReadyAzureSessionProvider, TokenInfo } from "../../auth/types"; import { AksClusterTreeNode } from "../../tree/aksClusterTreeItem"; import { SubscriptionTreeNode, isSubscriptionTreeNode } from "../../tree/subscriptionTreeItem"; -import { getAksClient } from "./arm"; +import { getAksClient, getMonitorClient } from "./arm"; import { Errorable, map as errmap, failed, getErrorMessage, succeeded } from "./errorable"; import { getKubeloginBinaryPath } from "./helper/kubeloginDownload"; import { longRunning } from "./host"; @@ -25,6 +26,7 @@ import { invokeKubectlCommand } from "./kubectl"; import { withOptionalTempFile } from "./tempfile"; import { getResources } from "./azureResources"; import { ClusterFilter } from "./config"; +import { DiagnosticSettingsResourceCollection } from "@azure/arm-monitor"; export interface KubernetesClusterInfo { readonly name: string; @@ -678,3 +680,19 @@ export async function getClusters( }; }); } + +export async function getClusterDiagnosticSettings( + sessionProvider: ReadyAzureSessionProvider, + clusterNode: AksClusterTreeNode, +): Promise { + try { + // Get diagnostic setting via diagnostic monitor + const client = getMonitorClient(sessionProvider, clusterNode.subscriptionId); + const diagnosticSettings = await client.diagnosticSettings.list(clusterNode.armId); + + return diagnosticSettings; + } catch (e) { + vscode.window.showErrorMessage(`Error fetching cluster diagnostic settings: ${e}`); + return undefined; + } +}