Update templates

fix: non string inputs in templates
This commit is contained in:
Andras Bacsai
2023-04-18 14:22:46 +02:00
parent e2821118eb
commit 3713b33578
6 changed files with 130 additions and 22 deletions

View File

@@ -268,6 +268,13 @@
- DISABLE_REGISTRATION=$$config_disable_registration
- DATABASE_URL=$$secret_database_url
- CLICKHOUSE_DATABASE_URL=$$secret_clickhouse_database_url
- MAILER_EMAIL=$$config_mailer_email
- SMTP_HOST_ADDR=$$config_smtp_host_addr
- SMTP_HOST_PORT=$$config_smtp_host_port
- SMTP_USER_NAME=$$config_smtp_user_name
- SMTP_USER_PWD=$$config_smtp_user_pwd
- SMTP_HOST_SSL_ENABLED=$$config_smtp_host_ssl_enabled
- SMTP_HOST_RETRIES=$$config_smtp_host_retries
ports:
- "8000"
$$id-postgresql:
@@ -375,6 +382,49 @@
label: PostgreSQL Database
defaultValue: plausible
description: ""
- id: $$config_mailer_email
name: MAILER_EMAIL
label: Mailer Email
defaultValue: hello@plausible.local
description: >-
The email id to use for as from address of all communications from Plausible.
- id: $$config_smtp_host_addr
name: SMTP_HOST_ADDR
label: SMTP Host Address
defaultValue: localhost
description: >-
The host address of your smtp server.
- id: $$config_smtp_host_port
name: SMTP_HOST_PORT
label: SMTP Port
defaultValue: "25"
description: >-
The port of your smtp server.
- id: $$config_smtp_user_name
name: SMTP_USER_NAME
label: SMTP Username
defaultValue: ""
description: >-
The username/email in case SMTP auth is enabled.
- id: $$config_smtp_user_pwd
name: SMTP_USER_PWD
label: SMTP Password
defaultValue: ""
description: >-
The password in case SMTP auth is enabled.
showOnConfiguration: true
- id: $$config_smtp_host_ssl_enabled
name: SMTP_HOST_SSL_ENABLED
label: SMTP SSL
defaultValue: "false"
description: >-
If SSL is enabled for SMTP connection.
- id: $$config_smtp_host_retries
name: SMTP_HOST_RETRIES
label: SMTP Retries
defaultValue: "2"
description: >-
Number of retries to make until mailer gives up.
- id: $$config_scriptName
name: SCRIPT_NAME
label: Custom Script Name
@@ -3389,6 +3439,13 @@
- DISABLE_REGISTRATION=$$config_disable_registration
- DATABASE_URL=$$secret_database_url
- CLICKHOUSE_DATABASE_URL=$$secret_clickhouse_database_url
- MAILER_EMAIL=$$config_mailer_email
- SMTP_HOST_ADDR=$$config_smtp_host_addr
- SMTP_HOST_PORT=$$config_smtp_host_port
- SMTP_USER_NAME=$$config_smtp_user_name
- SMTP_USER_PWD=$$config_smtp_user_pwd
- SMTP_HOST_SSL_ENABLED=$$config_smtp_host_ssl_enabled
- SMTP_HOST_RETRIES=$$config_smtp_host_retries
ports:
- "8000"
$$id-postgresql:
@@ -3496,6 +3553,49 @@
label: PostgreSQL Database
defaultValue: plausible
description: ""
- id: $$config_mailer_email
name: MAILER_EMAIL
label: Mailer Email
defaultValue: hello@plausible.local
description: >-
The email id to use for as from address of all communications from Plausible.
- id: $$config_smtp_host_addr
name: SMTP_HOST_ADDR
label: SMTP Host Address
defaultValue: localhost
description: >-
The host address of your smtp server.
- id: $$config_smtp_host_port
name: SMTP_HOST_PORT
label: SMTP Port
defaultValue: "25"
description: >-
The port of your smtp server.
- id: $$config_smtp_user_name
name: SMTP_USER_NAME
label: SMTP Username
defaultValue: ""
description: >-
The username/email in case SMTP auth is enabled.
- id: $$config_smtp_user_pwd
name: SMTP_USER_PWD
label: SMTP Password
defaultValue: ""
description: >-
The password in case SMTP auth is enabled.
showOnConfiguration: true
- id: $$config_smtp_host_ssl_enabled
name: SMTP_HOST_SSL_ENABLED
label: SMTP SSL
defaultValue: "false"
description: >-
If SSL is enabled for SMTP connection.
- id: $$config_smtp_host_retries
name: SMTP_HOST_RETRIES
label: SMTP Retries
defaultValue: "2"
description: >-
Number of retries to make until mailer gives up.
- id: $$config_scriptName
name: SCRIPT_NAME
label: Custom Script Name

View File

