How to use the gcp-metadata.HOST_ADDRESS function in gcp-metadata

To help you get started, we’ve selected a few gcp-metadata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ruslang02 / atomos / node_modules / google-auth-library / build / src / auth / computeclient.js View on Github external
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();
github googleapis / cloud-debug-nodejs / test / test-debuglet.ts View on Github external
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, {
github googleapis / cloud-debug-nodejs / test / nocks.ts View on Github external
export function metadataInstance(): nock.Scope {
  return nock(gcpMetadata.HOST_ADDRESS)
    .get('/computeMetadata/v1/instance')
    .replyWithError({code: 'ENOTFOUND', message: 'nocked request'});
}

gcp-metadata

Get the metadata from a Google Cloud Platform environment

Apache-2.0
Latest version published 6 months ago

Package Health Score

87 / 100
Full package analysis