in src/commands/aksDeployManifest/aksDeployManifest.ts [21:100]
export async function aksDeployManifest() {
// Check if GitHub Copilot for Azure extension is installed
const checkGitHubCopilotExtension = checkExtension(GITHUBCOPILOT_FOR_AZURE_VSCODE_ID);
if (!checkGitHubCopilotExtension) {
handleExtensionDoesNotExist(GITHUBCOPILOT_FOR_AZURE_VSCODE_ID);
return;
}
// Select manifest
const manifest = await getManifestFile();
if (manifest === undefined) {
logGitHubCopilotPluginEvent({ commandId: "aks.aksDeployManifest", manifestSelected: "false" });
return;
}
logGitHubCopilotPluginEvent({ commandId: "aks.aksDeployManifest", manifestSelected: "true" });
// Select cluster
const sessionProvider = await getReadySessionProvider();
if (failed(sessionProvider)) {
vscode.window.showErrorMessage(sessionProvider.error);
return;
}
const cluster = await selectClusterOptions(sessionProvider.result, undefined, "aks.aksDeployManifest");
if (failed(cluster)) {
logGitHubCopilotPluginEvent({ commandId: "aks.aksDeployManifest", clusterSelected: "false" });
vscode.window.showErrorMessage(cluster.error);
return;
}
// Return value is boolean if user selects new cluster option, which should stop flow and guide user to create a new cluster first.
if (cluster.result === true) {
vscode.window.showInformationMessage("Please create AKS cluster before deploying the manifest.");
return;
}
const clusterPreference = cluster.result as ClusterPreference;
// Confirm deployment
const confirmed = await confirmDeployment(clusterPreference.clusterName);
if (!confirmed) {
vscode.window.showWarningMessage("Manifest deployment cancelled.");
logGitHubCopilotPluginEvent({ commandId: "aks.aksDeployManifest", manifestDeploymentCancelled: "true" });
return;
}
const deploymentResult = await deployApplicationToCluster({
cluster: clusterPreference,
manifestPath: manifest,
});
if (failed(deploymentResult)) {
vscode.window.showErrorMessage(deploymentResult.error);
logGitHubCopilotPluginEvent({ commandId: "aks.aksDeployManifest", manifestDeploymentSuccess: "false" });
return;
}
logGitHubCopilotPluginEvent({ commandId: "aks.aksDeployManifest", manifestDeploymentSuccess: "true" });
vscode.window
.showInformationMessage(
`Your application has been successfully deployed to the ${clusterPreference.clusterName} AKS cluster.`,
"View resource in the Azure portal",
)
.then((res) => {
if (res) {
logGitHubCopilotPluginEvent({
commandId: "aks.aksDeployManifest",
manifestDeploymentLinkClicked: "true",
});
vscode.env.openExternal(vscode.Uri.parse(deploymentResult.result.url));
}
});
}