@@ -86,19 +86,20 @@ export async function migrateServicesToNewTemplate() {
if (template.variables) {
if (template.variables.length > 0) {
for (const variable of template.variables) {
const { defaultValue } = variable;
let { defaultValue } = variable;
defaultValue = defaultValue.toString();
const regex = /^\$\$.*\((\d+)\)$/g;
const length = Number(regex.exec(defaultValue)?.[1]) || undefined
if (variable.defaultValue.startsWith('$$generate_password')) {
if (defaultValue.startsWith('$$generate_password')) {
variable.value = generatePassword({ length });
} else if (variable.defaultValue.startsWith('$$generate_hex')) {
} else if (defaultValue.startsWith('$$generate_hex')) {
variable.value = generatePassword({ length, isHex: true });
} else if (variable.defaultValue.startsWith('$$generate_username')) {
} else if (defaultValue.startsWith('$$generate_username')) {
variable.value = cuid();
} else if (variable.defaultValue.startsWith('$$generate_token')) {
} else if (defaultValue.startsWith('$$generate_token')) {
variable.value = generateToken()
} else {
variable.value = variable.defaultValue || '';
variable.value = defaultValue || '';
}
}
}

View File

@@ -19,7 +19,7 @@ import { saveBuildLog } from './buildPacks/common';
import { scheduler } from './scheduler';
import type { ExecaChildProcess } from 'execa';
export const version = '3.12.30';
export const version = '3.12.31';
export const isDev = process.env.NODE_ENV === 'development';
export const proxyPort = process.env.COOLIFY_PROXY_PORT;
export const proxySecurePort = process.env.COOLIFY_PROXY_SECURE_PORT;

View File

@@ -412,22 +412,23 @@ export async function saveServiceType(
if (foundTemplate.variables) {
if (foundTemplate.variables.length > 0) {
for (const variable of foundTemplate.variables) {
const { defaultValue } = variable;
let { defaultValue } = variable;
defaultValue = defaultValue.toString();
const regex = /^\$\$.*\((\d+)\)$/g;
const length = Number(regex.exec(defaultValue)?.[1]) || undefined;
if (variable.defaultValue.startsWith('$$generate_password')) {
if (defaultValue.startsWith('$$generate_password')) {
variable.value = generatePassword({ length });
} else if (variable.defaultValue.startsWith('$$generate_hex')) {
} else if (defaultValue.startsWith('$$generate_hex')) {
variable.value = generatePassword({ length, isHex: true });
} else if (variable.defaultValue.startsWith('$$generate_username')) {
} else if (defaultValue.startsWith('$$generate_username')) {
variable.value = cuid();
} else if (variable.defaultValue.startsWith('$$generate_token')) {
} else if (defaultValue.startsWith('$$generate_token')) {
variable.value = generateToken();
} else {
variable.value = variable.defaultValue || '';
variable.value = defaultValue || '';
}
const foundVariableSomewhereElse = foundTemplate.variables.find((v) =>
v.defaultValue.includes(variable.id)
v.defaultValue.toString().includes(variable.id)
);
if (foundVariableSomewhereElse) {
foundVariableSomewhereElse.value = foundVariableSomewhereElse.value.replaceAll(
@@ -746,7 +747,10 @@ export async function saveService(request: FastifyRequest<SaveService>, reply: F
let { id: settingId, name, value, changed = false, isNew = false, variableName } = setting;
if (value) {
if (changed) {
await prisma.serviceSetting.update({ where: { id: settingId }, data: { value: value.replace(/\n/, "\\n") } });
await prisma.serviceSetting.update({
where: { id: settingId },
data: { value: value.replace(/\n/, '\\n') }
});
}
if (isNew) {
if (!variableName) {
@@ -1104,11 +1108,14 @@ export async function activateWordpressFtp(
} catch (error) {}
const volumes = [
`${id}-wordpress-data:/home/${ftpUser}/wordpress`,
`${isDev ? hostkeyDir : '/var/lib/docker/volumes/coolify-ssl-certs/_data/hostkeys'
`${
isDev ? hostkeyDir : '/var/lib/docker/volumes/coolify-ssl-certs/_data/hostkeys'
}/${id}.ed25519:/etc/ssh/ssh_host_ed25519_key`,
`${isDev ? hostkeyDir : '/var/lib/docker/volumes/coolify-ssl-certs/_data/hostkeys'
`${
isDev ? hostkeyDir : '/var/lib/docker/volumes/coolify-ssl-certs/_data/hostkeys'
}/${id}.rsa:/etc/ssh/ssh_host_rsa_key`,
`${isDev ? hostkeyDir : '/var/lib/docker/volumes/coolify-ssl-certs/_data/hostkeys'
`${
isDev ? hostkeyDir : '/var/lib/docker/volumes/coolify-ssl-certs/_data/hostkeys'
}/${id}.sh:/etc/sftp.d/chmod.sh`
];

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,7 @@
{
"name": "coolify",
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
"version": "3.12.30",
"version": "3.12.31",
"license": "Apache-2.0",
"repository": "github:coollabsio/coolify",
"scripts": {