Skip to content

Commit

Permalink
Support deploying to other clouds in Deploy Pane
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-c-martin committed Nov 19, 2024
1 parent 290c7e2 commit 63c6846
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function useAzure(props: UseAzureProps) {
userAgentOptions: {
userAgentPrefix: "bicepdeploypane",
},
endpoint: scope.armUrl,
});
}

Expand Down
1 change: 1 addition & 0 deletions src/vscode-bicep-ui/apps/deploy-pane/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import type { ErrorResponse } from "@azure/arm-resources";

type DeploymentScopeBase<T> = {
armUrl: string;
portalUrl: string;
tenantId: string;
} & T;
Expand Down
4 changes: 4 additions & 0 deletions src/vscode-bicep/src/azure/AzureUiManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class AzureUiManager implements IAzureUiManager {

return {
scopeType,
armUrl: subscription.environment.resourceManagerEndpointUrl,
portalUrl: subscription.environment.portalUrl,
tenantId: subscription.tenantId,
subscriptionId: subscription.subscriptionId,
Expand All @@ -36,6 +37,7 @@ export class AzureUiManager implements IAzureUiManager {
const location = await this.azurePickers.pickLocation(this.context, subscription);
return {
scopeType,
armUrl: subscription.environment.resourceManagerEndpointUrl,
portalUrl: subscription.environment.portalUrl,
tenantId: subscription.tenantId,
subscriptionId: subscription.subscriptionId,
Expand All @@ -50,6 +52,7 @@ export class AzureUiManager implements IAzureUiManager {

return {
scopeType,
armUrl: subscription.environment.resourceManagerEndpointUrl,
portalUrl: subscription.environment.portalUrl,
tenantId: subscription.tenantId,
managementGroup: nonNullProp(managementGroup, "name"),
Expand All @@ -64,6 +67,7 @@ export class AzureUiManager implements IAzureUiManager {

return {
scopeType,
armUrl: subscription.environment.resourceManagerEndpointUrl,
portalUrl: subscription.environment.portalUrl,
tenantId: subscription.tenantId,
associatedSubscriptionId: subscription.subscriptionId,
Expand Down
1 change: 1 addition & 0 deletions src/vscode-bicep/src/azure/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { AccessToken } from "@azure/identity";

type DeploymentScopeBase<T> = {
armUrl: string;
portalUrl: string;
tenantId: string;
} & T;
Expand Down
10 changes: 9 additions & 1 deletion src/vscode-bicep/src/panes/deploy/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
import crypto from "crypto";
import path from "path";
import { Environment } from "@azure/ms-rest-azure-env";
import { callWithTelemetryAndErrorHandlingSync, IActionContext } from "@microsoft/vscode-azext-utils";
import fse from "fs-extra";
import vscode, { ExtensionContext } from "vscode";
Expand Down Expand Up @@ -251,6 +252,13 @@ export class DeployPaneView extends Disposable {
vscode.Uri.joinPath(this.extensionUri, "out", "deploy-pane", "assets", "index.css"),
);

const armEndpoints = [
Environment.AzureCloud,
Environment.ChinaCloud,
Environment.GermanCloud,
Environment.USGovernment,
].map(env => env.resourceManagerEndpointUrl);

return `
<!DOCTYPE html>
<html lang="en">
Expand All @@ -260,7 +268,7 @@ export class DeployPaneView extends Disposable {
Use a content security policy to only allow loading images from our extension directory,
and only allow scripts that have a specific nonce.
-->
<meta http-equiv="Content-Security-Policy" content="default-src 'self' https://management.azure.com; style-src ${cspSource} 'unsafe-inline'; img-src ${cspSource} data:; script-src 'nonce-${nonce}' vscode-webview-resource:; font-src data: ${cspSource};">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' ${armEndpoints.join(' ')}; style-src ${cspSource} 'unsafe-inline'; img-src ${cspSource} data:; script-src 'nonce-${nonce}' vscode-webview-resource:; font-src data: ${cspSource};">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link id="vscode-codicon-stylesheet" rel="stylesheet" nonce="${nonce}" href="${codiconCssUri}">
</head>
Expand Down

0 comments on commit 63c6846

Please sign in to comment.