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