diff --git a/.changeset/perfect-lobsters-compare.md b/.changeset/perfect-lobsters-compare.md new file mode 100644 index 0000000000..cac8278e57 --- /dev/null +++ b/.changeset/perfect-lobsters-compare.md @@ -0,0 +1,5 @@ +--- +'@evidence-dev/snowflake': minor +--- + +Add Proxy config section/options to snowflake connector diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dbe0eafed2..5dcc3846de 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -117,7 +117,7 @@ Follow these steps to submit a pull request for your changes: 3. Test your changes to make sure all results are as expected 4. Format your code to prevent linting errors `pnpm run format` 5. Add a [changeset](#adding-a-changeset) -6. Open a pull request against the `main` branch of the `evidence` repo +6. Open a pull request against the `next` branch of the `evidence` repo [Here's an example of a pull request](https://github.com/evidence-dev/evidence/pull/165) from a community member who built Evidence's MySQL connector. diff --git a/packages/datasources/snowflake/index.cjs b/packages/datasources/snowflake/index.cjs index 16fe507685..82fb3ed2ef 100644 --- a/packages/datasources/snowflake/index.cjs +++ b/packages/datasources/snowflake/index.cjs @@ -153,6 +153,27 @@ const getCredentials = (database = {}) => { const role = database.role; const schema = database.schema; + // https://docs.snowflake.com/en/developer-guide/node-js/nodejs-driver-connect#label-nodejs-proxy-connection + const proxyOptions = database.proxy + ? { + proxyHost: database.proxy.host, + proxyPort: database.proxy.port, + proxyUser: database.proxy.username, + proxyPassword: database.proxy.password, + proxyProtocol: database.proxy.protocol + } + : {}; + + const baseOptions = { + account, + database: default_database, + username, + warehouse, + role, + schema, + ...proxyOptions + }; + if (authenticator === 'snowflake_jwt') { const private_key = database.private_key; const passphrase = database.passphrase; @@ -168,45 +189,25 @@ const getCredentials = (database = {}) => { }); return { + ...baseOptions, privateKey: decrypted_private_key, - username, - account, - database: default_database, - warehouse, - role, - schema, authenticator }; } else if (authenticator === 'externalbrowser') { return { - username, - account, - database: default_database, - warehouse, - role, - schema, + ...baseOptions, authenticator }; } else if (authenticator === 'okta') { return { - username, + ...baseOptions, password: database.password, - account, - database: default_database, - warehouse, - role, - schema, authenticator: database.okta_url }; } else { return { - username, - password: database.password, - account, - database: default_database, - warehouse, - schema, - role + ...baseOptions, + password: database.password }; } }; @@ -381,5 +382,47 @@ module.exports.options = { } } } + }, + proxy: { + title: 'Connect through an authenticated proxy?', + type: 'boolean', + secret: false, + required: false, + nest: true, + children: { + [true]: { + host: { + title: 'Host', + type: 'string', + secret: false, + required: true + }, + port: { + title: 'Port', + type: 'number', + secret: false, + required: true + }, + username: { + title: 'Username', + type: 'string', + secret: true, + shown: true, + required: false + }, + password: { + title: 'Password', + type: 'string', + secret: true, + required: false + }, + protocol: { + title: 'Protocol', + type: 'string', + secret: false, + required: false + } + } + } } };