Merge pull request #13372 from Budibase/fix/better-datasource-defaults
Better datasource default hosts
This commit is contained in:
commit
f9e78652bb
|
@ -9,6 +9,7 @@ import {
|
||||||
QueryType,
|
QueryType,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { db as dbCore } from "@budibase/backend-core"
|
import { db as dbCore } from "@budibase/backend-core"
|
||||||
|
import { HOST_ADDRESS } from "./utils"
|
||||||
|
|
||||||
interface CouchDBConfig {
|
interface CouchDBConfig {
|
||||||
url: string
|
url: string
|
||||||
|
@ -28,7 +29,7 @@ const SCHEMA: Integration = {
|
||||||
url: {
|
url: {
|
||||||
type: DatasourceFieldType.STRING,
|
type: DatasourceFieldType.STRING,
|
||||||
required: true,
|
required: true,
|
||||||
default: "http://localhost:5984",
|
default: `http://${HOST_ADDRESS}:5984`,
|
||||||
},
|
},
|
||||||
database: {
|
database: {
|
||||||
type: DatasourceFieldType.STRING,
|
type: DatasourceFieldType.STRING,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
|
||||||
import { Client, ClientOptions } from "@elastic/elasticsearch"
|
import { Client, ClientOptions } from "@elastic/elasticsearch"
|
||||||
|
import { HOST_ADDRESS } from "./utils"
|
||||||
|
|
||||||
interface ElasticsearchConfig {
|
interface ElasticsearchConfig {
|
||||||
url: string
|
url: string
|
||||||
|
@ -29,7 +30,7 @@ const SCHEMA: Integration = {
|
||||||
url: {
|
url: {
|
||||||
type: DatasourceFieldType.STRING,
|
type: DatasourceFieldType.STRING,
|
||||||
required: true,
|
required: true,
|
||||||
default: "http://localhost:9200",
|
default: `http://${HOST_ADDRESS}:9200`,
|
||||||
},
|
},
|
||||||
ssl: {
|
ssl: {
|
||||||
type: DatasourceFieldType.BOOLEAN,
|
type: DatasourceFieldType.BOOLEAN,
|
||||||
|
|
|
@ -22,6 +22,7 @@ import {
|
||||||
finaliseExternalTables,
|
finaliseExternalTables,
|
||||||
SqlClient,
|
SqlClient,
|
||||||
checkExternalTables,
|
checkExternalTables,
|
||||||
|
HOST_ADDRESS,
|
||||||
} from "./utils"
|
} from "./utils"
|
||||||
import Sql from "./base/sql"
|
import Sql from "./base/sql"
|
||||||
import { MSSQLTablesResponse, MSSQLColumn } from "./base/types"
|
import { MSSQLTablesResponse, MSSQLColumn } from "./base/types"
|
||||||
|
@ -88,7 +89,6 @@ const SCHEMA: Integration = {
|
||||||
user: {
|
user: {
|
||||||
type: DatasourceFieldType.STRING,
|
type: DatasourceFieldType.STRING,
|
||||||
required: true,
|
required: true,
|
||||||
default: "localhost",
|
|
||||||
},
|
},
|
||||||
password: {
|
password: {
|
||||||
type: DatasourceFieldType.PASSWORD,
|
type: DatasourceFieldType.PASSWORD,
|
||||||
|
@ -96,7 +96,7 @@ const SCHEMA: Integration = {
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
type: DatasourceFieldType.STRING,
|
type: DatasourceFieldType.STRING,
|
||||||
default: "localhost",
|
default: HOST_ADDRESS,
|
||||||
},
|
},
|
||||||
port: {
|
port: {
|
||||||
type: DatasourceFieldType.NUMBER,
|
type: DatasourceFieldType.NUMBER,
|
||||||
|
|
|
@ -22,6 +22,7 @@ import {
|
||||||
InsertManyResult,
|
InsertManyResult,
|
||||||
} from "mongodb"
|
} from "mongodb"
|
||||||
import environment from "../environment"
|
import environment from "../environment"
|
||||||
|
import { HOST_ADDRESS } from "./utils"
|
||||||
|
|
||||||
export interface MongoDBConfig {
|
export interface MongoDBConfig {
|
||||||
connectionString: string
|
connectionString: string
|
||||||
|
@ -51,7 +52,7 @@ const getSchema = () => {
|
||||||
connectionString: {
|
connectionString: {
|
||||||
type: DatasourceFieldType.STRING,
|
type: DatasourceFieldType.STRING,
|
||||||
required: true,
|
required: true,
|
||||||
default: "mongodb://localhost:27017",
|
default: `mongodb://${HOST_ADDRESS}:27017`,
|
||||||
display: "Connection string",
|
display: "Connection string",
|
||||||
},
|
},
|
||||||
db: {
|
db: {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import {
|
||||||
generateColumnDefinition,
|
generateColumnDefinition,
|
||||||
finaliseExternalTables,
|
finaliseExternalTables,
|
||||||
checkExternalTables,
|
checkExternalTables,
|
||||||
|
HOST_ADDRESS,
|
||||||
} from "./utils"
|
} from "./utils"
|
||||||
import dayjs from "dayjs"
|
import dayjs from "dayjs"
|
||||||
import { NUMBER_REGEX } from "../utilities"
|
import { NUMBER_REGEX } from "../utilities"
|
||||||
|
@ -49,7 +50,7 @@ const SCHEMA: Integration = {
|
||||||
datasource: {
|
datasource: {
|
||||||
host: {
|
host: {
|
||||||
type: DatasourceFieldType.STRING,
|
type: DatasourceFieldType.STRING,
|
||||||
default: "localhost",
|
default: HOST_ADDRESS,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
port: {
|
port: {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import {
|
||||||
finaliseExternalTables,
|
finaliseExternalTables,
|
||||||
getSqlQuery,
|
getSqlQuery,
|
||||||
SqlClient,
|
SqlClient,
|
||||||
|
HOST_ADDRESS,
|
||||||
} from "./utils"
|
} from "./utils"
|
||||||
import Sql from "./base/sql"
|
import Sql from "./base/sql"
|
||||||
import {
|
import {
|
||||||
|
@ -63,7 +64,7 @@ const SCHEMA: Integration = {
|
||||||
datasource: {
|
datasource: {
|
||||||
host: {
|
host: {
|
||||||
type: DatasourceFieldType.STRING,
|
type: DatasourceFieldType.STRING,
|
||||||
default: "localhost",
|
default: HOST_ADDRESS,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
port: {
|
port: {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import {
|
||||||
finaliseExternalTables,
|
finaliseExternalTables,
|
||||||
SqlClient,
|
SqlClient,
|
||||||
checkExternalTables,
|
checkExternalTables,
|
||||||
|
HOST_ADDRESS,
|
||||||
} from "./utils"
|
} from "./utils"
|
||||||
import Sql from "./base/sql"
|
import Sql from "./base/sql"
|
||||||
import { PostgresColumn } from "./base/types"
|
import { PostgresColumn } from "./base/types"
|
||||||
|
@ -72,7 +73,7 @@ const SCHEMA: Integration = {
|
||||||
datasource: {
|
datasource: {
|
||||||
host: {
|
host: {
|
||||||
type: DatasourceFieldType.STRING,
|
type: DatasourceFieldType.STRING,
|
||||||
default: "localhost",
|
default: HOST_ADDRESS,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
port: {
|
port: {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import {
|
||||||
QueryType,
|
QueryType,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import Redis from "ioredis"
|
import Redis from "ioredis"
|
||||||
|
import { HOST_ADDRESS } from "./utils"
|
||||||
|
|
||||||
interface RedisConfig {
|
interface RedisConfig {
|
||||||
host: string
|
host: string
|
||||||
|
@ -28,7 +29,7 @@ const SCHEMA: Integration = {
|
||||||
host: {
|
host: {
|
||||||
type: DatasourceFieldType.STRING,
|
type: DatasourceFieldType.STRING,
|
||||||
required: true,
|
required: true,
|
||||||
default: "localhost",
|
default: HOST_ADDRESS,
|
||||||
},
|
},
|
||||||
port: {
|
port: {
|
||||||
type: DatasourceFieldType.NUMBER,
|
type: DatasourceFieldType.NUMBER,
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
DEFAULT_BB_DATASOURCE_ID,
|
DEFAULT_BB_DATASOURCE_ID,
|
||||||
} from "../constants"
|
} from "../constants"
|
||||||
import { helpers } from "@budibase/shared-core"
|
import { helpers } from "@budibase/shared-core"
|
||||||
|
import env from "../environment"
|
||||||
|
|
||||||
const DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}`
|
const DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}`
|
||||||
const ROW_ID_REGEX = /^\[.*]$/g
|
const ROW_ID_REGEX = /^\[.*]$/g
|
||||||
|
@ -92,6 +93,14 @@ export enum SqlClient {
|
||||||
ORACLE = "oracledb",
|
ORACLE = "oracledb",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isCloud = env.isProd() && !env.SELF_HOSTED
|
||||||
|
const isSelfHost = env.isProd() && env.SELF_HOSTED
|
||||||
|
export const HOST_ADDRESS = isSelfHost
|
||||||
|
? "host.docker.internal"
|
||||||
|
: isCloud
|
||||||
|
? ""
|
||||||
|
: "localhost"
|
||||||
|
|
||||||
export function isExternalTableID(tableId: string) {
|
export function isExternalTableID(tableId: string) {
|
||||||
return tableId.includes(DocumentType.DATASOURCE)
|
return tableId.includes(DocumentType.DATASOURCE)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue