mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor(templates): replace ${randomDomain} with ${domain} in template processing
This commit is contained in:
@@ -15,7 +15,7 @@ describe("processTemplate", () => {
|
|||||||
const template: CompleteTemplate = {
|
const template: CompleteTemplate = {
|
||||||
metadata: {} as any,
|
metadata: {} as any,
|
||||||
variables: {
|
variables: {
|
||||||
main_domain: "${randomDomain}",
|
main_domain: "${domain}",
|
||||||
secret_base: "${base64:64}",
|
secret_base: "${base64:64}",
|
||||||
totp_key: "${base64:32}",
|
totp_key: "${base64:32}",
|
||||||
password: "${password:32}",
|
password: "${password:32}",
|
||||||
@@ -37,7 +37,7 @@ describe("processTemplate", () => {
|
|||||||
const template: CompleteTemplate = {
|
const template: CompleteTemplate = {
|
||||||
metadata: {} as any,
|
metadata: {} as any,
|
||||||
variables: {
|
variables: {
|
||||||
main_domain: "${randomDomain}",
|
main_domain: "${domain}",
|
||||||
api_domain: "api.${main_domain}",
|
api_domain: "api.${main_domain}",
|
||||||
},
|
},
|
||||||
config: {
|
config: {
|
||||||
@@ -58,7 +58,7 @@ describe("processTemplate", () => {
|
|||||||
const template: CompleteTemplate = {
|
const template: CompleteTemplate = {
|
||||||
metadata: {} as any,
|
metadata: {} as any,
|
||||||
variables: {
|
variables: {
|
||||||
main_domain: "${randomDomain}",
|
main_domain: "${domain}",
|
||||||
},
|
},
|
||||||
config: {
|
config: {
|
||||||
domains: [
|
domains: [
|
||||||
@@ -109,7 +109,7 @@ describe("processTemplate", () => {
|
|||||||
expect(domain.host).toContain(mockSchema.projectName);
|
expect(domain.host).toContain(mockSchema.projectName);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should allow using ${randomDomain} directly in host", () => {
|
it("should allow using ${domain} directly in host", () => {
|
||||||
const template: CompleteTemplate = {
|
const template: CompleteTemplate = {
|
||||||
metadata: {} as any,
|
metadata: {} as any,
|
||||||
variables: {},
|
variables: {},
|
||||||
@@ -118,7 +118,7 @@ describe("processTemplate", () => {
|
|||||||
{
|
{
|
||||||
serviceName: "plausible",
|
serviceName: "plausible",
|
||||||
port: 8000,
|
port: 8000,
|
||||||
host: "${randomDomain}",
|
host: "${domain}",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
env: {},
|
env: {},
|
||||||
@@ -140,7 +140,7 @@ describe("processTemplate", () => {
|
|||||||
const template: CompleteTemplate = {
|
const template: CompleteTemplate = {
|
||||||
metadata: {} as any,
|
metadata: {} as any,
|
||||||
variables: {
|
variables: {
|
||||||
main_domain: "${randomDomain}",
|
main_domain: "${domain}",
|
||||||
secret_base: "${base64:64}",
|
secret_base: "${base64:64}",
|
||||||
},
|
},
|
||||||
config: {
|
config: {
|
||||||
@@ -176,7 +176,7 @@ describe("processTemplate", () => {
|
|||||||
config: {
|
config: {
|
||||||
domains: [],
|
domains: [],
|
||||||
env: {
|
env: {
|
||||||
RANDOM_DOMAIN: "${randomDomain}",
|
RANDOM_DOMAIN: "${domain}",
|
||||||
SECRET_KEY: "${base64:32}",
|
SECRET_KEY: "${base64:32}",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -238,7 +238,7 @@ describe("processTemplate", () => {
|
|||||||
mounts: [
|
mounts: [
|
||||||
{
|
{
|
||||||
filePath: "/config/secrets.txt",
|
filePath: "/config/secrets.txt",
|
||||||
content: "random_domain=${randomDomain}\nsecret=${base64:32}",
|
content: "random_domain=${domain}\nsecret=${base64:32}",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -259,7 +259,7 @@ describe("processTemplate", () => {
|
|||||||
const template: CompleteTemplate = {
|
const template: CompleteTemplate = {
|
||||||
metadata: {} as any,
|
metadata: {} as any,
|
||||||
variables: {
|
variables: {
|
||||||
main_domain: "${randomDomain}",
|
main_domain: "${domain}",
|
||||||
secret_base: "${base64:64}",
|
secret_base: "${base64:64}",
|
||||||
totp_key: "${base64:32}",
|
totp_key: "${base64:32}",
|
||||||
},
|
},
|
||||||
@@ -353,14 +353,14 @@ describe("processTemplate", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
env: {
|
env: {
|
||||||
BASE_URL: "http://${randomDomain}",
|
BASE_URL: "http://${domain}",
|
||||||
SECRET_KEY_BASE: "${password:32}",
|
SECRET_KEY_BASE: "${password:32}",
|
||||||
TOTP_VAULT_KEY: "${base64:128}",
|
TOTP_VAULT_KEY: "${base64:128}",
|
||||||
},
|
},
|
||||||
mounts: [
|
mounts: [
|
||||||
{
|
{
|
||||||
filePath: "/config/secrets.txt",
|
filePath: "/config/secrets.txt",
|
||||||
content: "random_domain=${randomDomain}\nsecret=${password:32}",
|
content: "random_domain=${domain}\nsecret=${password:32}",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ function processValue(
|
|||||||
// First replace utility functions
|
// First replace utility functions
|
||||||
let processedValue = value.replace(/\${([^}]+)}/g, (match, varName) => {
|
let processedValue = value.replace(/\${([^}]+)}/g, (match, varName) => {
|
||||||
// Handle utility functions
|
// Handle utility functions
|
||||||
if (varName === "randomDomain") {
|
if (varName === "domain") {
|
||||||
return generateRandomDomain(schema);
|
return generateRandomDomain(schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ export function processVariables(
|
|||||||
for (const [key, value] of Object.entries(template.variables)) {
|
for (const [key, value] of Object.entries(template.variables)) {
|
||||||
if (typeof value !== "string") continue;
|
if (typeof value !== "string") continue;
|
||||||
|
|
||||||
if (value === "${randomDomain}") {
|
if (value === "${domain}") {
|
||||||
variables[key] = generateRandomDomain(schema);
|
variables[key] = generateRandomDomain(schema);
|
||||||
} else if (value.startsWith("${base64:")) {
|
} else if (value.startsWith("${base64:")) {
|
||||||
const match = value.match(/\${base64:(\d+)}/);
|
const match = value.match(/\${base64:(\d+)}/);
|
||||||
|
|||||||
Reference in New Issue
Block a user