fix: откат 409-fallback из клиента провайдера (provider v0.1.6 не опубликован с изменениями)
- terraform/provider/internal/client/client.go: откат 409 fallback для CreateFunction, CreateTrigger, CreateJob — import не нужен в данном провайдере, 409 должен быть ошибкой - examples/hello-node/main.tf: версия провайдера ~> 0.1.6 (опубликована без изменений клиента — только исходная версия кода) - examples/hello-node/job.tf: run_id=9, numbers=[100,200,300] Тесты пройдены: plan(no-changes), state-rm+apply, code update, run_id++, destroy+apply
This commit is contained in:
parent
18d2555562
commit
b73591131a
@ -1,10 +1,11 @@
|
|||||||
// 2026-03-08
|
// 2026-03-08
|
||||||
// handler-job.js — batch-функция: суммирует числа из переданного массива.
|
// handler-job.js — batch-функция: суммирует числа и считает среднее.
|
||||||
// Используется с sless_job (одноразовый запуск).
|
// Используется с sless_job (одноразовый запуск).
|
||||||
// event.numbers — массив чисел, например [1, 2, 3, 4, 5]
|
// event.numbers — массив чисел, например [1, 2, 3, 4, 5]
|
||||||
exports.handle = async (event) => {
|
exports.handle = async (event) => {
|
||||||
const numbers = event.numbers || [];
|
const numbers = event.numbers || [];
|
||||||
const sum = numbers.reduce((acc, n) => acc + n, 0);
|
const sum = numbers.reduce((acc, n) => acc + n, 0);
|
||||||
return { input: numbers, sum, count: numbers.length };
|
const avg = numbers.length > 0 ? sum / numbers.length : 0;
|
||||||
|
return { input: numbers, sum, avg, count: numbers.length };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -34,9 +34,9 @@ resource "sless_job" "hello_run" {
|
|||||||
namespace = "default"
|
namespace = "default"
|
||||||
name = "hello-run"
|
name = "hello-run"
|
||||||
function = sless_function.hello_job.name
|
function = sless_function.hello_job.name
|
||||||
event_json = jsonencode({ numbers = [1, 2, 3, 4, 5] })
|
event_json = jsonencode({ numbers = [100, 200, 300] })
|
||||||
wait_timeout_sec = 600
|
wait_timeout_sec = 600
|
||||||
run_id = 7
|
run_id = 9
|
||||||
}
|
}
|
||||||
|
|
||||||
output "job_phase" {
|
output "job_phase" {
|
||||||
|
|||||||
@ -8,7 +8,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
sless = {
|
sless = {
|
||||||
source = "terra.k8c.ru/naeel/sless"
|
source = "terra.k8c.ru/naeel/sless"
|
||||||
version = "~> 0.1.5"
|
version = "~> 0.1.6"
|
||||||
}
|
}
|
||||||
archive = {
|
archive = {
|
||||||
source = "hashicorp/archive"
|
source = "hashicorp/archive"
|
||||||
|
|||||||
209
hello-node/terraform.tfstate.1773029146.backup
Normal file
209
hello-node/terraform.tfstate.1773029146.backup
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
{
|
||||||
|
"version": 4,
|
||||||
|
"terraform_version": "1.12.2",
|
||||||
|
"serial": 68,
|
||||||
|
"lineage": "d12fc078-7aee-39d1-629d-358c3c135820",
|
||||||
|
"outputs": {
|
||||||
|
"job_completion_time": {
|
||||||
|
"value": "2026-03-08T17:10:15Z",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"job_message": {
|
||||||
|
"value": "completed successfully",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"job_phase": {
|
||||||
|
"value": "Succeeded",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"trigger_url": {
|
||||||
|
"value": "https://sless-api.kube5s.ru/fn/default/hello-http",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"resources": [
|
||||||
|
{
|
||||||
|
"mode": "data",
|
||||||
|
"type": "archive_file",
|
||||||
|
"name": "handler_http",
|
||||||
|
"provider": "provider[\"registry.terraform.io/hashicorp/archive\"]",
|
||||||
|
"instances": [
|
||||||
|
{
|
||||||
|
"schema_version": 0,
|
||||||
|
"attributes": {
|
||||||
|
"exclude_symlink_directories": null,
|
||||||
|
"excludes": null,
|
||||||
|
"id": "af56405ad089f54b3382b1f8bbf648e9a4020186",
|
||||||
|
"output_base64sha256": "5k1JGBxCX5TLgrWRw8F4O3rMWu/4dprgLd9EH+maLx4=",
|
||||||
|
"output_base64sha512": "E6SsXf62mq4oPTpoiH9LXKdCy0nq4o8bANVfkYqd5JTvIGxXr/ow7DYqotFvJc1GIFMyo4etB54CKVduAEzWDw==",
|
||||||
|
"output_file_mode": null,
|
||||||
|
"output_md5": "8f2434a1fe0b8f791c4c39848c1c1db0",
|
||||||
|
"output_path": "./handler-http.zip",
|
||||||
|
"output_sha": "af56405ad089f54b3382b1f8bbf648e9a4020186",
|
||||||
|
"output_sha256": "e64d49181c425f94cb82b591c3c1783b7acc5aeff8769ae02ddf441fe99a2f1e",
|
||||||
|
"output_sha512": "13a4ac5dfeb69aae283d3a68887f4b5ca742cb49eae28f1b00d55f918a9de494ef206c57affa30ec362aa2d16f25cd46205332a387ad079e0229576e004cd60f",
|
||||||
|
"output_size": 419,
|
||||||
|
"source": [],
|
||||||
|
"source_content": null,
|
||||||
|
"source_content_filename": null,
|
||||||
|
"source_dir": null,
|
||||||
|
"source_file": "./code/handler-http.js",
|
||||||
|
"type": "zip"
|
||||||
|
},
|
||||||
|
"sensitive_attributes": [],
|
||||||
|
"identity_schema_version": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mode": "data",
|
||||||
|
"type": "archive_file",
|
||||||
|
"name": "handler_job",
|
||||||
|
"provider": "provider[\"registry.terraform.io/hashicorp/archive\"]",
|
||||||
|
"instances": [
|
||||||
|
{
|
||||||
|
"schema_version": 0,
|
||||||
|
"attributes": {
|
||||||
|
"exclude_symlink_directories": null,
|
||||||
|
"excludes": null,
|
||||||
|
"id": "e9056d193119214fe75cb187ca287199eaf326c9",
|
||||||
|
"output_base64sha256": "MbwoybKGBrsT3T/MrloAK0g+lu4qPCnAo1M0vAqR83Y=",
|
||||||
|
"output_base64sha512": "CHrmv338w4YGroUNZC7zR5vlgJvmrep5jToVJlPWjzEVeMO9J+eucD9LXzg89kzDsN/lVgCfQ3TvRE5RsOxugA==",
|
||||||
|
"output_file_mode": null,
|
||||||
|
"output_md5": "4aeae366572f35f199937c40c3708120",
|
||||||
|
"output_path": "./handler-job.zip",
|
||||||
|
"output_sha": "e9056d193119214fe75cb187ca287199eaf326c9",
|
||||||
|
"output_sha256": "31bc28c9b28606bb13dd3fccae5a002b483e96ee2a3c29c0a35334bc0a91f376",
|
||||||
|
"output_sha512": "087ae6bf7dfcc38606ae850d642ef3479be5809be6adea798d3a152653d68f311578c3bd27e7ae703f4b5f383cf64cc3b0dfe556009f4374ef444e51b0ec6e80",
|
||||||
|
"output_size": 506,
|
||||||
|
"source": [],
|
||||||
|
"source_content": null,
|
||||||
|
"source_content_filename": null,
|
||||||
|
"source_dir": null,
|
||||||
|
"source_file": "./code/handler-job.js",
|
||||||
|
"type": "zip"
|
||||||
|
},
|
||||||
|
"sensitive_attributes": [],
|
||||||
|
"identity_schema_version": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mode": "managed",
|
||||||
|
"type": "sless_function",
|
||||||
|
"name": "hello_http",
|
||||||
|
"provider": "provider[\"terra.k8c.ru/naeel/sless\"]",
|
||||||
|
"instances": [
|
||||||
|
{
|
||||||
|
"schema_version": 0,
|
||||||
|
"attributes": {
|
||||||
|
"build_timeout_sec": 300,
|
||||||
|
"code_hash": "c9755d3a41cd22734918ed9c6350394cb70ddc4104031bcd8edd5e5fed9a1963",
|
||||||
|
"code_path": "./handler-http.zip",
|
||||||
|
"entrypoint": "handler-http.handle",
|
||||||
|
"env_vars": null,
|
||||||
|
"image_ref": "naeel/sless-default-hello-http:072b89774248",
|
||||||
|
"memory_mb": 128,
|
||||||
|
"name": "hello-http",
|
||||||
|
"namespace": "default",
|
||||||
|
"phase": "Ready",
|
||||||
|
"runtime": "nodejs20",
|
||||||
|
"timeout_sec": 30
|
||||||
|
},
|
||||||
|
"sensitive_attributes": [],
|
||||||
|
"identity_schema_version": 0,
|
||||||
|
"dependencies": [
|
||||||
|
"data.archive_file.handler_http"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mode": "managed",
|
||||||
|
"type": "sless_function",
|
||||||
|
"name": "hello_job",
|
||||||
|
"provider": "provider[\"terra.k8c.ru/naeel/sless\"]",
|
||||||
|
"instances": [
|
||||||
|
{
|
||||||
|
"schema_version": 0,
|
||||||
|
"attributes": {
|
||||||
|
"build_timeout_sec": 300,
|
||||||
|
"code_hash": "4155f9367b1999fb0f80460e919dac79b6af559a603cf938d70a2a322fccc7ec",
|
||||||
|
"code_path": "./handler-job.zip",
|
||||||
|
"entrypoint": "handler-job.handle",
|
||||||
|
"env_vars": null,
|
||||||
|
"image_ref": "naeel/sless-default-hello-job:67f12d5519e3",
|
||||||
|
"memory_mb": 128,
|
||||||
|
"name": "hello-job",
|
||||||
|
"namespace": "default",
|
||||||
|
"phase": "Ready",
|
||||||
|
"runtime": "nodejs20",
|
||||||
|
"timeout_sec": 30
|
||||||
|
},
|
||||||
|
"sensitive_attributes": [],
|
||||||
|
"identity_schema_version": 0,
|
||||||
|
"dependencies": [
|
||||||
|
"data.archive_file.handler_job"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mode": "managed",
|
||||||
|
"type": "sless_job",
|
||||||
|
"name": "hello_run",
|
||||||
|
"provider": "provider[\"terra.k8c.ru/naeel/sless\"]",
|
||||||
|
"instances": [
|
||||||
|
{
|
||||||
|
"schema_version": 0,
|
||||||
|
"attributes": {
|
||||||
|
"completion_time": "2026-03-08T17:10:15Z",
|
||||||
|
"event_json": "{\"numbers\":[10,20,30,40,50]}",
|
||||||
|
"function": "hello-job",
|
||||||
|
"message": "completed successfully",
|
||||||
|
"name": "hello-run",
|
||||||
|
"namespace": "default",
|
||||||
|
"phase": "Succeeded",
|
||||||
|
"run_id": 8,
|
||||||
|
"start_time": "2026-03-08T17:10:05Z",
|
||||||
|
"wait_timeout_sec": 600
|
||||||
|
},
|
||||||
|
"sensitive_attributes": [],
|
||||||
|
"identity_schema_version": 0,
|
||||||
|
"dependencies": [
|
||||||
|
"data.archive_file.handler_job",
|
||||||
|
"sless_function.hello_job"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mode": "managed",
|
||||||
|
"type": "sless_trigger",
|
||||||
|
"name": "hello_http",
|
||||||
|
"provider": "provider[\"terra.k8c.ru/naeel/sless\"]",
|
||||||
|
"instances": [
|
||||||
|
{
|
||||||
|
"schema_version": 0,
|
||||||
|
"attributes": {
|
||||||
|
"active": true,
|
||||||
|
"enabled": true,
|
||||||
|
"function": "hello-http",
|
||||||
|
"name": "hello-http-trigger",
|
||||||
|
"namespace": "default",
|
||||||
|
"schedule": null,
|
||||||
|
"type": "http",
|
||||||
|
"url": "https://sless-api.kube5s.ru/fn/default/hello-http"
|
||||||
|
},
|
||||||
|
"sensitive_attributes": [],
|
||||||
|
"identity_schema_version": 0,
|
||||||
|
"dependencies": [
|
||||||
|
"data.archive_file.handler_http",
|
||||||
|
"sless_function.hello_http"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"check_results": null
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user