-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use iam client library to setup test #1173
Conversation
package.json
Outdated
@@ -23,6 +23,8 @@ | |||
"fast-text-encoding": "^1.0.0", | |||
"gaxios": "^4.0.0", | |||
"gcp-metadata": "^4.2.0", | |||
"google-auth-library": "^7.0.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are just being used in samples, you would need to add them to samples/package.json
. There should already be a reference to google-auth-library
there, since it gets linked in as part of the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1.
You just need to add the additional dependency, e.g. googleapis
which can probably go here:
"google-auth-library": "^7.1.0", |
// changes. | ||
// https://cloud.google.com/iam/docs/reference/rest/v1beta/projects.locations.workloadIdentityPools | ||
// https://github.com/googleapis/google-api-nodejs-client/tree/master/src/apis/iam | ||
const authClient = await auth.getClient(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can skip this line entirely and say google.options({auth});
and it will work just the same :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
package.json
Outdated
@@ -23,6 +23,8 @@ | |||
"fast-text-encoding": "^1.0.0", | |||
"gaxios": "^4.0.0", | |||
"gcp-metadata": "^4.2.0", | |||
"google-auth-library": "^7.0.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1.
You just need to add the additional dependency, e.g. googleapis
which can probably go here:
"google-auth-library": "^7.1.0", |
policy: { | ||
bindings, | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of the lint errors can be fixed by running npm run fix
.
You can also see the list of errors by running npm run lint
. This is useful for the errors that require manual fixing.
// changes. | ||
// https://cloud.google.com/iam/docs/reference/rest/v1beta/projects.locations.workloadIdentityPools | ||
// https://github.com/googleapis/google-api-nodejs-client/tree/master/src/apis/iam | ||
const authClient = await auth.getClient(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
}, | ||
response = await iam.projects.locations.workloadIdentityPools.create({ | ||
parent: `projects/${projectId}/locations/global`, | ||
workloadIdentityPoolId: poolId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a display name and description: https://github.com/googleapis/google-api-nodejs-client/blob/19bd611ca69f334b342565698a8ec8991e956580/src/apis/iam/v1.ts#L2412
This makes it easy to understand who created this pool (It will also work well in the Cloud Console UI).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from my end. Leaving it to repo owners for the final say.
@bcoe this is one of the action items from when we added the integration tests before launch. Your input is highly appreciated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit, regarding using the IAM library directly. I appreciate this refactor.
samples/package.json
Outdated
@@ -14,6 +14,7 @@ | |||
"license": "Apache-2.0", | |||
"dependencies": { | |||
"google-auth-library": "^7.1.0", | |||
"googleapis": "^73.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could I get you to try out https://www.npmjs.com/package/@googleapis/iam, I love to stress test our individual modules, and it should improve install size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your feedback. In externalclient-setup.js, I still need to set auth with import from googleapis:
google.options({auth});
I am not able to setup the auth if only install @googleapis/iam
for this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't this work?
const Iam = require('@googleapis/iam')
const iam = await iam.iam({
version: 'v1',
auth
});
const response = await iam.projects.locations.workloadIdentityPools.create({});
You can pass auth to the client itself, it doesn't need to be configured globally (perhaps I'm missing the issue though.).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is working. Thank you.
🤖 I have created a release \*beep\* \*boop\* --- ### [7.1.2](https://github.com/googleapis/google-auth-library-nodejs/compare/v7.1.1...v7.1.2) (2021-06-10) ### Bug Fixes * use iam client library to setup test ([#1173](https://github.com/googleapis/google-auth-library-nodejs/issues/1173)) ([74ac5db](https://github.com/googleapis/google-auth-library-nodejs/commit/74ac5db59f9eff8fa4f3bdb6acc0647a1a4f491f)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This PR is for implementing using IAM client library for setting up externalClient tests, without making any changes to
current tests.
The bug could be tracked from b/185501294.
@bojeil-google