From a5b94a63f513e770dac35735c9b476509b9abeae Mon Sep 17 00:00:00 2001 From: Gaston Yelmini Date: Mon, 27 Nov 2023 16:04:44 -0300 Subject: [PATCH] INT-9927: propagate run service metadata to entity --- .../__snapshots__/converters.test.ts.snap | 9 +++++++ .../__snapshots__/index.test.ts.snap | 27 +++++++++++++++++++ src/steps/cloud-run/converters.ts | 3 +++ src/steps/cloud-run/index.test.ts | 6 ++--- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/steps/cloud-run/__snapshots__/converters.test.ts.snap b/src/steps/cloud-run/__snapshots__/converters.test.ts.snap index 7aecf8de..162c682b 100644 --- a/src/steps/cloud-run/__snapshots__/converters.test.ts.snap +++ b/src/steps/cloud-run/__snapshots__/converters.test.ts.snap @@ -310,6 +310,15 @@ exports[`#createCloudRunServiceEntity should convert to entity 1`] = ` "function": [ "workload-management", ], + "metaClientName": "cloud-console", + "metaCreator": "user@email.com", + "metaIngress": "all", + "metaIngressStatus": "all", + "metaLastModifier": "user@email.com", + "metaLaunchStage": "BETA", + "metaMaxScale": "100", + "metaSandbox": "gvisor", + "metaUserImage": "us-docker.pkg.dev/cloudrun/container/hello", "name": "example-cloud-run-service", "webLink": "https://console.cloud.google.com/run/detail/us-central1/example-cloud-run-service", } diff --git a/src/steps/cloud-run/__snapshots__/index.test.ts.snap b/src/steps/cloud-run/__snapshots__/index.test.ts.snap index fb2592c8..6bcdfa6a 100644 --- a/src/steps/cloud-run/__snapshots__/index.test.ts.snap +++ b/src/steps/cloud-run/__snapshots__/index.test.ts.snap @@ -120,6 +120,15 @@ exports[`#fetchCloudRunConfigurations should collect data 1`] = ` "function": [ "workload-management", ], + "metaClientName": "cloud-console", + "metaCreator": "user@email.com", + "metaIngress": "all", + "metaIngressStatus": "all", + "metaLastModifier": "user@email.com", + "metaLaunchStage": "BETA", + "metaMaxScale": "100", + "metaSandbox": "gvisor", + "metaUserImage": "us-docker.pkg.dev/cloudrun/container/hello", "name": "example-cloud-run-service", "webLink": "https://console.cloud.google.com/run/detail/us-central1/example-cloud-run-service", }, @@ -368,6 +377,15 @@ exports[`#fetchCloudRunRoutes should collect data 1`] = ` "function": [ "workload-management", ], + "metaClientName": "cloud-console", + "metaCreator": "user@email.com", + "metaIngress": "all", + "metaIngressStatus": "all", + "metaLastModifier": "user@email.com", + "metaLaunchStage": "BETA", + "metaMaxScale": "100", + "metaSandbox": "gvisor", + "metaUserImage": "us-docker.pkg.dev/cloudrun/container/hello", "name": "example-cloud-run-service", "webLink": "https://console.cloud.google.com/run/detail/us-central1/example-cloud-run-service", }, @@ -594,6 +612,15 @@ exports[`#fetchCloudRunServices should collect data 1`] = ` "function": [ "workload-management", ], + "metaClientName": "cloud-console", + "metaCreator": "user@email.com", + "metaIngress": "all", + "metaIngressStatus": "all", + "metaLastModifier": "user@email.com", + "metaLaunchStage": "BETA", + "metaMaxScale": "100", + "metaSandbox": "gvisor", + "metaUserImage": "us-docker.pkg.dev/cloudrun/container/hello", "name": "example-cloud-run-service", "webLink": "https://console.cloud.google.com/run/detail/us-central1/example-cloud-run-service", }, diff --git a/src/steps/cloud-run/converters.ts b/src/steps/cloud-run/converters.ts index 73104055..b0dfc9ff 100644 --- a/src/steps/cloud-run/converters.ts +++ b/src/steps/cloud-run/converters.ts @@ -53,6 +53,8 @@ export function createCloudRunServiceEntity( webLink = `/run?project=${projectId}`; } + const metadataProperties = parseMetadata(data); + return createIntegrationEntity({ entityData: { source: data, @@ -66,6 +68,7 @@ export function createCloudRunServiceEntity( category: ['infrastructure'], createdOn: parseTimePropertyValue(data.metadata?.creationTimestamp), webLink: getGoogleCloudConsoleWebLink(webLink), + ...metadataProperties.filteredProperties, }, }, }); diff --git a/src/steps/cloud-run/index.test.ts b/src/steps/cloud-run/index.test.ts index 04bd3cd0..3cd41982 100644 --- a/src/steps/cloud-run/index.test.ts +++ b/src/steps/cloud-run/index.test.ts @@ -51,7 +51,7 @@ describe('#fetchCloudRunServices', () => { ).toMatchGraphObjectSchema({ _class: ['Service'], schema: { - additionalProperties: false, + additionalProperties: true, properties: { _type: { const: 'google_cloud_run_service' }, _rawData: { @@ -110,7 +110,7 @@ describe('#fetchCloudRunRoutes', () => { ).toMatchGraphObjectSchema({ _class: ['Service'], schema: { - additionalProperties: false, + additionalProperties: true, properties: { _type: { const: 'google_cloud_run_service' }, _rawData: { @@ -204,7 +204,7 @@ describe('#fetchCloudRunConfigurations', () => { ).toMatchGraphObjectSchema({ _class: ['Service'], schema: { - additionalProperties: false, + additionalProperties: true, properties: { _type: { const: 'google_cloud_run_service' }, _rawData: {