sless-primer/simple-node/time-getter.tf
“Naeel” 695f217e13 feat: operator v0.1.16 — job stdout -> status.Message (feature B)
- FunctionJobReconciler: added KubeClient field (kubernetes.Interface)
- getJobPodOutput(): reads pod logs via typed client after job succeeds
- main.go: inject kubernetes.NewForConfigOrDie into FunctionJobReconciler
- rbac.yaml: add pods/pods/log get/list/watch permissions
- examples/simple-python/: job->function chain demo (Python)
- examples/simple-node/: job->function chain demo (Node.js)

sless_job.X.message now contains the return value of the function
2026-03-09 14:50:06 +04:00

37 lines
1.4 KiB
HCL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Создано: 2026-03-09
# time-getter.tf — одноразовая функция + джоб запускающий её при apply.
# sless_job.run_getter.message после apply содержит stdout runner-а:
# {"time":"2026-03-09T12:34:56.789Z"}
# Это значение terraform записывает в env JOB_TIME функции time_display.
# Упаковываем код функции в zip
data "archive_file" "time_getter_zip" {
type = "zip"
source_dir = "${path.module}/code/time_getter"
output_path = "${path.module}/dist/time_getter.zip"
}
# Функция-вычислитель: запускается только джобом, не имеет HTTP-триггера
resource "sless_function" "time_getter" {
namespace = "default"
name = "simple-node-time-getter"
runtime = "nodejs20"
entrypoint = "time_getter.getTime"
memory_mb = 64
code_path = data.archive_file.time_getter_zip.output_path
code_hash = filesha256("${path.module}/code/time_getter/time_getter.js")
}
# Джоб: запускает time_getter один раз при terraform apply.
resource "sless_job" "run_getter" {
namespace = "default"
name = "simple-node-getter-run"
function = sless_function.time_getter.name
run_id = 1
wait_timeout_sec = 120
event_json = "{}"
depends_on = [sless_function.time_getter]
}