add {{ .Group }} variable to schema location options (#120)

This commit is contained in:
hadar-co 2022-07-16 15:13:17 +03:00 committed by GitHub
parent 9a6fff13cb
commit 5e63bc5ad7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View file

@ -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 * *StrictSuffix* - "-strict" or "" depending on whether validation is running in strict mode or not
* *ResourceKind* - Kind of the Kubernetes Resource * *ResourceKind* - Kind of the Kubernetes Resource
* *ResourceAPIVersion* - Version of API used for the resource - "v1" in "apiVersion: monitoring.coreos.com/v1" * *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 * *KindSuffix* - suffix computed from apiVersion - for compatibility with Kubeval schema registries
### Converting an OpenAPI file to a JSON Schema ### Converting an OpenAPI file to a JSON Schema

View file

@ -61,12 +61,14 @@ func schemaPath(tpl, resourceKind, resourceAPIVersion, k8sVersion string, strict
StrictSuffix string StrictSuffix string
ResourceKind string ResourceKind string
ResourceAPIVersion string ResourceAPIVersion string
Group string
KindSuffix string KindSuffix string
}{ }{
normalisedVersion, normalisedVersion,
strictSuffix, strictSuffix,
strings.ToLower(resourceKind), strings.ToLower(resourceKind),
groupParts[len(groupParts)-1], groupParts[len(groupParts)-1],
groupParts[0],
kindSuffix, kindSuffix,
} }