From 5e63bc5ad7bf82895bd91c19e2ee160d0ffd9964 Mon Sep 17 00:00:00 2001 From: hadar-co Date: Sat, 16 Jul 2022 15:13:17 +0300 Subject: [PATCH] add {{ .Group }} variable to schema location options (#120) --- Readme.md | 1 + pkg/registry/registry.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Readme.md b/Readme.md index e791dd9..6a998ef 100644 --- a/Readme.md +++ b/Readme.md @@ -194,6 +194,7 @@ Here are the variables you can use in -schema-location: * *StrictSuffix* - "-strict" or "" depending on whether validation is running in strict mode or not * *ResourceKind* - Kind of the Kubernetes Resource * *ResourceAPIVersion* - Version of API used for the resource - "v1" in "apiVersion: monitoring.coreos.com/v1" + * *Group* - the group name as stated in this resource's definition - "monitoring.coreos.com" in "apiVersion: monitoring.coreos.com/v1" * *KindSuffix* - suffix computed from apiVersion - for compatibility with Kubeval schema registries ### Converting an OpenAPI file to a JSON Schema diff --git a/pkg/registry/registry.go b/pkg/registry/registry.go index 40f7cae..b5451ff 100644 --- a/pkg/registry/registry.go +++ b/pkg/registry/registry.go @@ -61,12 +61,14 @@ func schemaPath(tpl, resourceKind, resourceAPIVersion, k8sVersion string, strict StrictSuffix string ResourceKind string ResourceAPIVersion string + Group string KindSuffix string }{ normalisedVersion, strictSuffix, strings.ToLower(resourceKind), groupParts[len(groupParts)-1], + groupParts[0], kindSuffix, }