Skip to content

Commit e711474

Browse files
Merge branch 'main' into feature/CG-665-add-api-gateway
2 parents 879975d + 261c099 commit e711474

30 files changed

Lines changed: 525 additions & 113 deletions

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
# [0.31.0](https://gitlab.com/auto-cloud/cloudgraph/provider/cloudgraph-provider-gcp/compare/0.30.0...0.31.0) (2022-02-18)
2+
3+
4+
### Bug Fixes
5+
6+
* **label:** pluralize secretManager ([853d37b](https://gitlab.com/auto-cloud/cloudgraph/provider/cloudgraph-provider-gcp/commit/853d37bfd2854070998ca60d6e68d9e0721f7320))
7+
8+
9+
### Features
10+
11+
* **label/tag:** add labels/tags as services ([d07fdd5](https://gitlab.com/auto-cloud/cloudgraph/provider/cloudgraph-provider-gcp/commit/d07fdd58530c2efb48ac55914179c8f84f64a182))
12+
13+
# [0.30.0](https://gitlab.com/auto-cloud/cloudgraph/provider/cloudgraph-provider-gcp/compare/0.29.0...0.30.0) (2022-02-16)
14+
15+
16+
### Features
17+
18+
* **firestore:** add firestore databasecd ([e692909](https://gitlab.com/auto-cloud/cloudgraph/provider/cloudgraph-provider-gcp/commit/e69290991881b91f57165af4d418f5251eae6bb4))
19+
* **firestore:** add project connection ([6b93c39](https://gitlab.com/auto-cloud/cloudgraph/provider/cloudgraph-provider-gcp/commit/6b93c39186f7220453d6781117ffcb3cfde3de45))
20+
121
# [0.29.0](https://gitlab.com/auto-cloud/cloudgraph/provider/cloudgraph-provider-gcp/compare/0.28.2...0.29.0) (2022-02-11)
222

323

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ CloudGraph GCP Provider will ask you what regions you would like to crawl and wi
8989
| kmsCryptoKeys | iamPolicy, kmsKeyRing, project |
9090
| dnsManagedZone | project |
9191
| dnsPolicy | project, network |
92+
| firestores | project |
9293
| firewall | network, project |
9394
| folder | iamPolicy, organization, project |
9495
| kmsKeyRing | kmsCryptoKeys, project |

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cloudgraph/cg-provider-gcp",
3-
"version": "0.29.0",
3+
"version": "0.31.0",
44
"description": "CloudGraph provider plugin for GCP used to fetch GCP cloud data.",
55
"publishConfig": {
66
"registry": "https://registry.npmjs.org/",
@@ -41,7 +41,9 @@
4141
"@google-cloud/bigquery-reservation": "^1.4.0",
4242
"@google-cloud/compute": "^3.0.0",
4343
"@google-cloud/dataproc": "^3.2.0",
44+
"@google-cloud/datastore": "^6.6.2",
4445
"@google-cloud/dns": "^2.2.3",
46+
"@google-cloud/firestore": "^5.0.2",
4547
"@google-cloud/functions": "^1.2.0",
4648
"@google-cloud/kms": "^2.10.0",
4749
"@google-cloud/logging": "^9.6.4",

src/enums/schemasMap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,6 @@ export default {
5050
[services.apiGatewayGateway]: 'gcpApiGatewayGateway',
5151
[services.apiGatewayApi]: 'gcpApiGatewayApi',
5252
[services.apiGatewayApiConfig]: 'gcpApiGatewayApiConfig',
53+
[services.firestoreDatabase]: 'gcpFirestoreDatabase',
5354
tag: 'gcpTag',
5455
}

src/enums/serviceMap.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import GcpCdnUrlMap from '../services/cdnUrlMap'
1515
import GcpDnsManagedZone from '../services/dnsManagedZone'
1616
import GcpVpc from '../services/vpc'
1717
import GcpIam from '../services/iam'
18-
import GcpTag from '../services/tag'
1918
import GcpLogBucket from '../services/logBucket'
2019
import GcpLogSink from '../services/logSink'
2120
import GcpLogView from '../services/logView'
@@ -46,6 +45,9 @@ import GcpDataprocWorkflowTemplate from '../services/dataprocWorkflowTemplate'
4645
import GcpApiGatewayGateway from '../services/apiGatewayGateway'
4746
import GcpApiGatewayApi from '../services/apiGatewayApi'
4847
import GcpApiGatewayApiConfig from '../services/apiGatewayApiConfig'
48+
import GcpFirestoreDatabase from '../services/firestore'
49+
import GcpLabel from '../services/label'
50+
import GcpTag from '../services/tag'
4951

5052
/**
5153
* serviceMap is an object that contains all currently supported services
@@ -98,5 +100,7 @@ export default {
98100
[services.apiGatewayGateway]: GcpApiGatewayGateway,
99101
[services.apiGatewayApi]: GcpApiGatewayApi,
100102
[services.apiGatewayApiConfig]: GcpApiGatewayApiConfig,
103+
[services.firestoreDatabase]: GcpFirestoreDatabase,
104+
label: GcpLabel,
101105
tag: GcpTag,
102106
}

src/enums/services.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default {
4848
bigQueryDataTransferRun: 'bigQueryDataTransferRun',
4949
// databaseMigration: 'database-migration',
5050
// datastore: 'datastore',
51-
// firestore: 'firestore',
51+
firestoreDatabase: 'firestoreDatabases',
5252
cloudRouter: 'cloudRouters',
5353
firewall: 'firewall',
5454
// spanner: 'spanner',
@@ -69,7 +69,7 @@ export default {
6969
// recaptcha: 'recaptcha',
7070
// resourceManager: 'resource-manager',
7171
// resourceSettings: 'resource-settings',
72-
secretManager: 'secretManager',
72+
secretManager: 'secrets',
7373
// iot: 'iot',
7474
// cloudShell: 'cloud-shell',
7575
// debug: 'debug',

src/services/alertPolicy/format.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default ({
3535
region,
3636
displayName,
3737
documentation,
38-
userLabels: formatLabelsFromMap(userLabels),
38+
labels: formatLabelsFromMap(userLabels),
3939
conditions: conditions?.map(condition => ({
4040
id: cuid(),
4141
name: condition?.name,

src/services/alertPolicy/schema.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
type gcpAlertPolicy implements gcpBaseResource @key(fields: "id") {
22
displayName: String @search(by: [hash, regexp])
33
documentation: gcpAlertPolicyDocumentation
4-
userLabels: [gcpRawLabel]
4+
labels: [gcpRawLabel]
55
conditions: [gcpAlertPolicyCondition]
66
combiner: String @search(by: [hash, regexp])
77
enabled: gcpBoolValue

src/services/firestore/data.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import CloudGraph from '@cloudgraph/sdk'
2+
import groupBy from 'lodash/groupBy'
3+
import { Datastore } from '@google-cloud/datastore'
4+
import gcpLoggerText from '../../properties/logger'
5+
import { GcpServiceInput } from '../../types'
6+
import { initTestEndpoint, generateGcpErrorLog } from '../../utils'
7+
import { GLOBAL_REGION } from '../../config/constants'
8+
import { listData } from '../../utils/fetchUtils'
9+
10+
const lt = { ...gcpLoggerText }
11+
const { logger } = CloudGraph
12+
const serviceName = 'Firestore Database'
13+
const apiEndpoint = initTestEndpoint(serviceName)
14+
15+
export interface RawGcpFirestoreDatabase {
16+
id: string
17+
projectId: string
18+
region: string
19+
name: string
20+
createTime: string
21+
updateTime: string
22+
locationId: string
23+
type: string
24+
concurrencyMode: string
25+
appEngineIntegrationMode: string
26+
keyPrefix: string
27+
}
28+
29+
export default async ({
30+
config,
31+
}: GcpServiceInput): Promise<{
32+
[region: string]: RawGcpFirestoreDatabase[]
33+
}> =>
34+
new Promise(async resolve => {
35+
const firestoreDatabaseList: RawGcpFirestoreDatabase[] = []
36+
const { projectId } = config
37+
38+
try {
39+
const service = new Datastore({ ...config, apiEndpoint })
40+
const data = await listData({
41+
accessToken: await service.auth.getAccessToken(),
42+
apiUri: `https://firestore.googleapis.com/v1/projects/${projectId}/databases`,
43+
dataFieldName: 'databases',
44+
})
45+
46+
for (const {name, createTime, updateTime, locationId, type, concurrencyMode, appEngineIntegrationMode, keyPrefix} of data) {
47+
firestoreDatabaseList.push({
48+
id: name,
49+
projectId,
50+
region: GLOBAL_REGION,
51+
name,
52+
createTime,
53+
updateTime,
54+
locationId,
55+
type,
56+
concurrencyMode,
57+
appEngineIntegrationMode,
58+
keyPrefix,
59+
})
60+
}
61+
} catch (error) {
62+
generateGcpErrorLog(serviceName, 'firestore:listDatabase', error)
63+
}
64+
65+
logger.debug(lt.foundResources(serviceName, firestoreDatabaseList.length))
66+
resolve(groupBy(firestoreDatabaseList, 'region'))
67+
})

src/services/firestore/format.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { GcpFirestoreDatabase } from '../../types/generated'
2+
import { RawGcpFirestoreDatabase } from './data'
3+
4+
export default ({
5+
service,
6+
}: {
7+
service: RawGcpFirestoreDatabase
8+
region: string
9+
}): GcpFirestoreDatabase => {
10+
const {
11+
id,
12+
projectId,
13+
region,
14+
name,
15+
createTime,
16+
updateTime,
17+
locationId,
18+
type,
19+
concurrencyMode,
20+
appEngineIntegrationMode,
21+
keyPrefix,
22+
} = service
23+
24+
return {
25+
id,
26+
projectId,
27+
region,
28+
name,
29+
createTime,
30+
updateTime,
31+
locationId,
32+
type,
33+
concurrencyMode,
34+
appEngineIntegrationMode,
35+
keyPrefix,
36+
}
37+
}

0 commit comments

Comments
 (0)