Merge pull request #3886 from Budibase/feature/dynamo-describe

adding dynamoDB describe call to dynamo integration
This commit is contained in:
Martin McKeaveney 2022-01-04 12:42:49 +00:00 committed by GitHub
commit 2479e95a0c
6 changed files with 48 additions and 9 deletions

View File

@ -12,6 +12,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Fail if branch is not master
if: github.ref != 'refs/heads/master'
run: |
echo "Ref is not master, you must run this job from master."
exit 1
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Pull values.yaml from budibase-infra - name: Pull values.yaml from budibase-infra

View File

@ -7,8 +7,11 @@ const {
} = require("../../db/utils") } = require("../../db/utils")
const { BaseQueryVerbs } = require("../../constants") const { BaseQueryVerbs } = require("../../constants")
const { Thread, ThreadType } = require("../../threads") const { Thread, ThreadType } = require("../../threads")
const env = require("../../environment")
const Runner = new Thread(ThreadType.QUERY, { timeoutMs: 10000 }) const Runner = new Thread(ThreadType.QUERY, {
timeoutMs: env.QUERY_THREAD_TIMEOUT || 10000,
})
// simple function to append "readable" to all read queries // simple function to append "readable" to all read queries
function enrichQueries(input) { function enrichQueries(input) {

View File

@ -65,6 +65,7 @@ module.exports = {
DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL, DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL,
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS, ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
DISABLE_THREADING: process.env.DISABLE_THREADING, DISABLE_THREADING: process.env.DISABLE_THREADING,
QUERY_THREAD_TIMEOUT: process.env.QUERY_THREAD_TIMEOUT,
_set(key, value) { _set(key, value) {
process.env[key] = value process.env[key] = value
module.exports[key] = value module.exports[key] = value

View File

@ -80,6 +80,17 @@ module DynamoModule {
}, },
}, },
}, },
describe: {
type: QueryTypes.FIELDS,
customisable: true,
readable: true,
fields: {
table: {
type: DatasourceFieldTypes.STRING,
required: true,
},
},
},
get: { get: {
type: QueryTypes.FIELDS, type: QueryTypes.FIELDS,
customisable: true, customisable: true,
@ -180,6 +191,13 @@ module DynamoModule {
return response return response
} }
async describe(query: { table: string }) {
const params = {
TableName: query.table,
}
return new AWS.DynamoDB().describeTable(params).promise()
}
async get(query: { table: string; json: object }) { async get(query: { table: string; json: object }) {
const params = { const params = {
TableName: query.table, TableName: query.table,

View File

@ -450,7 +450,7 @@ module OracleModule {
}) })
return lastRow.rows return lastRow.rows
} else { } else {
return [{ [ operation.toLowerCase() ]: true }] return [{ [operation.toLowerCase()]: true }]
} }
} }
} }

View File

@ -8,6 +8,8 @@ module S3Module {
region: string region: string
accessKeyId: string accessKeyId: string
secretAccessKey: string secretAccessKey: string
s3ForcePathStyle: boolean
endpoint?: string
} }
const SCHEMA: Integration = { const SCHEMA: Integration = {
@ -18,7 +20,7 @@ module S3Module {
datasource: { datasource: {
region: { region: {
type: "string", type: "string",
required: true, required: false,
default: "us-east-1", default: "us-east-1",
}, },
accessKeyId: { accessKeyId: {
@ -29,6 +31,15 @@ module S3Module {
type: "password", type: "password",
required: true, required: true,
}, },
endpoint: {
type: "string",
required: false,
},
signatureVersion: {
type: "string",
required: false,
default: "v4"
},
}, },
query: { query: {
read: { read: {
@ -46,16 +57,16 @@ module S3Module {
class S3Integration implements IntegrationBase { class S3Integration implements IntegrationBase {
private readonly config: S3Config private readonly config: S3Config
private client: any private client: any
private connectionPromise: Promise<any>
constructor(config: S3Config) { constructor(config: S3Config) {
this.config = config this.config = config
this.connectionPromise = this.connect() if (this.config.endpoint) {
this.client = new AWS.S3() this.config.s3ForcePathStyle = true
} } else {
delete this.config.endpoint
}
async connect() { this.client = new AWS.S3(this.config)
AWS.config.update(this.config)
} }
async read(query: { bucket: string }) { async read(query: { bucket: string }) {