From 99ef17d62f1d1dc376510450ff5a134dd20a26f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Sun, 8 Mar 2026 20:34:00 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20=D1=83=D0=B1=D1=80=D0=B0=D1=82=D1=8C=20U?= =?UTF-8?q?seStateForUnknown=20=D1=81=20image=5Fref,=20provider=20v0.1.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/hello-node/code/handler-http.js | 2 +- examples/hello-node/handler-http.zip | Bin 410 -> 413 bytes examples/hello-node/http.tf | 4 +++- examples/hello-node/job.tf | 3 ++- examples/hello-node/main.tf | 2 +- .../internal/resources/function_resource.go | 6 +++--- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/hello-node/code/handler-http.js b/examples/hello-node/code/handler-http.js index ec016dc..9766375 100644 --- a/examples/hello-node/code/handler-http.js +++ b/examples/hello-node/code/handler-http.js @@ -3,6 +3,6 @@ // Используется с sless_trigger (постоянный эндпоинт). exports.handle = async (event) => { const name = event.name || 'World'; - return { message: `Hello, ${name}!` }; + return { message: `Hello, ${name}! HTTP ` }; }; diff --git a/examples/hello-node/handler-http.zip b/examples/hello-node/handler-http.zip index 03b93538014f4381c2ca397b0e112812fbb2c108..8ce3f7ddbf43a1d10027b2581382d93a2964c7a7 100644 GIT binary patch delta 329 zcmV-P0k-~{1DykqE`N~EN&-r(e&@%>@qN^)wG+2`>{d@5-^U<`dZE(pz}k^_ZSXUD zL#y3BcjZBr%=jgbOl4IE6YjWWA~UY#iED0T0q$kSlt~_BE`JLqOu6xLG2dm*J$L+; z7j9+wkE|ebm{1vWY4ugVuQbXzRe9cH&l#-Ri01`xpdKFI3tcSUd8r4Sr^C zXtmqtt~|(+8NcL_sjTW?!X39vWX82Tam|e^z`e|vGRcF?Wq-khDK}m|%y*e{&mF(z zg2bux>b>_pm~O|0|4DPG8R!V%uR9hiZGd=bP?;YS85baD|@3Oj4@Qk1btOUr=`L$ zKEmNRFH8?Qm^3z=X~S`T0{{U3|4>T@2&Fe%cnSdk05|~v08mQ-0u%!j00;mG0000X YilsMPcnSdk063Fl0W=0j0RR910Jrput^fc4 diff --git a/examples/hello-node/http.tf b/examples/hello-node/http.tf index e0678ca..c45fd6a 100644 --- a/examples/hello-node/http.tf +++ b/examples/hello-node/http.tf @@ -22,7 +22,9 @@ resource "sless_function" "hello_http" { timeout_sec = 30 code_path = data.archive_file.handler_http.output_path - code_hash = data.archive_file.handler_http.output_md5 + # filesha256 исходного файла — надёжнее чем output_md5 zip: + # MD5 zip зависит от метаданных архива и может совпасть при разном содержимом + code_hash = filesha256("${path.module}/code/handler-http.js") } resource "sless_trigger" "hello_http" { diff --git a/examples/hello-node/job.tf b/examples/hello-node/job.tf index 5692465..59b2d27 100644 --- a/examples/hello-node/job.tf +++ b/examples/hello-node/job.tf @@ -24,7 +24,8 @@ resource "sless_function" "hello_job" { timeout_sec = 30 code_path = data.archive_file.handler_job.output_path - code_hash = data.archive_file.handler_job.output_md5 + # filesha256 исходного файла — надёжнее чем output_md5 zip + code_hash = filesha256("${path.module}/code/handler-job.js") } # Одноразовый запуск. Все поля immutable — изменение любого пересоздаёт джоб. diff --git a/examples/hello-node/main.tf b/examples/hello-node/main.tf index 6e11712..b861a85 100644 --- a/examples/hello-node/main.tf +++ b/examples/hello-node/main.tf @@ -8,7 +8,7 @@ terraform { required_providers { sless = { source = "terra.k8c.ru/naeel/sless" - version = "~> 0.1.4" + version = "~> 0.1.5" } archive = { source = "hashicorp/archive" diff --git a/terraform/provider/internal/resources/function_resource.go b/terraform/provider/internal/resources/function_resource.go index 00348d5..afd7521 100644 --- a/terraform/provider/internal/resources/function_resource.go +++ b/terraform/provider/internal/resources/function_resource.go @@ -131,11 +131,11 @@ func (r *FunctionResource) Schema(_ context.Context, _ resource.SchemaRequest, r stringplanmodifier.UseStateForUnknown(), }, }, + // image_ref — только для чтения, вычисляется оператором после сборки образа. + // Намеренно без UseStateForUnknown: при пересборке (смена code_hash) image_ref + // может измениться (например смена registry), поэтому всегда (known after apply). "image_ref": schema.StringAttribute{ Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, }, }, }