From 1770a9b84b76186f7dedff02864249c150e46be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Sun, 8 Mar 2026 10:10:32 +0400 Subject: [PATCH] feat: trigger.enabled + job.run_id lifecycle control (operator v0.1.6, provider v0.1.4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- hello-node/http.tf | 2 ++ hello-node/job.tf | 2 ++ hello-node/main.tf | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hello-node/http.tf b/hello-node/http.tf index ee255cd..e0678ca 100644 --- a/hello-node/http.tf +++ b/hello-node/http.tf @@ -30,6 +30,8 @@ resource "sless_trigger" "hello_http" { name = "hello-http-trigger" type = "http" function = sless_function.hello_http.name + # enabled = false — чтобы заморозить функцию (не удаляя ресурс), потом поставить зновь true + enabled = true } output "trigger_url" { diff --git a/hello-node/job.tf b/hello-node/job.tf index 23097dc..8687f77 100644 --- a/hello-node/job.tf +++ b/hello-node/job.tf @@ -28,12 +28,14 @@ resource "sless_function" "hello_job" { } # Одноразовый запуск. Все поля immutable — изменение любого пересоздаёт джоб. +# run_id: 0 = не запускать, 1+ = запустить. Для повторного запуска увеличь run_id (1→2→3...). resource "sless_job" "hello_run" { namespace = "default" name = "hello-run" function = sless_function.hello_job.name event_json = jsonencode({ numbers = [1, 2, 3, 4, 5] }) wait_timeout_sec = 120 + run_id = 1 } output "job_phase" { diff --git a/hello-node/main.tf b/hello-node/main.tf index 0bd5b5c..6e11712 100644 --- a/hello-node/main.tf +++ b/hello-node/main.tf @@ -8,7 +8,7 @@ terraform { required_providers { sless = { source = "terra.k8c.ru/naeel/sless" - version = "~> 0.1.1" + version = "~> 0.1.4" } archive = { source = "hashicorp/archive"