Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dandua98/cosmos arm #116

Merged
merged 7 commits into from
Mar 15, 2019
Merged

Dandua98/cosmos arm #116

merged 7 commits into from
Mar 15, 2019

Conversation

dandua98
Copy link
Contributor

@dandua98 dandua98 commented Mar 12, 2019

WARNING: Don't review this PR until #115 is closed. This will reduce the number of changes shown

This PR introduces ARM templates for Cosmos and closes AB#24106

Testing Notes:

  • Run the extension as usual (./build followed by F5 in extension dir to run the extension) and deploy a cosmos resource through the wizard

Notes:

  • The comment errors in .vscode files are by vscode itself and not something introduced by the devs, this PR just linted everything since yarn format was ran

userSubscriptionItem.subscriptionId === undefined
) {
throw new SubscriptionError(
"SubscriptionItem cannot have undefined values"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix to move this to constants is in next PR

// See http://go.microsoft.com/fwlink/?LinkId=827846
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are by VSCode, not us

): ResourceManagementClient {
let userCredentials: ServiceClientCredentials =
userSubscriptionItem.session.credentials;
if (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is private method - you don't need to validate input. Instead you need to make sure that this method is called with correct parameters that are not null.

please remove line 27. And possibly entire "if" depends on if you explicitly want containment of the userSubscriptionItem.subscription(Id) to be validated in this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix for this is in next PR (#117) which uses this module too. I extended some functionality there so would rather address it there


public getResourceManagementClient(
userSubscriptionItem: SubscriptionItem
): ResourceManagementClient {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this one is public - check for null in the input parameters. If userSubscriptionItem is null -> don't call this.SetClientState. Instead either throw or whatever is expected result.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okey for now, but please keep in mind for the future that not everything can be carried to the future PR's. "Missing null-check" is buggy enough to be fixed within the same PR. State of your main branch can't be broken between PR's because you decided to fix your previous PR in the next PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a missing null-check. It can't be null anyway (can only be undefined) and we're checking for that instead

SahilTara
SahilTara previously approved these changes Mar 15, 2019
src/extension/src/azure-arm/resourceManager.ts Outdated Show resolved Hide resolved
{
"apiVersion": "2015-04-08",
"kind": "[parameters('kind')]",
"type": "Microsoft.DocumentDb/databaseAccounts",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be Microsoft.DocumentDB/databaseAccounts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this is not decided by me. It's the parameters Azure accepts

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.microsoft.com/en-us/azure/templates/Microsoft.DocumentDB/2015-04-08/databaseAccounts

Please fix this in the next PR since I realize you have conflicts.

src/extension/src/azure-cosmosDB/cosmosDbModule.ts Outdated Show resolved Hide resolved
src/extension/src/azure-cosmosDB/cosmosDbModule.ts Outdated Show resolved Hide resolved
};

try {
if (this.SubscriptionItemCosmosClient === undefined) {
throw new AuthorizationError("Cosmos Client cannot be undefined.");
}

let azureResourceClient: ResourceManagementClient = new ResourceManager().getResourceManagementClient(
userSubscriptionItem

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this defined?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean "userSubscriptionItem"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a parameter to the, I just modified what gets done in this function (modifying how cosmos is deployed internally) and not function and class itself

src/extension/src/controller.ts Outdated Show resolved Hide resolved
@dandua98 dandua98 requested a review from trevorNgo March 15, 2019 21:46
@dandua98 dandua98 merged commit ea363cf into dev Mar 15, 2019
@dandua98 dandua98 deleted the dandua98/cosmos-arm branch March 20, 2019 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants