This commit is contained in:
Andras Bacsai
2022-10-26 10:12:17 +02:00
parent 54e0a9fc28
commit c34de3d0a3
8 changed files with 181 additions and 182 deletions

View File

@@ -258,9 +258,7 @@ export async function saveServiceType(request: FastifyRequest<SaveServiceType>,
const regex = /^\$\$.*\((\d+)\)$/g;
const length = Number(regex.exec(defaultValue)?.[1]) || undefined
if (variable.defaultValue.startsWith('$$generate_password')) {
console.log(variable)
variable.value = generatePassword({ length });
console.log(variable.value)
} else if (variable.defaultValue.startsWith('$$generate_hex')) {
variable.value = generatePassword({ length, isHex: true });
} else if (variable.defaultValue.startsWith('$$generate_username')) {
@@ -268,6 +266,10 @@ export async function saveServiceType(request: FastifyRequest<SaveServiceType>,
} else {
variable.value = variable.defaultValue || '';
}
const foundVariableSomewhereElse = foundTemplate.variables.find(v => v.defaultValue.includes(variable.id))
if (foundVariableSomewhereElse) {
foundVariableSomewhereElse.value = foundVariableSomewhereElse.value.replaceAll(variable.id, variable.value)
}
}
}
for (const variable of foundTemplate.variables) {