Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
url = this.tokenUrl ||
"" + gcpMetadata.HOST_ADDRESS + Compute._GOOGLE_OAUTH2_TOKEN_URL;
res = null;
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
return [4 /*yield*/, ax.request({
url: url,
headers: (_a = {}, _a[gcpMetadata.HEADER_NAME] = 'Google', _a),
raxConfig: { noResponseRetries: 3, retry: 3, instance: ax }
})];
case 2:
// TODO: In 2.0, we should remove the ability to configure the tokenUrl,
// and switch this over to use the gcp-metadata package instead.
res = _b.sent();
return [3 /*break*/, 4];
case 3:
e_1 = _b.sent();
it('should attempt to retrieve cluster name if needed', done => {
const savedRunningOnGCP = Debuglet.runningOnGCP;
Debuglet.runningOnGCP = () => {
return Promise.resolve(true);
};
const clusterScope = nock(gcpMetadata.HOST_ADDRESS)
.get('/computeMetadata/v1/instance/attributes/cluster-name')
.once()
.reply(200, 'cluster-name-from-metadata');
const debug = new Debug(
{projectId: 'fake-project', credentials: fakeCredentials},
packageInfo
);
nocks.oauth2();
const config = debugletConfig();
const debuglet = new Debuglet(debug, config);
const scope = nock(config.apiUrl)
.post(REGISTER_PATH)
.reply(200, {
export function metadataInstance(): nock.Scope {
return nock(gcpMetadata.HOST_ADDRESS)
.get('/computeMetadata/v1/instance')
.replyWithError({code: 'ENOTFOUND', message: 'nocked request'});
}