From 398e8be6e8fcf0ebdf9c30d44550c5ca1777ae4e Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Mon, 12 May 2025 11:59:54 +0100 Subject: [PATCH] encoding/jsonschema: recognize date-time too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Kubernetes documentation is inconsistent about whether the correct spelling is `datetime` or `date-time`. After digging into the code a bit, it seems that both forms are accepted (and also weird variants like `--date--time`, but we'll ignore that possibility). See this comment for some background [1]. [1] https://github.com/kubernetes/kubernetes/issues/131082#issuecomment-2872063205 Signed-off-by: Roger Peppe Change-Id: Idcc5175536b1df3044e27d68c3c400713e711c0d Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1214780 TryBot-Result: CUEcueckoo Reviewed-by: Daniel Martí --- encoding/jsonschema/constraints_format.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoding/jsonschema/constraints_format.go b/encoding/jsonschema/constraints_format.go index b793f48cb..22728b0a2 100644 --- a/encoding/jsonschema/constraints_format.go +++ b/encoding/jsonschema/constraints_format.go @@ -39,7 +39,7 @@ var formatFuncs = sync.OnceValue(func() map[string]formatFuncInfo { "creditcard": {k8s, formatTODO}, "data": {openAPI, formatTODO}, "date": {vfrom(VersionDraft7) | openAPI | k8s, formatDate}, - "date-time": {allVersions | openAPI, formatDateTime}, + "date-time": {allVersions | openAPI | k8s, formatDateTime}, "datetime": {k8s, formatDateTime}, "double": {openAPI | k8s, formatTODO}, "duration": {vfrom(VersionDraft2019_09) | k8s, formatTODO}, -- 2.51.2