[Fix] 🐛 PreCheck the Config if Instance has Changed #21

This commit is contained in:
Harry-zklcdc
2025-03-30 01:25:21 +08:00
parent 69554b5e39
commit 011827f5c7
3 changed files with 35 additions and 5 deletions
+11 -1
View File
@@ -66,7 +66,17 @@ func modifyHandler(ctx iris.Context) {
return
}
if req.CpuOnly == instance.CpuOnly && req.CpuOnly {
hasChanges := false
if req.CpuOnly != instance.CpuOnly {
hasChanges = true
}
if req.GpuCount != nil && *req.GpuCount != instance.GpuCount {
hasChanges = true
}
if req.VolumeSize != nil && *req.VolumeSize != instance.VolumeSize {
hasChanges = true
}
if !hasChanges {
middleware.Error(ctx, middleware.CodeBadRequest, iris.StatusBadRequest)
return
}
+11 -1
View File
@@ -72,7 +72,17 @@ func modifyHandler(ctx iris.Context) {
return
}
if req.CpuOnly == instance.CpuOnly && req.CpuOnly {
hasChanges := false
if req.CpuOnly != instance.CpuOnly {
hasChanges = true
}
if req.GpuCount != nil && *req.GpuCount != instance.GpuCount {
hasChanges = true
}
if req.VolumeSize != nil && *req.VolumeSize != instance.VolumeSize {
hasChanges = true
}
if !hasChanges {
middleware.Error(ctx, middleware.CodeBadRequest, iris.StatusBadRequest)
return
}