Skip to content

Commit 6efdd85

Browse files
committed
[minor] Style compliance for pkgcloud#99.
1 parent 29c0c2e commit 6efdd85

4 files changed

Lines changed: 179 additions & 184 deletions

File tree

lib/pkgcloud/amazon/compute/client/groups.js

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,50 @@ var errs = require('errs'),
77
utile = require('utile');
88

99
//
10-
// ### function listGroups (options, callback)
10+
// ### function listGroups (options, callback)
1111
// #### @options {Object} **Optional** Filter parameters when listing keys
1212
// #### @callback {function} Continuation to respond to when complete.
13-
//
14-
// Lists all EC2 SecurityGroups matching the specified `options`.
13+
//
14+
// Lists all EC2 SecurityGroups matching the specified `options`.
1515
//
1616
exports.listGroups = function (options, callback) {
1717
if (!callback && typeof options === 'function') {
1818
callback = options;
19-
options = {}
19+
options = {};
2020
}
21-
21+
2222
var self = this;
23-
2423
options = options || {};
25-
24+
2625
return this.query('DescribeSecurityGroups', options, callback, function (body, res) {
2726
callback(null, self._toArray(body.securityGroupInfo.item));
2827
});
2928
};
3029

3130
//
32-
// ### function getGroup (name, callback)
31+
// ### function getGroup (name, callback)
3332
// #### @name {string} Name of the EC2 Security Group to get
3433
// #### @callback {function} Continuation to respond to when complete.
35-
//
34+
//
3635
// Gets the details of the EC2 SecurityGroup with the specified `name`.
3736
//
3837
exports.getGroup = function (name, callback) {
3938
return this.listGroups({
4039
'GroupName.1': name
4140
}, function (err, body) {
42-
return err
41+
return err
4342
? callback(err)
4443
: callback(null, body[0]);
4544
});
4645
};
4746

4847
//
49-
// ### function addGroup (options, callback)
48+
// ### function addGroup (options, callback)
5049
// #### @options {Object} Security Group details
5150
// #### @name {string} String name of the group
5251
// #### @description {string} Description of the group
5352
// #### @callback {function} Continuation to respond to when complete.
54-
//
53+
//
5554
// Adds an EC2 SecurityGroup with the specified `options`.
5655
//
5756
exports.addGroup = function (options, callback) {
@@ -61,9 +60,9 @@ exports.addGroup = function (options, callback) {
6160
callback
6261
);
6362
}
64-
63+
6564
return this.query(
66-
'CreateSecurityGroup',
65+
'CreateSecurityGroup',
6766
{
6867
GroupName: options.name,
6968
GroupDescription: options.description
@@ -76,17 +75,17 @@ exports.addGroup = function (options, callback) {
7675
};
7776

7877
//
79-
// ### function delGroup (name, callback)
78+
// ### function delGroup (name, callback)
8079
// #### @name {string} Name of the EC2 Security Group to destroy
8180
// #### @callback {function} Continuation to respond to when complete.
82-
//
81+
//
8382
// Destroys EC2 SecurityGroup with the specified `name`.
8483
//
8584
exports.destroyGroup = function (name, callback) {
8685
return this.query(
87-
'DeleteSecurityGroup',
88-
{ GroupName: name },
89-
callback,
86+
'DeleteSecurityGroup',
87+
{ GroupName: name },
88+
callback,
9089
function (body, res) {
9190
return callback(null, true);
9291
}
@@ -100,7 +99,7 @@ exports.destroyGroup = function (name, callback) {
10099
// #### @rules {object} Ingress rules to apply
101100
// #### @callback {function} Continuation to respond to when complete.
102101
//
103-
// Note: rules must match the format of the AWS API
102+
// Note: rules must match the format of the AWS API
104103
// - http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html
105104
//
106105
// Add Ingress Rules to a SecurityGroup with the specified `name`.
@@ -112,20 +111,20 @@ exports.addRules = function (options, callback) {
112111
callback
113112
);
114113
}
115-
114+
116115
// Simply append the group name to the rules - override if existing
117116
var rules = options.rules;
118117
rules.GroupName = options.name;
119-
118+
120119
return this.query(
121-
'AuthorizeSecurityGroupIngress',
120+
'AuthorizeSecurityGroupIngress',
122121
rules ,
123122
callback,
124123
function (body, res) {
125124
return callback(null, true);
126125
}
127126
);
128-
}
127+
};
129128

130129
//
131130
// ### function delRules (options, callback)
@@ -134,7 +133,7 @@ exports.addRules = function (options, callback) {
134133
// #### @rules {object} Ingress rules to revoke
135134
// #### @callback {function} Continuation to respond to when complete.
136135
//
137-
// Note: rules must match the format of the AWS API
136+
// Note: rules must match the format of the AWS API
138137
// - http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html
139138
//
140139
// Revoke Ingress Rules to a SecurityGroup with the specified `name`.
@@ -146,17 +145,17 @@ exports.delRules = function (options, callback) {
146145
callback
147146
);
148147
}
149-
148+
150149
// Simply append the group name to the rules - override if existing
151150
var rules = options.rules;
152151
rules.GroupName = options.name;
153-
152+
154153
return this.query(
155-
'RevokeSecurityGroupIngress',
154+
'RevokeSecurityGroupIngress',
156155
rules ,
157156
callback,
158157
function (body, res) {
159158
return callback(null, true);
160159
}
161160
);
162-
}
161+
};

