This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
generated from JupiterOne-Archives/integration-template
-
Notifications
You must be signed in to change notification settings - Fork 13
fix(INT-6744): add debug log if timeout error #576
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,7 +1,7 @@ | ||||||||||||||
import { cloudbuild_v1, google } from 'googleapis'; | ||||||||||||||
import { Client } from '../../google-cloud/client'; | ||||||||||||||
import { IntegrationStepContext } from '../../types'; | ||||||||||||||
import { CloudBuildLocations } from './constants'; | ||||||||||||||
import { CloudBuildEntitiesSpec, CloudBuildLocations } from './constants'; | ||||||||||||||
|
||||||||||||||
export class CloudBuildClient extends Client { | ||||||||||||||
private client = google.cloudbuild({ version: 'v1' }); | ||||||||||||||
|
@@ -129,29 +129,41 @@ export class CloudBuildClient extends Client { | |||||||||||||
|
||||||||||||||
async iterateBuildBitbucketRepositories( | ||||||||||||||
serverConfig: cloudbuild_v1.Schema$BitbucketServerConfig, | ||||||||||||||
context: IntegrationStepContext, | ||||||||||||||
callback: ( | ||||||||||||||
data: cloudbuild_v1.Schema$BitbucketServerRepository, | ||||||||||||||
) => Promise<void>, | ||||||||||||||
): Promise<void> { | ||||||||||||||
const auth = await this.getAuthenticatedServiceClient(); | ||||||||||||||
|
||||||||||||||
await this.iterateApi( | ||||||||||||||
(nextPageToken) => { | ||||||||||||||
return this.client.projects.locations.bitbucketServerConfigs.repos.list( | ||||||||||||||
{ | ||||||||||||||
auth, | ||||||||||||||
pageToken: nextPageToken, | ||||||||||||||
parent: serverConfig.name!, | ||||||||||||||
}, | ||||||||||||||
try { | ||||||||||||||
await this.iterateApi( | ||||||||||||||
(nextPageToken) => { | ||||||||||||||
return this.client.projects.locations.bitbucketServerConfigs.repos.list( | ||||||||||||||
{ | ||||||||||||||
auth, | ||||||||||||||
pageToken: nextPageToken, | ||||||||||||||
parent: serverConfig.name!, | ||||||||||||||
}, | ||||||||||||||
); | ||||||||||||||
}, | ||||||||||||||
async ( | ||||||||||||||
data: cloudbuild_v1.Schema$ListBitbucketServerRepositoriesResponse, | ||||||||||||||
) => { | ||||||||||||||
for (const config of data.bitbucketServerRepositories || []) { | ||||||||||||||
await callback(config); | ||||||||||||||
} | ||||||||||||||
}, | ||||||||||||||
); | ||||||||||||||
} catch (err) { | ||||||||||||||
if (err.code === 'ATTEMPT_TIMEOUT') { | ||||||||||||||
context.logger.warn( | ||||||||||||||
{ err }, | ||||||||||||||
`${CloudBuildEntitiesSpec.BUILD_BITBUCKET_SERVER_CONFIG._type} - Unable to fetch BitBucket repositories. This might be caused by expired credentials in the GCP console (Cloud Build).`, | ||||||||||||||
); | ||||||||||||||
}, | ||||||||||||||
async ( | ||||||||||||||
data: cloudbuild_v1.Schema$ListBitbucketServerRepositoriesResponse, | ||||||||||||||
) => { | ||||||||||||||
for (const config of data.bitbucketServerRepositories || []) { | ||||||||||||||
await callback(config); | ||||||||||||||
} | ||||||||||||||
}, | ||||||||||||||
); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
throw err; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest the following so that the step does not fail if
Suggested change
|
||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The name of the variable is
CloudBuildEntitiesSpec
but actually comes from a constants file