fix: API validation + Terraform plan-time validators
API (operator v0.1.13): - functions.go: добавлена валидация entrypoint (не пустой) и memory_mb (1-4096). Фиксирует БАГ-1/2/4 из негативных тестов. - triggers.go: добавлена валидация type (только 'http'/'cron'). Фиксирует БАГ-3 (неверное сообщение об ошибке). Провайдер (v0.1.7): - Добавлен пакет terraform-plugin-framework-validators v0.19.0 - function_resource: runtime OneOf, memory_mb 1-4096, timeout_sec 1-900 - trigger_resource: type OneOf(http, cron) - job_resource: run_id AtLeast(0) - examples/main.tf: обновлена версия до ~> 0.1.7 doc/errors/log.md: задокументированы исправления и результаты повторных тестов
This commit is contained in:
@@ -89,6 +89,14 @@ func (h *Handler) CreateFunction(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusBadRequest, errResp("name and runtime are required"))
|
||||
return
|
||||
}
|
||||
if req.Entrypoint == "" {
|
||||
writeJSON(w, http.StatusBadRequest, errResp("entrypoint is required"))
|
||||
return
|
||||
}
|
||||
if req.MemoryMB <= 0 || req.MemoryMB > 4096 {
|
||||
writeJSON(w, http.StatusBadRequest, errResp("memory_mb must be between 1 and 4096"))
|
||||
return
|
||||
}
|
||||
|
||||
fn := &slessv1alpha1.Function{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
||||
@@ -83,6 +83,10 @@ func (h *Handler) CreateTrigger(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusBadRequest, errResp("name, type and function are required"))
|
||||
return
|
||||
}
|
||||
if req.Type != "http" && req.Type != "cron" {
|
||||
writeJSON(w, http.StatusBadRequest, errResp("type must be \"http\" or \"cron\""))
|
||||
return
|
||||
}
|
||||
if req.Type == "cron" && req.Schedule == "" {
|
||||
writeJSON(w, http.StatusBadRequest, errResp("schedule is required for cron trigger"))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user