lib/pkgcloud/amazon/compute/client/keys.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ exports.addKey = function (options, callback) {
7777
};
7878

7979
//
80-
// ### function destroyKey (name, callback)
80+
// ### function destroyKey (name, callback)
8181
// #### @name {string} Name of the EC2 key pair to destroy
8282
// #### @callback {function} Continuation to respond to when complete.
8383
//

test/amazon/compute/client/groups-test.js

Lines changed: 98 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -5,119 +5,117 @@ var assert = require('assert');
55
var client = helpers.createClient('amazon', 'compute');
66

77
// Tests
8-
var suite = vows.describe('[Amazon Client] SecurityGroup management');
9-
10-
suite.addBatch({
11-
'add SecurityGroup': {
12-
topic: function() {
13-
client.addGroup({
14-
name: 'unit test',
15-
description: 'unit test'
16-
}, this.callback)
17-
},
18-
'should succeed': function(err, data) {
19-
assert.isNull(err);
20-
assert.isTrue(data);
21-
}
8+
var suite = vows.describe('pkgcloud/amazon/groups').addBatch({
9+
'add SecurityGroup': {
10+
topic: function () {
11+
client.addGroup({
12+
name: 'unit test',
13+
description: 'unit test'
14+
}, this.callback)
2215
},
23-
'destroy SecurityGroup': {
24-
topic: function() {
25-
client.destroyGroup('unit test', this.callback);
26-
},
27-
'should succeed': function(err, data) {
28-
assert.isNull(err);
29-
assert.isTrue(data);
30-
}
16+
'should succeed': function (err, data) {
17+
assert.isNull(err);
18+
assert.isTrue(data);
19+
}
20+
},
21+
'destroy SecurityGroup': {
22+
topic: function () {
23+
client.destroyGroup('unit test', this.callback);
3124
},
32-
'list SecurityGroups': {
33-
topic: function() {
34-
client.listGroups(this.callback);
35-
},
36-
'should succeed': function(err, data) {
37-
assert.isNull(err);
38-
assert.isArray(data);
39-
}
25+
'should succeed': function (err, data) {
26+
assert.isNull(err);
27+
assert.isTrue(data);
28+
}
29+
},
30+
'list SecurityGroups': {
31+
topic: function () {
32+
client.listGroups(this.callback);
4033
},
41-
'get SecurityGroup': {
42-
topic: function() {
43-
client.getGroup('unit test', this.callback);
44-
},
45-
'should succeed': function(err, data) {
46-
assert.isNull(err);
47-
// TODO
48-
}
34+
'should succeed': function (err, data) {
35+
assert.isNull(err);
36+
assert.isArray(data);
37+
}
38+
},
39+
'get SecurityGroup': {
40+
topic: function () {
41+
client.getGroup('unit test', this.callback);
4942
},
50-
'add Rules': {
51-
topic: function() {
52-
client.addRules({
53-
name: 'unit test',
54-
rules: {
55-
'IpPermissions.1.IpProtocol': 'tcp',
56-
'IpPermissions.1.Groups.1.GroupName': 'unit test',
57-
'IpPermissions.1.FromPort': 0,
58-
'IpPermissions.1.ToPort': 65535
59-
}
60-
}, this.callback);
61-
},
62-
'should succeed': function(err, data) {
63-
assert.isNull(err);
64-
assert.isTrue(data);
43+
'should succeed': function (err, data) {
44+
assert.isNull(err);
45+
// TODO
46+
}
47+
},
48+
'add Rules': {
49+
topic: function () {
50+
client.addRules({
51+
name: 'unit test',
52+
rules: {
53+
'IpPermissions.1.IpProtocol': 'tcp',
54+
'IpPermissions.1.Groups.1.GroupName': 'unit test',
55+
'IpPermissions.1.FromPort': 0,
56+
'IpPermissions.1.ToPort': 65535
6557
}
58+
}, this.callback);
6659
},
67-
'destroy Rules': {
68-
topic: function() {
69-
client.delRules({
70-
name: 'unit test',
71-
rules: {
72-
'IpPermissions.1.IpProtocol': 'tcp',
73-
'IpPermissions.1.Groups.1.GroupName': 'unit test',
74-
'IpPermissions.1.FromPort': 0,
75-
'IpPermissions.1.ToPort': 65535
76-
}
77-
}, this.callback);
78-
},
79-
'should succeed': function(err, data) {
80-
assert.isNull(err);
81-
assert.isTrue(data);
60+
'should succeed': function (err, data) {
61+
assert.isNull(err);
62+
assert.isTrue(data);
63+
}
64+
},
65+
'destroy Rules': {
66+
topic: function () {
67+
client.delRules({
68+
name: 'unit test',
69+
rules: {
70+
'IpPermissions.1.IpProtocol': 'tcp',
71+
'IpPermissions.1.Groups.1.GroupName': 'unit test',
72+
'IpPermissions.1.FromPort': 0,
73+
'IpPermissions.1.ToPort': 65535
8274
}
75+
}, this.callback);
76+
},
77+
'should succeed': function (err, data) {
78+
assert.isNull(err);
79+
assert.isTrue(data);
8380
}
81+
}
8482
});
8583

8684

8785
// Mock API answers
8886
var nock = require('nock');
8987
nock('https://' + client.serversUrl)
90-
.filteringRequestBody(helpers.authFilter)
91-
.post('/?Action=CreateSecurityGroup', {
92-
GroupDescription: 'unit test',
93-
GroupName: 'unit test'
94-
})
95-
.reply(200, helpers.loadFixture('amazon/add-group.xml'), {})
96-
.post('/?Action=DeleteSecurityGroup', {
97-
GroupName: 'unit test'
98-
})
99-
.reply(200, helpers.loadFixture('amazon/destroy-group.xml', {}))
100-
.post('/?Action=DescribeSecurityGroups', {})
101-
.reply(200, helpers.loadFixture('amazon/list-groups.xml'), {})
102-
.post('/?Action=DescribeSecurityGroups', {
103-
'GroupName.1': 'unit test'
104-
})
105-
.reply(200, helpers.loadFixture('amazon/list-group.xml'), {})
106-
.post('/?Action=AuthorizeSecurityGroupIngress', {
107-
GroupName: 'unit test',
108-
'IpPermissions.1.FromPort': '0',
109-
'IpPermissions.1.Groups.1.GroupName': 'unit test',
110-
'IpPermissions.1.IpProtocol': 'tcp',
111-
'IpPermissions.1.ToPort': '65535'
112-
})
113-
.reply(200, helpers.loadFixture('amazon/add-rules.xml'), {})
114-
.post('/?Action=RevokeSecurityGroupIngress', {
115-
GroupName: 'unit test',
116-
'IpPermissions.1.FromPort': '0',
117-
'IpPermissions.1.Groups.1.GroupName': 'unit test',
118-
'IpPermissions.1.IpProtocol': 'tcp',
119-
'IpPermissions.1.ToPort': '65535'
120-
})
121-
.reply(200, helpers.loadFixture('amazon/destroy-rules.xml'), {})
88+
.filteringRequestBody(helpers.authFilter)
89+
.post('/?Action=CreateSecurityGroup', {
90+
GroupDescription: 'unit test',
91+
GroupName: 'unit test'
92+
})
93+
.reply(200, helpers.loadFixture('amazon/add-group.xml'), {})
94+
.post('/?Action=DeleteSecurityGroup', {
95+
GroupName: 'unit test'
96+
})
97+
.reply(200, helpers.loadFixture('amazon/destroy-group.xml', {}))
98+
.post('/?Action=DescribeSecurityGroups', {})
99+
.reply(200, helpers.loadFixture('amazon/list-groups.xml'), {})
100+
.post('/?Action=DescribeSecurityGroups', {
101+
'GroupName.1': 'unit test'
102+
})
103+
.reply(200, helpers.loadFixture('amazon/list-group.xml'), {})
104+
.post('/?Action=AuthorizeSecurityGroupIngress', {
105+
GroupName: 'unit test',
106+
'IpPermissions.1.FromPort': '0',
107+
'IpPermissions.1.Groups.1.GroupName': 'unit test',
108+
'IpPermissions.1.IpProtocol': 'tcp',
109+
'IpPermissions.1.ToPort': '65535'
110+
})
111+
.reply(200, helpers.loadFixture('amazon/add-rules.xml'), {})
112+
.post('/?Action=RevokeSecurityGroupIngress', {
113+
GroupName: 'unit test',
114+
'IpPermissions.1.FromPort': '0',
115+
'IpPermissions.1.Groups.1.GroupName': 'unit test',
116+
'IpPermissions.1.IpProtocol': 'tcp',
117+
'IpPermissions.1.ToPort': '65535'
118+
})
119+
.reply(200, helpers.loadFixture('amazon/destroy-rules.xml'), {})
122120

123121
suite.export(module);

0 commit comments

Comments
 (0)