Skip to content

Commit c39093a

Browse files
committed
feat: collect provider errors
1 parent 7bc70eb commit c39093a

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"terraform:cleanup": "rimraf ./tests/terraform/{.terraform,.terraform.lock.hcl,tfplan} ./tests/terraform/*.{tfstate,tfplan,backup}"
3232
},
3333
"dependencies": {
34-
"@cloudgraph/sdk": "0.22.1",
34+
"@cloudgraph/sdk": "0.23.0",
3535
"@google-cloud/access-approval": "^2.1.2",
3636
"@google-cloud/api-gateway": "^1.2.1",
3737
"@google-cloud/asset": "^3.22.0",
@@ -104,4 +104,4 @@
104104
"**/jsdoc": "^4.0.0",
105105
"**/uri-js": "^3.0.1"
106106
}
107-
}
107+
}

src/services/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import services from '../enums/services'
1818
import { GcpBilling, GcpCredentials, rawDataInterface } from '../types'
1919
import { DEFAULT_REGION, DEFAULT_RESOURCES } from '../config/constants'
2020
import relations from '../enums/relations'
21+
import { getAllProviderErrors } from '../utils'
2122

2223
export const enums = {
2324
services,
@@ -142,7 +143,8 @@ export default class Provider extends CloudGraph.Client {
142143
const { addBillingConfig } = await this.interface.prompt([
143144
{
144145
type: 'confirm',
145-
message: 'Do you want to configure export cloud Billing data to BigQuery?',
146+
message:
147+
'Do you want to configure export cloud Billing data to BigQuery?',
146148
name: 'addBillingConfig',
147149
default: true,
148150
},
@@ -525,6 +527,7 @@ export default class Provider extends CloudGraph.Client {
525527
}
526528
}
527529

530+
result.errors = getAllProviderErrors()
528531
return result
529532
}
530533
}

src/utils/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import CloudGraph from '@cloudgraph/sdk'
2+
import { ProviderError } from '@cloudgraph/sdk/dist/src/types'
23
import environment from '../config/environment'
34

45
const { logger } = CloudGraph
@@ -14,6 +15,12 @@ export function initTestEndpoint(service?: string): string | undefined {
1415
return endpoint
1516
}
1617

18+
const errorsHistory: ProviderError[] = []
19+
20+
export function getAllProviderErrors(): ProviderError[] {
21+
return errorsHistory
22+
}
23+
1724
export function generateGcpErrorLog(
1825
service: string,
1926
functionName: string,
@@ -23,4 +30,10 @@ export function generateGcpErrorLog(
2330
`There was a problem getting data for service ${service}, CG encountered an error calling ${functionName}`
2431
)
2532
logger.debug(err.message)
33+
34+
errorsHistory.push({
35+
service,
36+
function: functionName,
37+
message: err?.message,
38+
})
2639
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,10 +598,10 @@
598598
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
599599
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
600600

601-
"@cloudgraph/sdk@0.22.1":
602-
version "0.22.1"
603-
resolved "https://registry.yarnpkg.com/@cloudgraph/sdk/-/sdk-0.22.1.tgz#bf5c2f263df17b085147a3ca234ac5b0a8806545"
604-
integrity sha512-aMrnoTRRIODAVvgtmqGZPB7Z8x1kMgKjFtLjpiHa121o0GCEZCjbxDmU8T3DwmRwI1u4QD5iKbXf9dB0573mJA==
601+
"@cloudgraph/sdk@0.23.0":
602+
version "0.23.0"
603+
resolved "https://registry.yarnpkg.com/@cloudgraph/sdk/-/sdk-0.23.0.tgz#3f6012c0e3573f527da27ebcccb8841bbeffd21b"
604+
integrity sha512-c+Ozu8yLK3RlAcKy4d0fdTQc9JkdUJ2ESmrcW7oC5XdIARrDWQ5+Kr8AGPABOK1/UYtFyVR2JmUHnoSJdGAv6Q==
605605
dependencies:
606606
"@graphql-tools/load-files" "^6.5.3"
607607
"@graphql-tools/merge" "^8.2.1"

0 commit comments

Comments
 (0)