mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-08 04:55:17 +00:00
feat: add validation to prevent use of 'production' as environment name in creation and update operations, enhancing error handling in environment management
This commit is contained in:
@@ -58,6 +58,13 @@ export const environmentRouter = createTRPCRouter({
|
|||||||
// This would typically involve checking project ownership/membership
|
// This would typically involve checking project ownership/membership
|
||||||
// For now, we'll use a basic organization check
|
// For now, we'll use a basic organization check
|
||||||
|
|
||||||
|
if (input.name === "production") {
|
||||||
|
throw new TRPCError({
|
||||||
|
code: "BAD_REQUEST",
|
||||||
|
message: "Environment name cannot be production",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const environment = await createEnvironment(input);
|
const environment = await createEnvironment(input);
|
||||||
|
|
||||||
if (ctx.user.role === "member") {
|
if (ctx.user.role === "member") {
|
||||||
@@ -229,6 +236,14 @@ export const environmentRouter = createTRPCRouter({
|
|||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
try {
|
try {
|
||||||
const { environmentId, ...updateData } = input;
|
const { environmentId, ...updateData } = input;
|
||||||
|
|
||||||
|
if (updateData.name === "production") {
|
||||||
|
throw new TRPCError({
|
||||||
|
code: "BAD_REQUEST",
|
||||||
|
message: "Environment name cannot be production",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (ctx.user.role === "member") {
|
if (ctx.user.role === "member") {
|
||||||
await checkEnvironmentAccess(
|
await checkEnvironmentAccess(
|
||||||
ctx.user.id,
|
ctx.user.id,
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export const runWebServerBackup = async (backup: BackupSchedule) => {
|
|||||||
writeStream.write("Zipped database and filesystem\n");
|
writeStream.write("Zipped database and filesystem\n");
|
||||||
|
|
||||||
const uploadCommand = `rclone copyto ${rcloneFlags.join(" ")} "${tempDir}/${backupFileName}" "${s3Path}"`;
|
const uploadCommand = `rclone copyto ${rcloneFlags.join(" ")} "${tempDir}/${backupFileName}" "${s3Path}"`;
|
||||||
writeStream.write(`Running command: ${uploadCommand}\n`);
|
writeStream.write("Running command to upload backup to S3\n");
|
||||||
await execAsync(uploadCommand);
|
await execAsync(uploadCommand);
|
||||||
writeStream.write("Uploaded backup to S3 ✅\n");
|
writeStream.write("Uploaded backup to S3 ✅\n");
|
||||||
writeStream.end();
|
writeStream.end();
|
||||||
|
|||||||
Reference in New Issue
Block a user