-
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.
- Loading branch information
1 parent
5b7afad
commit 056244a
Showing
9 changed files
with
10,935 additions
and
13,767 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { ProgressLocation, window } from "vscode"; | ||
import { IActionContext } from 'vscode-azureextensionui'; | ||
import * as Constants from '../../constants'; | ||
import { ServiceTreeItem } from '../../explorer/ServiceTreeItem'; | ||
import { ext } from '../../extensionVariables'; | ||
import { localize } from '../../localize'; | ||
import { ApiOpsTooling} from "../../utils/ApiOpsTooling"; | ||
import { azUtils } from '../../utils/azUtils'; | ||
import { cpUtils } from '../../utils/cpUtils'; | ||
import { ExtensionHelper } from "../../utils/ExtensionHelper"; | ||
import { askFolder } from '../../utils/vscodeUtils'; | ||
|
||
export async function importService(context: IActionContext, node?: ServiceTreeItem): Promise<void> { | ||
if (!node) { | ||
node = <ServiceTreeItem>await ext.tree.showTreeItemPicker(ServiceTreeItem.contextValue, context); | ||
} | ||
|
||
const uri = await askFolder("Import"); | ||
const sourceApimName = node.root.serviceName; | ||
const resourceGroup = node.root.resourceGroupName; | ||
const subscriptionId = node.root.subscriptionId; | ||
|
||
const noticeContent = localize("Publish", `Publishing '${uri}' to '${sourceApimName}' service.`); | ||
|
||
window.withProgress( | ||
{ | ||
location: ProgressLocation.Notification, | ||
title: localize("Extracting", noticeContent), | ||
cancellable: false | ||
}, | ||
async () => { | ||
await azUtils.checkAzInstalled(); | ||
await runPublisher(uri.fsPath, sourceApimName, resourceGroup, subscriptionId); | ||
} | ||
).then( | ||
() => { | ||
window.showInformationMessage(localize("Published", `Publish completed!`)); | ||
}); | ||
} | ||
|
||
async function runPublisher(filePath: string, apimName: string, resourceGroupName: string, subscriptionId: string): Promise<void> { | ||
ext.outputChannel.show(); | ||
|
||
// Check our APIOps tooling has been downloaded | ||
const downloader = new ApiOpsTooling(ext.context, new ExtensionHelper()); | ||
await downloader.downloadGitHubReleaseIfMissing(Constants.publisherBinaryName); | ||
|
||
await azUtils.setSubscription(subscriptionId, ext.outputChannel); | ||
|
||
// It's not on the PATH so you need ./ | ||
await cpUtils.executeCommand( | ||
ext.outputChannel, | ||
await downloader.getDownloadStoragePath(), | ||
`./${Constants.publisherBinaryName}`, | ||
`AZURE_SUBSCRIPTION_ID=${subscriptionId}`, | ||
`API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH=${filePath}`, | ||
`API_MANAGEMENT_SERVICE_NAME=${apimName}`, | ||
`AZURE_RESOURCE_GROUP_NAME=${resourceGroupName}` | ||
); | ||
} |
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
Oops, something went wrong.