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

Commit

Permalink
Update dependency gcp-metadata to v1 (#346)
Browse files Browse the repository at this point in the history
* Update dependency gcp-metadata to v1

* fix nocks path
  • Loading branch information
renovate[bot] authored and mayurkale22 committed Mar 16, 2019
1 parent 8b80a65 commit 1dae581
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 20 deletions.
12 changes: 7 additions & 5 deletions packages/opencensus-exporter-stackdriver/test/nocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const HEADERS = {
['metadata-flavor']: 'Google'
};

const HOST_ADDRESS = 'http://metadata.google.internal.';

export function oauth2<T extends {} = {}>(validator?: (body: T) => boolean):
nock.Scope {
validator = validator || accept;
Expand All @@ -43,15 +45,15 @@ export function projectId(status: number|(() => string), reply?: () => string) {
reply = status;
status = 200;
}
return nock('http://metadata.google.internal')
return nock(HOST_ADDRESS)
.get('/computeMetadata/v1/project/project-id')
.once()
.reply(status, reply, {'Metadata-Flavor': 'Google'});
}

export function noDetectResource() {
const scopes = [
nock('http://metadata.google.internal')
nock(HOST_ADDRESS)
.get('/computeMetadata/v1/instance')
.once()
.replyWithError({code: 'ENOTFOUND'}),
Expand All @@ -63,7 +65,7 @@ export function noDetectResource() {
}

export function detectGceResource() {
return nock('http://metadata.google.internal')
return nock(HOST_ADDRESS)
.get('/computeMetadata/v1/instance')
.reply(200, {}, HEADERS)
.get('/computeMetadata/v1/project/project-id')
Expand All @@ -80,7 +82,7 @@ export function instanceId(
reply = status;
status = 200;
}
return nock('http://metadata.google.internal')
return nock(HOST_ADDRESS)
.get('/computeMetadata/v1/instance/id')
.once()
.reply(status, reply, {'Metadata-Flavor': 'Google'});
Expand All @@ -91,7 +93,7 @@ export function hostname(status: number|(() => string), reply?: () => string) {
reply = status;
status = 200;
}
return nock('http://metadata.google.internal')
return nock(HOST_ADDRESS)
.get('/computeMetadata/v1/instance/hostname')
.once()
.reply(status, reply, {'Metadata-Flavor': 'Google'});
Expand Down
49 changes: 35 additions & 14 deletions packages/opencensus-resource-util/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/opencensus-resource-util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
},
"dependencies": {
"@opencensus/core": "^0.0.9",
"gcp-metadata": "^0.9.3"
"gcp-metadata": "^1.0.0"
}
}

0 comments on commit 1dae581

Please sign in to comment.