feat: trigger.enabled + job.run_id lifecycle control (operator v0.1.6, provider v0.1.4)

- TriggerSpec.Enabled bool (default=true): enabled=false масштабирует Deployment до 0
- FunctionJobSpec.RunID int64 (default=0): run_id=0 = skip, >0 = run
- API: PATCH /v1/namespaces/{ns}/triggers/{name} (UpdateTrigger)
- Provider: enabled attribute (Optional, Computed, in-place update)
- Provider: run_id attribute (Optional, Computed, default=0, RequiresReplace)
- operator image: naeel/sless-operator:v0.1.6
- provider: terra.k8c.ru/naeel/sless v0.1.4
This commit is contained in:
“Naeel”
2026-03-08 10:10:32 +04:00
parent 8fb0ef5ea1
commit d67b9745a8
20 changed files with 509 additions and 143 deletions
+6 -1
View File
@@ -1,4 +1,4 @@
// Изменено: 2026-03-07
// Изменено: 2026-03-08
// jobs.go — CRUD handlers для FunctionJob CRD.
// Создаёт/читает/удаляет k8s FunctionJob ресурсы.
// Namespace берётся из URL: /v1/namespaces/{namespace}/jobs/{name}
@@ -21,6 +21,8 @@ type jobRequest struct {
Name string `json:"name"`
FunctionRef string `json:"function"`
EventJSON string `json:"event_json,omitempty"`
// RunID — идентификатор запуска. 0 = создать без запуска, >0 = запустить.
RunID int64 `json:"run_id"`
}
// jobResponse — ответ при чтении / создании FunctionJob
@@ -29,6 +31,7 @@ type jobResponse struct {
Namespace string `json:"namespace"`
FunctionRef string `json:"function"`
EventJSON string `json:"event_json"`
RunID int64 `json:"run_id"`
Phase string `json:"phase"`
JobName string `json:"job_name,omitempty"`
StartTime string `json:"start_time,omitempty"`
@@ -43,6 +46,7 @@ func jobToResponse(j *slessv1alpha1.FunctionJob) jobResponse {
Namespace: j.Namespace,
FunctionRef: j.Spec.FunctionRef,
EventJSON: j.Spec.EventJSON,
RunID: j.Spec.RunID,
Phase: string(j.Status.Phase),
JobName: j.Status.JobName,
Message: j.Status.Message,
@@ -86,6 +90,7 @@ func (h *Handler) CreateJob(w http.ResponseWriter, r *http.Request) {
Spec: slessv1alpha1.FunctionJobSpec{
FunctionRef: req.FunctionRef,
EventJSON: req.EventJSON,
RunID: req.RunID,
},
}