Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2784 from amarzavery/fixes
Browse files Browse the repository at this point in the history
fixes #2155 and #2785
  • Loading branch information
amarzavery committed Apr 21, 2016
2 parents da0f60d + 8123fdd commit ef104f2
Show file tree
Hide file tree
Showing 15 changed files with 771 additions and 1,191 deletions.
5 changes: 3 additions & 2 deletions lib/cli.js
Expand Up @@ -533,8 +533,9 @@ _.extend(AzureCli.prototype, {
}

if (!cat) {
var toBlame = (i>2) ? args[i-1] : category;
log.error('\'' + toBlame + '\' is not an azure command. See \'azure help\'.');
var toBlame = (i > 2) ? args[i - 1] : category;
var msg = '\'' + toBlame + '\' is not an azure command. See \'azure help\'.';
this.exit('error', msg, 1);
} else {
//if we are here, then it is about display help.
command.categoryHelpInformation.apply(cat,[]);
Expand Down
17 changes: 13 additions & 4 deletions lib/commands/arm/group/group._js
Expand Up @@ -130,6 +130,7 @@ exports.init = function (cli) {
.description($('Deletes a resource group'))
.usage('[options] <name>')
.option('-n --name <name>', $('the resource group name'))
.option('--nowait', $('does not wait for the delete operation to complete. Returns as soon as the intial request is received by the server.'))
.option('-q, --quiet', $('quiet mode (do not ask for delete confirmation)'))
.option('--subscription <subscription>', $('the subscription identifier'))
.execute(function (name, options, _) {
Expand All @@ -140,10 +141,18 @@ exports.init = function (cli) {
var subscription = profile.current.getSubscription(options.subscription);
var client = utils.createResourceClient(subscription);
var progress = cli.interaction.progress(util.format($('Deleting resource group %s'), name));
try {
client.resourceGroups.deleteMethod(name, _);
} finally {
progress.end();
if (options.nowait) {
try {
client.resourceGroups.beginDeleteMethod(name, _);
} finally {
progress.end();
}
} else {
try {
client.resourceGroups.deleteMethod(name, _);
} finally {
progress.end();
}
}
});

Expand Down
8 changes: 8 additions & 0 deletions lib/plugins.arm.json
Expand Up @@ -33246,6 +33246,14 @@
"long": "--name",
"description": "the resource group name"
},
{
"flags": "--nowait",
"required": 0,
"optional": 0,
"bool": true,
"long": "--nowait",
"description": "does not wait for the delete operation to complete. Returns as soon as the intial request is received by the server."
},
{
"flags": "-q, --quiet",
"required": 0,
Expand Down
12 changes: 9 additions & 3 deletions test/commands/arm/group/arm.group-tests.js
Expand Up @@ -104,8 +104,14 @@ describe('arm', function () {
var results = JSON.parse(listResult.text);
results.length.should.be.above(0);

suite.execute('group delete %s --json --quiet', groupName, function () {
done();
suite.execute('group delete --nowait %s --json --quiet', groupName, function (deleteResult) {
deleteResult.exitStatus.should.equal(0);
suite.execute('group list --json', function(result){
result.exitStatus.should.equal(0);
var output = JSON.parse(result.text);
output.some(function (g) { return (g.name === groupName && g.location === normalizedTestLocation && g.properties.provisioningState === 'Deleting'); }).should.be.true;
done();
});
});
});
});
Expand Down Expand Up @@ -286,7 +292,7 @@ describe('arm', function () {
}

function cleanupForLogShow (done) {
suite.execute('group delete %s --json --quiet', groupName, function () {
suite.execute('group delete %s --nowait --json --quiet', groupName, function () {
console.log(' . Performing cleanup of group log show tests')
done();
});
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Expand Up @@ -6,13 +6,13 @@ exports.getMockedProfile = function () {
var newProfile = new profile.Profile();

newProfile.addSubscription(new profile.Subscription({
id: '00977cdb-163f-435f-9c32-39ec8ae61f4d',
name: 'node',
id: '3ca49042-782a-4cc9-89b5-ee1b487fe115',
name: 'AzSdkCore1',
user: {
name: 'user@domain.example',
type: 'user'
},
tenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47',
tenantId: '1449d5b7-8a83-47db-ae4c-9b03e888bad0',
state: 'Enabled',
registeredProviders: [],
_eventsCount: '1',
Expand All @@ -29,36 +29,36 @@ exports.setEnvironment = function() {
exports.scopes = [[function (nock) {
var result =
nock('http://management.azure.com:443')
.get('/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d/resourcegroups/xDeploymentTestGroup8112/providers/Microsoft.Resources/deployments/random_deployment_name?api-version=2016-02-01')
.get('/subscriptions/3ca49042-782a-4cc9-89b5-ee1b487fe115/resourcegroups/xDeploymentTestGroup8771/providers/Microsoft.Resources/deployments/random_deployment_name?api-version=2016-02-01')
.reply(404, "{\"error\":{\"code\":\"DeploymentNotFound\",\"message\":\"Deployment 'random_deployment_name' could not be found.\"}}", { 'cache-control': 'no-cache',
pragma: 'no-cache',
'content-type': 'application/json; charset=utf-8',
expires: '-1',
'x-ms-failure-cause': 'gateway',
'x-ms-ratelimit-remaining-subscription-reads': '14997',
'x-ms-request-id': '0d48275f-ee24-4f20-8009-b099e23463b5',
'x-ms-correlation-request-id': '0d48275f-ee24-4f20-8009-b099e23463b5',
'x-ms-routing-request-id': 'WESTUS:20160130T204522Z:0d48275f-ee24-4f20-8009-b099e23463b5',
'x-ms-ratelimit-remaining-subscription-reads': '14998',
'x-ms-request-id': '43631144-d911-45dc-b884-f56be177229c',
'x-ms-correlation-request-id': '43631144-d911-45dc-b884-f56be177229c',
'x-ms-routing-request-id': 'CENTRALUS:20160421T032944Z:43631144-d911-45dc-b884-f56be177229c',
'strict-transport-security': 'max-age=31536000; includeSubDomains',
date: 'Sat, 30 Jan 2016 20:45:22 GMT',
date: 'Thu, 21 Apr 2016 03:29:44 GMT',
connection: 'close',
'content-length': '107' });
return result; },
function (nock) {
var result =
nock('https://management.azure.com:443')
.get('/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d/resourcegroups/xDeploymentTestGroup8112/providers/Microsoft.Resources/deployments/random_deployment_name?api-version=2016-02-01')
.get('/subscriptions/3ca49042-782a-4cc9-89b5-ee1b487fe115/resourcegroups/xDeploymentTestGroup8771/providers/Microsoft.Resources/deployments/random_deployment_name?api-version=2016-02-01')
.reply(404, "{\"error\":{\"code\":\"DeploymentNotFound\",\"message\":\"Deployment 'random_deployment_name' could not be found.\"}}", { 'cache-control': 'no-cache',
pragma: 'no-cache',
'content-type': 'application/json; charset=utf-8',
expires: '-1',
'x-ms-failure-cause': 'gateway',
'x-ms-ratelimit-remaining-subscription-reads': '14997',
'x-ms-request-id': '0d48275f-ee24-4f20-8009-b099e23463b5',
'x-ms-correlation-request-id': '0d48275f-ee24-4f20-8009-b099e23463b5',
'x-ms-routing-request-id': 'WESTUS:20160130T204522Z:0d48275f-ee24-4f20-8009-b099e23463b5',
'x-ms-ratelimit-remaining-subscription-reads': '14998',
'x-ms-request-id': '43631144-d911-45dc-b884-f56be177229c',
'x-ms-correlation-request-id': '43631144-d911-45dc-b884-f56be177229c',
'x-ms-routing-request-id': 'CENTRALUS:20160421T032944Z:43631144-d911-45dc-b884-f56be177229c',
'strict-transport-security': 'max-age=31536000; includeSubDomains',
date: 'Sat, 30 Jan 2016 20:45:22 GMT',
date: 'Thu, 21 Apr 2016 03:29:44 GMT',
connection: 'close',
'content-length': '107' });
return result; }]];
Expand Up @@ -6,13 +6,13 @@ exports.getMockedProfile = function () {
var newProfile = new profile.Profile();

newProfile.addSubscription(new profile.Subscription({
id: '00977cdb-163f-435f-9c32-39ec8ae61f4d',
name: 'node',
id: '3ca49042-782a-4cc9-89b5-ee1b487fe115',
name: 'AzSdkCore1',
user: {
name: 'user@domain.example',
type: 'user'
},
tenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47',
tenantId: '1449d5b7-8a83-47db-ae4c-9b03e888bad0',
state: 'Enabled',
registeredProviders: [],
_eventsCount: '1',
Expand All @@ -29,36 +29,36 @@ exports.setEnvironment = function() {
exports.scopes = [[function (nock) {
var result =
nock('http://management.azure.com:443')
.get('/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d/resourcegroups/random_group_name/providers/Microsoft.Resources/deployments/?$top=1&api-version=2016-02-01')
.get('/subscriptions/3ca49042-782a-4cc9-89b5-ee1b487fe115/resourcegroups/random_group_name/providers/Microsoft.Resources/deployments/?$top=1&api-version=2016-02-01')
.reply(404, "{\"error\":{\"code\":\"ResourceGroupNotFound\",\"message\":\"Resource group 'random_group_name' could not be found.\"}}", { 'cache-control': 'no-cache',
pragma: 'no-cache',
'content-type': 'application/json; charset=utf-8',
expires: '-1',
'x-ms-failure-cause': 'gateway',
'x-ms-ratelimit-remaining-subscription-reads': '14992',
'x-ms-request-id': 'ea1218ee-19ae-4d81-b0f8-f3370e4548d2',
'x-ms-correlation-request-id': 'ea1218ee-19ae-4d81-b0f8-f3370e4548d2',
'x-ms-routing-request-id': 'WESTUS:20160130T204522Z:ea1218ee-19ae-4d81-b0f8-f3370e4548d2',
'x-ms-ratelimit-remaining-subscription-reads': '14999',
'x-ms-request-id': 'f4a5817d-78f4-4781-af8c-2f2ffa88bca4',
'x-ms-correlation-request-id': 'f4a5817d-78f4-4781-af8c-2f2ffa88bca4',
'x-ms-routing-request-id': 'CENTRALUS:20160421T032943Z:f4a5817d-78f4-4781-af8c-2f2ffa88bca4',
'strict-transport-security': 'max-age=31536000; includeSubDomains',
date: 'Sat, 30 Jan 2016 20:45:21 GMT',
date: 'Thu, 21 Apr 2016 03:29:43 GMT',
connection: 'close',
'content-length': '109' });
return result; },
function (nock) {
var result =
nock('https://management.azure.com:443')
.get('/subscriptions/00977cdb-163f-435f-9c32-39ec8ae61f4d/resourcegroups/random_group_name/providers/Microsoft.Resources/deployments/?$top=1&api-version=2016-02-01')
.get('/subscriptions/3ca49042-782a-4cc9-89b5-ee1b487fe115/resourcegroups/random_group_name/providers/Microsoft.Resources/deployments/?$top=1&api-version=2016-02-01')
.reply(404, "{\"error\":{\"code\":\"ResourceGroupNotFound\",\"message\":\"Resource group 'random_group_name' could not be found.\"}}", { 'cache-control': 'no-cache',
pragma: 'no-cache',
'content-type': 'application/json; charset=utf-8',
expires: '-1',
'x-ms-failure-cause': 'gateway',
'x-ms-ratelimit-remaining-subscription-reads': '14992',
'x-ms-request-id': 'ea1218ee-19ae-4d81-b0f8-f3370e4548d2',
'x-ms-correlation-request-id': 'ea1218ee-19ae-4d81-b0f8-f3370e4548d2',
'x-ms-routing-request-id': 'WESTUS:20160130T204522Z:ea1218ee-19ae-4d81-b0f8-f3370e4548d2',
'x-ms-ratelimit-remaining-subscription-reads': '14999',
'x-ms-request-id': 'f4a5817d-78f4-4781-af8c-2f2ffa88bca4',
'x-ms-correlation-request-id': 'f4a5817d-78f4-4781-af8c-2f2ffa88bca4',
'x-ms-routing-request-id': 'CENTRALUS:20160421T032943Z:f4a5817d-78f4-4781-af8c-2f2ffa88bca4',
'strict-transport-security': 'max-age=31536000; includeSubDomains',
date: 'Sat, 30 Jan 2016 20:45:21 GMT',
date: 'Thu, 21 Apr 2016 03:29:43 GMT',
connection: 'close',
'content-length': '109' });
return result; }]];

Large diffs are not rendered by default.

0 comments on commit ef104f2

Please sign in to comment.