Skip to content

Feat/usability updates #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
chore: unify naming of environment variables
  • Loading branch information
ludomikula committed Jun 18, 2023
commit c640eb64995f40a1a723cb709b6bc44b772e63ec
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"description": "The domains supported for CORS requests. All domains are allowed by default. If there are multiple domains, please separate them with commas.",
"required": false
},
"MONGODB_URI": {
"description": "Your Mongo Database URI.",
"MONGODB_URL": {
"description": "Your Mongo Database URL.",
"required": false
},
"REDIS_URL": {
Expand Down
6 changes: 2 additions & 4 deletions deploy/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ Image can be configured by setting environment variables.
| `FRONTEND_ENABLED` | If **true** lowcoder web frontend is started in the container | `true` |
| `PUID` | ID of user running services. It will own all created logs and data. | `9001` |
| `PGID` | ID of group of the user running services. | `9001` |
| `MONGODB_URI` | Mongo database connection string | `mongodb://localhost:27017/lowcoder?authSource=admin` |
| `MONGODB_URL` | Mongo database connection string | `mongodb://localhost:27017/lowcoder?authSource=admin` |
| `REDIS_URL` | Redis server URL | `redis://localhost:6379` |
| `JS_EXECUTOR_URI` | Node service URL | `http://localhost:6060` |
| `ENABLE_USER_SIGN_UP` | Enable registration of new users | `true` |
| `ENCRYPTION_PASSWORD` | Encryption password | `lowcoder.org` |
| `ENCRYPTION_SALT` | Salt used for encrypting password | `lowcoder.org` |
Expand Down Expand Up @@ -66,9 +65,8 @@ Image can be configured by setting environment variables.
| --------------------------------| --------------------------------------------------------------------| ------------------------------------------------------|
| `PUID` | ID of user running services. It will own all created logs and data. | `9001` |
| `PGID` | ID of group of the user running services. | `9001` |
| `MONGODB_URI` | Mongo database connection string | `mongodb://localhost:27017/lowcoder?authSource=admin` |
| `MONGODB_URL` | Mongo database connection string | `mongodb://localhost:27017/lowcoder?authSource=admin` |
| `REDIS_URL` | Redis server URL | `redis://localhost:6379` |
| `JS_EXECUTOR_URI` | Node service URL | `http://localhost:6060` |
| `ENABLE_USER_SIGN_UP` | Enable registration of new users | `true` |
| `ENCRYPTION_PASSWORD` | Encryption password | `lowcoder.org` |
| `ENCRYPTION_SALT` | Salt used for encrypting password | `lowcoder.org` |
Expand Down
4 changes: 2 additions & 2 deletions deploy/docker/docker-compose-multi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ services:
environment:
PUID: "9001"
PGID: "9001"
MONGODB_URI: "mongodb://lowcoder:secret123@mongodb/lowcoder?authSource=admin"
MONGODB_URL: "mongodb://lowcoder:secret123@mongodb/lowcoder?authSource=admin"
REDIS_URL: "redis://redis:6379"
JS_EXECUTOR_URI: "http://lowcoder-node-service:6060"
LOWCODER_NODE_SERVICE_URL: "http://lowcoder-node-service:6060"
ENABLE_USER_SIGN_UP: "true"
ENCRYPTION_PASSWORD: "lowcoder.org"
ENCRYPTION_SALT: "lowcoder.org"
Expand Down
5 changes: 2 additions & 3 deletions deploy/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ services:
DEFAULT_ORG_GROUP_COUNT: 100
DEFAULT_ORG_APP_COUNT: 1000
DEFAULT_DEVELOPER_COUNT: 50
#MONGODB_URI: "mongodb://lowcoder:secret123@mongodb/lowcoder?authSource=admin"
MONGODB_URI: "mongodb://localhost:27017/lowcoder?authSource=admin"
#MONGODB_URL: "mongodb://lowcoder:secret123@mongodb/lowcoder?authSource=admin"
MONGODB_URL: "mongodb://localhost:27017/lowcoder?authSource=admin"
REDIS_URL: "redis://localhost:6379"
JS_EXECUTOR_URI: "http://localhost:6060"
ENABLE_USER_SIGN_UP: "true"
ENCRYPTION_PASSWORD: "lowcoder.org"
ENCRYPTION_SALT: "lowcoder.org"
Expand Down
4 changes: 2 additions & 2 deletions deploy/helm/templates/api-service/configMap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ data:
REDIS_URL: {{- .Values.redis.externalUrl | quote }}
{{- end }}
{{- if .Values.apiService.nodeServiceUrl }}
JS_EXECUTOR_URI: {{ .Values.apiService.nodeServiceUrl | quote }}
LOWCODER_NODE_SERVICE_URL: {{ .Values.apiService.nodeServiceUrl | quote }}
{{- else }}
JS_EXECUTOR_URI: "http://{{ $name }}-node-service:{{ .Values.nodeService.service.port }}"
LOWCODER_NODE_SERVICE_URL: "http://{{ $name }}-node-service:{{ .Values.nodeService.service.port }}"
{{- end }}
PUID: {{ .Values.apiService.config.userId | default "9001" | quote }}
PGID: {{ .Values.apiService.config.groupId | default "9001" | quote }}
Expand Down
4 changes: 2 additions & 2 deletions deploy/helm/templates/api-service/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ metadata:
{{- end }}
stringData:
{{- if .Values.mongodb.enabled }}
MONGODB_URI: "mongodb://{{ $mongoUser }}:{{ $mongoPassword }}@{{ $mongoServicename }}.{{ $nameSpace }}.svc.cluster.local/{{ $lowcoderDatabase }}?retryWrites=true&ssl=false"
MONGODB_URL: "mongodb://{{ $mongoUser }}:{{ $mongoPassword }}@{{ $mongoServicename }}.{{ $nameSpace }}.svc.cluster.local/{{ $lowcoderDatabase }}?retryWrites=true&ssl=false"
{{- else }}
MONGODB_URI: {{- .Values.mongodb.externalUrl | quote }}
MONGODB_URL: {{- .Values.mongodb.externalUrl | quote }}
{{- end }}
ENCRYPTION_PASSWORD: {{ .Values.apiService.config.encryption.password | default "lowcoder.org" | quote }}
ENCRYPTION_SALT: {{ .Values.apiService.config.encryption.salt | default "lowcoder.org" | quote }}
Expand Down
10 changes: 5 additions & 5 deletions docs/self-hosting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ For developers who require stateless containers in a cluster environment, we off

<figure><img src="../.gitbook/assets/docker-compose-multi.jpeg" alt=""><figcaption></figcaption></figure>

* **mongodb**: Start a new MongoDB instance on your host. You can delete this part and modify the environment variable `MONGODB_URI` of **openblocks-api-service** to use your own MongoDB.
* **redis**: Start a new Redis instance on your host. You can delete this part and modify the environment variable `REDIS_URI` of **openblocks-api-service** to use your own Redis.
* **mongodb**: Start a new MongoDB instance on your host. You can delete this part and modify the environment variable `MONGODB_URL` of **openblocks-api-service** to use your own MongoDB.
* **redis**: Start a new Redis instance on your host. You can delete this part and modify the environment variable `REDIS_URL` of **openblocks-api-service** to use your own Redis.
* **openblocks-api-service**: Required.&#x20;
* **openblocks-node-service**: Required.
* **openblocks-frontend**: Required. Can be optional if you deploy frontend on CDN.
Expand Down Expand Up @@ -199,16 +199,16 @@ By default Lowcoder uses the built-in MongoDB and Redis installed inside the con

{% tabs %}
{% tab title="Docker-Compose" %}
Add environment variables `MONGODB_URI` and `REDIS_URI` in `docker-compose.yml` downloaded in your working directory.\
Add environment variables `MONGODB_URL` and `REDIS_URL` in `docker-compose.yml` downloaded in your working directory.\
<img src="../.gitbook/assets/mongodb-redis-uri.png" alt="" data-size="original">
{% endtab %}

{% tab title="Docker" %}
Add environment variables `MONGODB_URI` and `REDIS_URI` to the deployment command, as shown below:
Add environment variables `MONGODB_URL` and `REDIS_URL` to the deployment command, as shown below:

{% code overflow="wrap" %}
```bash
docker run -d --name openblocks -e MONGODB_URI=YOUR_MONGODB_URI REDIS_URI=YOUR_REDIS_URI -p 3000:3000 -v "$PWD/stacks:/openblocks-stacks lowcoderorg/lowcoder-ce
docker run -d --name openblocks -e MONGODB_URL=YOUR_MONGODB_URL REDIS_URL=YOUR_REDIS_URL -p 3000:3000 -v "$PWD/stacks:/openblocks-stacks lowcoderorg/lowcoder-ce
```
{% endcode %}
{% endtab %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,13 @@ private String buildClientUri(MongoDatasourceConfig mongoDatasourceConfig) {

if (mongoDatasourceConfig.isUsingUri()) {
if (StringUtils.isBlank(mongoDatasourceConfig.getUri())) {
throw new PluginException(DATASOURCE_ARGUMENT_ERROR, "MONGODB_URI_EMPTY");
throw new PluginException(DATASOURCE_ARGUMENT_ERROR, "MONGODB_URL_EMPTY");
}

String uri = mongoDatasourceConfig.getUri();
Map<String, String> extractedInfo = extractInfoFromConnectionStringURI(uri);
if (extractedInfo == null) {
throw new PluginException(DATASOURCE_ARGUMENT_ERROR, "MONGODB_URI_EXTRACT_ERROR");
throw new PluginException(DATASOURCE_ARGUMENT_ERROR, "MONGODB_URL_EXTRACT_ERROR");
}

return uri;
Expand Down Expand Up @@ -420,17 +420,17 @@ public Set<String> validateConfig(MongoDatasourceConfig connectionConfig) {

if (connectionConfig.isUsingUri()) {
if (StringUtils.isBlank(connectionConfig.getUri())) {
return ImmutableSet.of("MONGODB_URI_EMPTY_PLZ_CHECK");
return ImmutableSet.of("MONGODB_URL_EMPTY_PLZ_CHECK");
}

String mongoUri = connectionConfig.getUri();
if (!MongoConnectionUriParser.isValid(mongoUri)) {
return ImmutableSet.of("INVALID_MONGODB_URI_PLZ_CHECK");
return ImmutableSet.of("INVALID_MONGODB_URL_PLZ_CHECK");
}

Map<String, String> extractedInfo = extractInfoFromConnectionStringURI(mongoUri);
if (extractedInfo == null) {
return ImmutableSet.of("INVALID_MONGODB_URI_PLZ_CHECK");
return ImmutableSet.of("INVALID_MONGODB_URL_PLZ_CHECK");
}

return invalids;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public final class MongoConnectionUriParser {
*
* ^(mongodb(?:\+srv)?:\/\/)(?:(.+):(.+)@)?([^\/\?]+)\/?([^\?]+)?\??(.+)?$
*/
public static final String MONGO_URI_REGEX = "^(mongodb(?:\\+srv)?://)(?:(.+):(.+)@)?([^/?]+)/?([^?]+)?\\??(.+)?$";
public static final String MONGO_URL_REGEX = "^(mongodb(?:\\+srv)?://)(?:(.+):(.+)@)?([^/?]+)/?([^?]+)?\\??(.+)?$";

private static final Pattern PATTERN = Pattern.compile(MONGO_URI_REGEX);
private static final Pattern PATTERN = Pattern.compile(MONGO_URL_REGEX);

private static final int REGEX_GROUP_HEAD = 1;

Expand Down Expand Up @@ -53,7 +53,7 @@ public static boolean isValid(String uri) {
}

public static Map<String, String> extractInfoFromConnectionStringURI(String uri) {
if (!uri.matches(MONGO_URI_REGEX)) {
if (!uri.matches(MONGO_URL_REGEX)) {
return null;
}

Expand All @@ -75,7 +75,7 @@ public static Map<String, String> extractInfoFromConnectionStringURI(String uri)
public static String parseDatabaseFrom(String uri) {
Map<String, String> extractedInfo = extractInfoFromConnectionStringURI(uri);
if (extractedInfo == null) {
throw ofPluginException(DATASOURCE_ARGUMENT_ERROR, "INVALID_MONGODB_URI");
throw ofPluginException(DATASOURCE_ARGUMENT_ERROR, "INVALID_MONGODB_URL");
}

String database = extractedInfo.get(KEY_URI_DBNAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public enum RedisError implements PluginError {
// redis
REDIS_EXECUTION_ERROR,

REDIS_URI_ERROR,
REDIS_URL_ERROR,


}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static com.google.common.collect.Maps.newHashMap;
import static java.util.Objects.isNull;
import static org.lowcoder.plugin.redis.RedisError.REDIS_EXECUTION_ERROR;
import static org.lowcoder.plugin.redis.RedisError.REDIS_URI_ERROR;
import static org.lowcoder.plugin.redis.RedisError.REDIS_URL_ERROR;
import static org.lowcoder.plugin.redis.constants.RedisConstants.JEDIS_POOL_MAX_IDLE;
import static org.lowcoder.plugin.redis.constants.RedisConstants.JEDIS_POOL_MAX_TOTAL;
import static org.lowcoder.plugin.redis.constants.RedisConstants.JEDIS_POOL_MIN_EVICTABLE_IDLE_MILLIS;
Expand Down Expand Up @@ -101,7 +101,7 @@ public Mono<JedisPool> createConnection(RedisDatasourceConfig connectionConfig)
.subscribeOn(scheduler)
.onErrorMap(t -> {
if (t instanceof ArrayIndexOutOfBoundsException && connectionConfig.isUsingUri()) {
return new PluginException(REDIS_URI_ERROR, "REDIS_URI_ERROR", t.getMessage());
return new PluginException(REDIS_URL_ERROR, "REDIS_URL_ERROR", t.getMessage());
}
return t;
});
Expand Down Expand Up @@ -173,7 +173,7 @@ public Set<String> validateConfig(RedisDatasourceConfig connectionConfig) {

if (connectionConfig.isUsingUri()) {
if (StringUtils.isBlank(connectionConfig.getUri())) {
invalids.add("REDIS_URI_EMPTY");
invalids.add("REDIS_URL_EMPTY");
}
} else {
if (StringUtils.isBlank(host)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ NO_PERMISSION_TO_VIEW=It appears you don''t have the permission to view, please
INVALID_QUERY_ID=Invalid query ID.
INVALID_ES_CONFIG=Illegal elasticsearch data source configuration.
INVALID_CONNECTION_STRING=Fail to parse connectionString.
INVALID_MONGODB_URI=Illegal MongoDB URI format, please check again.
INVALID_MONGODB_URL=Illegal MongoDB URL format, please check again.
MONGODB_DATABASE_EMPTY=MongoDB database cannot be empty.
DATASOURCE_NAME_EMPTY=Illegal data source configuration: data source name is empty.
INVALID_DATASOURCE_TYPE_0=Illegal data source type.
Expand Down Expand Up @@ -129,7 +129,7 @@ CONNECTION_ERROR=Connection error: {0}.
MONGODB_COMMAND_ERROR=Illegal MongoDB query: {0}
REST_API_EXECUTION_ERROR=REST API execution error: {0}.
REDIS_EXECUTION_ERROR=Sorry, Redis execution error: {0}.
REDIS_URI_ERROR=The format of the URI error: {0}. Correct format: redis://username:password@my-redis.com: 6379 or redis://:password@my-redis.com: 6379.
REDIS_URL_ERROR=The format of the URL error: {0}. Correct format: redis://username:password@my-redis.com: 6379 or redis://:password@my-redis.com: 6379.
LOWCODER_INTERNAL_REQUEST_ERROR=Request failed: {0}.
LOWCODER_INTERNAL_INVALID_REQUEST_TYPE=Invalid Lowcoder API request type, please contact the administrator.
ES_EXECUTION_ERROR=Elasticsearch query execution error: {0}.
Expand Down Expand Up @@ -174,8 +174,8 @@ INVALID_PG_QUERY_CONFIG_EMPTY=PostgreSQL query configuration is empty.
INVALID_PG=Failed to parse PostgreSQL query configuration.
INVALID_RESTAPI=Failed to parse REST API query configuration.
GET_MONGODB_STRUCTURE_ERROR=Failed to get MongoDB structure.
MONGODB_URI_EMPTY=MongoDB''s connection URI is empty.
MONGODB_URI_EXTRACT_ERROR=Failed to resolve MongoDB connection URI.
MONGODB_URL_EMPTY=MongoDB''s connection URL is empty.
MONGODB_URL_EXTRACT_ERROR=Failed to resolve MongoDB connection URL.
CONTENT_PARSE_ERROR=Resolve upload data failed, it requires format {data:base64 string, name:string} or an array of it
MULTIFORM_DATA_IS_NOT_STRING=Resolve upload data failed, data field is not a valid base64 string
MULTIFORM_NAME_IS_NOT_STRING=Resolve upload data failed, name field is not a valid string
Expand Down Expand Up @@ -210,11 +210,11 @@ HOST_WITH_COLON=Host cannot contain "/" or ":" character.
INVALID_HOST=Invalid Host.
DATABASE_NAME_EMPTY=Database name cannot be empty.
CONNECTION_STRING_EMPTY=The connection string cannot be empty.
MONGODB_URI_EMPTY_PLZ_CHECK=URI format of the connection is invalid.
INVALID_MONGODB_URI_PLZ_CHECK=URI format of the MongoDB connection is invalid.
MONGODB_URL_EMPTY_PLZ_CHECK=URL format of the connection is invalid.
INVALID_MONGODB_URL_PLZ_CHECK=URL format of the MongoDB connection is invalid.
HOST_EMPTY_PLZ_CHECK=Host for the connection is empty.
DATABASE_EMPTY=Database cannot be empty.
REDIS_URI_EMPTY=Redis connection URI is empty.
REDIS_URL_EMPTY=Redis connection URL is empty.
PORT_EMPTY=Connection Port is empty.
INVALID_PORT=Port number cannot be negative.
AUTH_ERROR=Authentication error, please contact system administrator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ springdoc:
path: /api/docs/api-docs
swagger-ui:
path: /api/docs/swagger-ui
paths-to-exclude: /api/v1/**
paths-to-exclude: /api/v1/**
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ auth:
spring:
data:
mongodb:
uri: ${MONGODB_URI:mongodb://localhost:27017/lowcoder?socketTimeoutMS=5000}
uri: ${MONGODB_URL:mongodb://localhost:27017/lowcoder?socketTimeoutMS=5000}
redis:
url: ${REDIS_URL:redis://localhost:6379}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ common:
version: 1.1.8
block-hound-enable: false
js-executor:
host: ${JS_EXECUTOR_URI:http://127.0.0.1:6060}
host: ${LOWCODER_NODE_SERVICE_URL:http://127.0.0.1:6060}
max-query-request-size-in-mb: 20
max-query-response-size-in-mb: 20

Expand Down