From fb921056bbe19d82b8543628f09ea85d52cb84b1 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 6 Feb 2026 07:52:05 +0000 Subject: [PATCH 1/2] fix: embed timezone database via time/tzdata import Adds `_ "time/tzdata"` import to main.go so the provider binary includes an embedded copy of the IANA Time Zone database. This ensures timezone operations work correctly even when the host system lacks tzdata (e.g. scratch/distroless Docker images). Fixes #470 --- main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.go b/main.go index ef606a6d..4c9a562e 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,9 @@ package main import ( "flag" + // Embed timezone data for use in environments that may not have the + // timezone database available (e.g. scratch Docker images). + _ "time/tzdata" "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" From ad259254f5195c2d363563eb76c340c602207656 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 6 Feb 2026 08:22:51 +0000 Subject: [PATCH 2/2] test: use non-UTC timezone in integration test to exercise tzdata embed Changes the integration test for coder_workspace_preset scheduling from timezone = "UTC" to timezone = "America/New_York". UTC is hardcoded in Go and always works regardless of tzdata availability, so it never caught the bug described in #470. Using a real IANA timezone like America/New_York ensures the test exercises time.LoadLocation against the timezone database and will fail in environments without system tzdata unless the time/tzdata package is embedded in the binary. Also removes the overzealous AST-based main_test.go that was added previously. Refs #470 --- integration/integration_test.go | 2 +- integration/test-data-source/main.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/integration_test.go b/integration/integration_test.go index bc6fac96..765ae117 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -99,7 +99,7 @@ func TestIntegration(t *testing.T) { "workspace_preset.parameters.param": `preset param value`, "workspace_preset.prebuilds.instances": `1`, "workspace_preset.prebuilds.expiration_policy.ttl": `86400`, - "workspace_preset.prebuilds.scheduling.timezone": `UTC`, + "workspace_preset.prebuilds.scheduling.timezone": `America/New_York`, "workspace_preset.prebuilds.scheduling.schedule0.cron": `\* 8-18 \* \* 1-5`, "workspace_preset.prebuilds.scheduling.schedule0.instances": `3`, "workspace_preset.prebuilds.scheduling.schedule1.cron": `\* 8-14 \* \* 6`, diff --git a/integration/test-data-source/main.tf b/integration/test-data-source/main.tf index cc4802d3..b3093418 100644 --- a/integration/test-data-source/main.tf +++ b/integration/test-data-source/main.tf @@ -34,7 +34,7 @@ data "coder_workspace_preset" "preset" { ttl = 86400 } scheduling { - timezone = "UTC" + timezone = "America/New_York" schedule { cron = "* 8-18 * * 1-5" instances = 3