Skip to content

Commit 5185ce3

Browse files
committed
Merge pull request #890 from stephenplusplus/spp--update-gce-images
compute: update gce-images to re-use auth client
2 parents 5152771 + d410f1c commit 5185ce3

File tree

5 files changed

+14
-22
lines changed

5 files changed

+14
-22
lines changed

lib/compute/index.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,13 @@ function Compute(options) {
110110
return new Compute(options);
111111
}
112112

113-
var authConfig = {
113+
this.makeAuthenticatedRequest_ = util.makeAuthenticatedRequestFactory({
114114
credentials: options.credentials,
115115
keyFile: options.keyFilename,
116116
scopes: SCOPES,
117117
email: options.email
118-
};
119-
120-
// We store the authConfig for use with gceImages in Zone.
121-
this.authConfig = authConfig;
118+
});
122119

123-
this.makeAuthenticatedRequest_ =
124-
util.makeAuthenticatedRequestFactory(authConfig);
125120
this.projectId = options.projectId;
126121
}
127122

lib/compute/zone.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ function Zone(compute, name) {
8484
this.name = name;
8585
this.metadata = {};
8686

87-
this.gceImages = gceImages(compute.authConfig);
87+
this.gceImages = gceImages({
88+
authClient: compute.makeAuthenticatedRequest_.authClient
89+
});
8890
}
8991

9092
/**

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"dns-zonefile": "0.1.10",
9090
"duplexify": "^3.2.0",
9191
"extend": "^3.0.0",
92-
"gce-images": "^0.1.0",
92+
"gce-images": "^0.2.0",
9393
"gcs-resumable-upload": "^0.2.1",
9494
"google-auto-auth": "^0.2.0",
9595
"hash-stream-validation": "^0.1.0",

test/compute/index.js

-11
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,6 @@ describe('Compute', function() {
144144
fakeUtil.normalizeArguments = normalizeArguments;
145145
});
146146

147-
it('should localize authConfig', function() {
148-
var compute = new Compute(options);
149-
150-
assert.deepEqual(compute.authConfig, {
151-
credentials: options.credentials,
152-
keyFile: options.keyFilename,
153-
email: options.email,
154-
scopes: ['https://www.googleapis.com/auth/compute']
155-
});
156-
});
157-
158147
it('should create a makeAuthenticatedRequest method', function(done) {
159148
fakeUtil.makeAuthenticatedRequestFactory = function(options_) {
160149
assert.deepEqual(options_, {

test/compute/zone.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ describe('Zone', function() {
6060
var zone;
6161

6262
var COMPUTE = {
63-
authConfig: { a: 'b', c: 'd' }
63+
makeAuthenticatedRequest_: {
64+
authClient: {
65+
a: 'b',
66+
c: 'd'
67+
}
68+
}
6469
};
6570
var ZONE_NAME = 'us-central1-a';
6671

@@ -111,7 +116,8 @@ describe('Zone', function() {
111116
var gceVal = 'ok';
112117

113118
gceImagesOverride = function(authConfig) {
114-
assert.strictEqual(authConfig, COMPUTE.authConfig);
119+
var expectedAuthClient = COMPUTE.makeAuthenticatedRequest_.authClient;
120+
assert.strictEqual(authConfig.authClient, expectedAuthClient);
115121
return gceVal;
116122
};
117123

0 commit comments

Comments
 (0)