diff --git a/packages/gcp-cloud-run/package.json b/packages/gcp-cloud-run/package.json index 5201743d..416bd0c3 100644 --- a/packages/gcp-cloud-run/package.json +++ b/packages/gcp-cloud-run/package.json @@ -1,6 +1,6 @@ { "name": "@nx-extend/gcp-cloud-run", - "version": "10.1.1", + "version": "10.1.2", "homepage": "https://github.com/TriPSs/nx-extend/blob/master/packages/gcp-cloud-run/README.md", "bugs": { "url": "https://github.com/tripss/nx-extend/issues" diff --git a/packages/gcp-cloud-run/src/utils/get-valid-secrets.ts b/packages/gcp-cloud-run/src/utils/get-valid-secrets.ts index 97000dd2..1e6d559f 100644 --- a/packages/gcp-cloud-run/src/utils/get-valid-secrets.ts +++ b/packages/gcp-cloud-run/src/utils/get-valid-secrets.ts @@ -1,21 +1,37 @@ import { logger } from '@nx/devkit' -export function getValidSecrets(secrets?: string[] | Record): string[] { +export function getValidSecrets( + secrets?: string | string[] | Record +): string[] { if (!secrets) { return [] } + if (typeof secrets === 'string') { + try { + secrets = JSON.parse(secrets) + } catch { + throw new Error('Invalid JSON passed to secrets argument') + } + } + if (!Array.isArray(secrets)) { - secrets = Object.keys(secrets).map((secret) => `${secret}=${secrets[secret]}`) + secrets = Object.keys(secrets).map( + (secret) => `${secret}=${secrets[secret]}` + ) } - return secrets.map((secret) => { - if (secret.includes('=') && secret.includes(':')) { - return secret - } + return secrets + .map((secret) => { + if (secret.includes('=') && secret.includes(':')) { + return secret + } - logger.warn(`"${secret}" is not a valid secret! It should be in the following format "ENV_VAR_NAME=SECRET:VERSION"`) + logger.warn( + `"${secret}" is not a valid secret! It should be in the following format "ENV_VAR_NAME=SECRET:VERSION"` + ) - return false - }).filter(Boolean) as string[] + return false + }) + .filter(Boolean) as string[] } diff --git a/packages/gcp-functions/package.json b/packages/gcp-functions/package.json index 8510df65..2462465a 100644 --- a/packages/gcp-functions/package.json +++ b/packages/gcp-functions/package.json @@ -1,6 +1,6 @@ { "name": "@nx-extend/gcp-functions", - "version": "13.1.4", + "version": "13.1.5", "homepage": "https://github.com/TriPSs/nx-extend/blob/master/packages/gcp-functions/README.md", "bugs": { "url": "https://github.com/tripss/nx-extend/issues" diff --git a/packages/gcp-functions/src/utils/get-valid-secrets.ts b/packages/gcp-functions/src/utils/get-valid-secrets.ts index 97000dd2..56b23fa6 100644 --- a/packages/gcp-functions/src/utils/get-valid-secrets.ts +++ b/packages/gcp-functions/src/utils/get-valid-secrets.ts @@ -1,11 +1,19 @@ import { logger } from '@nx/devkit' -export function getValidSecrets(secrets?: string[] | Record): string[] { +export function getValidSecrets(secrets?: string | string[] | Record): string[] { if (!secrets) { return [] } - if (!Array.isArray(secrets)) { + if (typeof secrets === 'string') { + try { + secrets = JSON.parse(secrets) + } catch { + throw new Error('Invalid JSON passed to secrets argument') + } + } + + if (!Array.isArray(secrets)) { secrets = Object.keys(secrets).map((secret) => `${secret}=${secrets[secret]}`) }