Skip to content

Commit

Permalink
Dandua98/cosmos arm (#116)
Browse files Browse the repository at this point in the history
* added cosmos arm deployment

* added fix for comments

* fixed undefined syntax and added comments

* change array<object> to Object[]

* change attemptCosmos in controller to processCosmos
  • Loading branch information
dandua98 committed Mar 15, 2019
1 parent b6a0e6f commit ea363cf
Show file tree
Hide file tree
Showing 11 changed files with 353 additions and 96 deletions.
Empty file added dist/.gitkeep
Empty file.
10 changes: 4 additions & 6 deletions src/extension/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"eg2.tslint"
]
}
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": ["eg2.tslint"]
}
53 changes: 24 additions & 29 deletions src/extension/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,28 @@
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: watch"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "npm: watch"
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "npm: watch"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test"
],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"preLaunchTask": "npm: watch"
}
]
}
18 changes: 9 additions & 9 deletions src/extension/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
32 changes: 16 additions & 16 deletions src/extension/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
18 changes: 18 additions & 0 deletions src/extension/src/azure-arm/armFileHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as fsx from "fs-extra";

export namespace ARMFileHelper {
export function createOrOverwriteDir(dirPath: string): void {
if (fsx.pathExistsSync(dirPath)) {
fsx.removeSync(dirPath);
}

fsx.mkdirpSync(dirPath);
}

export function writeObjectToJsonFile(
filePath: string,
object: object
): void {
fsx.writeFileSync(filePath, JSON.stringify(object, null, 2), "utf-8");
}
}
48 changes: 48 additions & 0 deletions src/extension/src/azure-arm/resourceManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import ResourceManagementClient from "azure-arm-resource/lib/resource/resourceManagementClient";
import { SubscriptionItem } from "../azure-auth/azureAuth";
import { ServiceClientCredentials } from "ms-rest";
import { SubscriptionError } from "../errors";

export class ResourceManager {
private AzureResourceManagementClient: ResourceManagementClient | undefined;

private setClientState(userSubscriptionItem: SubscriptionItem): void {
if (
this.AzureResourceManagementClient === undefined ||
this.AzureResourceManagementClient.subscriptionId !==
userSubscriptionItem.subscriptionId
) {
this.AzureResourceManagementClient = this.createResourceManagementClient(
userSubscriptionItem
);
}
}

private createResourceManagementClient(
userSubscriptionItem: SubscriptionItem
): ResourceManagementClient {
let userCredentials: ServiceClientCredentials =
userSubscriptionItem.session.credentials;
if (
userSubscriptionItem === undefined ||
userSubscriptionItem.subscription === undefined ||
userSubscriptionItem.subscriptionId === undefined
) {
throw new SubscriptionError(
"SubscriptionItem cannot have undefined values"
);
}
return new ResourceManagementClient(
userCredentials,
userSubscriptionItem.subscriptionId,
userSubscriptionItem.session.environment.resourceManagerEndpointUrl
);
}

public getResourceManagementClient(
userSubscriptionItem: SubscriptionItem
): ResourceManagementClient {
this.setClientState(userSubscriptionItem);
return this.AzureResourceManagementClient!;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {}
}
55 changes: 55 additions & 0 deletions src/extension/src/azure-cosmosDB/arm-templates/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string"
},
"location": {
"type": "string"
},
"locationName": {
"type": "string"
},
"defaultExperience": {
"type": "string"
},
"capabilities": {
"type": "array"
},
"kind": {
"type": "string"
}
},
"variables": {},
"resources": [
{
"apiVersion": "2015-04-08",
"kind": "[parameters('kind')]",
"type": "Microsoft.DocumentDb/databaseAccounts",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"properties": {
"databaseAccountOfferType": "Standard",
"locations": [
{
"id": "[concat(parameters('name'), '-', parameters('location'))]",
"failoverPriority": 0,
"locationName": "[parameters('locationName')]"
}
],
"enableMultipleWriteLocations": true,
"isVirtualNetworkFilterEnabled": false,
"virtualNetworkRules": [],
"ipRangeFilter": "",
"dependsOn": [],
"capabilities": "[parameters('capabilities')]"
},
"tags": {
"defaultExperience": "[parameters('defaultExperience')]",
"generatedBy": "Web Template Studio"
}
}
],
"outputs": {}
}

0 comments on commit ea363cf

Please sign in to comment.