From 4ef91ab46732066d9b5acc4ef444b11a66fcfc86 Mon Sep 17 00:00:00 2001 From: Andre Wanlin <67169551+awanlin@users.noreply.github.com> Date: Wed, 24 May 2023 11:52:40 -0500 Subject: [PATCH 1/3] Added PG object details Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com> --- .changeset/afraid-rules-yell.md | 5 +++ packages/backend-common/config.d.ts | 60 ++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 .changeset/afraid-rules-yell.md diff --git a/.changeset/afraid-rules-yell.md b/.changeset/afraid-rules-yell.md new file mode 100644 index 0000000000..ab32da1cd9 --- /dev/null +++ b/.changeset/afraid-rules-yell.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-common': patch +--- + +Updated the backend database connection configuration schema to include the full PG object details in order to set the password visibility to secret diff --git a/packages/backend-common/config.d.ts b/packages/backend-common/config.d.ts index dc2e2fa133..42033a8c9f 100644 --- a/packages/backend-common/config.d.ts +++ b/packages/backend-common/config.d.ts @@ -14,6 +14,9 @@ * limitations under the License. */ +import { CustomTypesConfig } from 'pg'; +import { ConnectionOptions } from 'tls'; + export interface Config { app: { baseUrl: string; // defined in core, but repeated here without doc @@ -72,10 +75,63 @@ export interface Config { /** Default database client to use */ client: 'better-sqlite3' | 'sqlite3' | 'pg'; /** - * Base database connection string or Knex object + * Base database connection string or Knex (PG) object + * PG object details come from: https://node-postgres.com/apis/client * @visibility secret */ - connection: string | object; + connection: + | string + | { + /** + * User with which to authenticate to the server + */ + user?: string; + /** + * Corresponding password + * @visibility secret + */ + password: string; + /** + * Postgres server hostname or, for UNIX domain sockets, the socket filename + */ + host?: string; + /** + * Database name within the server + */ + database?: string; + /** + * Port on which to connect + */ + port?: number; + /** + * TLS/SSL connections settings + */ + ssl?: boolean | ConnectionOptions; + /** + * Custom type parsers + */ + types?: CustomTypesConfig; + /** + * Number of milliseconds before a statement in query will time out, default is no timeout + */ + statement_timeout?: false | number; + /** + * Number of milliseconds before a query call will timeout, default is no timeout + */ + query_timeout?: number; + /** + * The name of the application that created this Client instance + */ + application_name?: string; + /** + * Number of milliseconds to wait for connection, default is no timeout + */ + connectionTimeoutMillis?: number; + /** + * Number of milliseconds before terminating any session with an open idle transaction, default is no timeout + */ + idle_in_transaction_session_timeout?: number; + }; /** Database name prefix override */ prefix?: string; /** From 447270a7d9083fdd7fd8a76c002ff945544c9be2 Mon Sep 17 00:00:00 2001 From: Andre Wanlin <67169551+awanlin@users.noreply.github.com> Date: Mon, 29 May 2023 07:25:01 -0500 Subject: [PATCH 2/3] Simplified based on feedback Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com> --- .changeset/afraid-rules-yell.md | 2 +- packages/backend-common/config.d.ts | 50 +++-------------------------- 2 files changed, 6 insertions(+), 46 deletions(-) diff --git a/.changeset/afraid-rules-yell.md b/.changeset/afraid-rules-yell.md index ab32da1cd9..258a07dc89 100644 --- a/.changeset/afraid-rules-yell.md +++ b/.changeset/afraid-rules-yell.md @@ -2,4 +2,4 @@ '@backstage/backend-common': patch --- -Updated the backend database connection configuration schema to include the full PG object details in order to set the password visibility to secret +Updated the backend database connection configuration schema to set the password visibility to secret diff --git a/packages/backend-common/config.d.ts b/packages/backend-common/config.d.ts index 42033a8c9f..512341ec3a 100644 --- a/packages/backend-common/config.d.ts +++ b/packages/backend-common/config.d.ts @@ -81,57 +81,17 @@ export interface Config { */ connection: | string - | { + | Partial<{ /** - * User with which to authenticate to the server - */ - user?: string; - /** - * Corresponding password + * Password that belongs to the Postgres User * @visibility secret */ password: string; /** - * Postgres server hostname or, for UNIX domain sockets, the socket filename + * Other Knex (PG) object settings */ - host?: string; - /** - * Database name within the server - */ - database?: string; - /** - * Port on which to connect - */ - port?: number; - /** - * TLS/SSL connections settings - */ - ssl?: boolean | ConnectionOptions; - /** - * Custom type parsers - */ - types?: CustomTypesConfig; - /** - * Number of milliseconds before a statement in query will time out, default is no timeout - */ - statement_timeout?: false | number; - /** - * Number of milliseconds before a query call will timeout, default is no timeout - */ - query_timeout?: number; - /** - * The name of the application that created this Client instance - */ - application_name?: string; - /** - * Number of milliseconds to wait for connection, default is no timeout - */ - connectionTimeoutMillis?: number; - /** - * Number of milliseconds before terminating any session with an open idle transaction, default is no timeout - */ - idle_in_transaction_session_timeout?: number; - }; + [key: string]: unknown; + }>; /** Database name prefix override */ prefix?: string; /** From de8bb7f92fa73c90fd4b51967a51fb424cd18c00 Mon Sep 17 00:00:00 2001 From: Andre Wanlin <67169551+awanlin@users.noreply.github.com> Date: Mon, 29 May 2023 10:01:10 -0500 Subject: [PATCH 3/3] Corrections based on feedback Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com> --- packages/backend-common/config.d.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/backend-common/config.d.ts b/packages/backend-common/config.d.ts index 512341ec3a..3fd886874e 100644 --- a/packages/backend-common/config.d.ts +++ b/packages/backend-common/config.d.ts @@ -14,9 +14,6 @@ * limitations under the License. */ -import { CustomTypesConfig } from 'pg'; -import { ConnectionOptions } from 'tls'; - export interface Config { app: { baseUrl: string; // defined in core, but repeated here without doc @@ -75,20 +72,19 @@ export interface Config { /** Default database client to use */ client: 'better-sqlite3' | 'sqlite3' | 'pg'; /** - * Base database connection string or Knex (PG) object - * PG object details come from: https://node-postgres.com/apis/client + * Base database connection string, or object with individual connection properties * @visibility secret */ connection: | string | Partial<{ /** - * Password that belongs to the Postgres User + * Password that belongs to the client User * @visibility secret */ password: string; /** - * Other Knex (PG) object settings + * Other connection settings */ [key: string]: unknown; }>;