mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-20 10:49:51 +00:00
Updated names for schema-location vars, added documentation, updated openapi2jsonschema
This commit is contained in:
parent
300b571c33
commit
4ae74305d1
6 changed files with 59 additions and 23 deletions
|
|
@ -36,7 +36,6 @@ func (r LocalRegistry) DownloadSchema(resourceKind, resourceAPIVersion, k8sVersi
|
|||
if err != nil {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
f, err := os.Open(schemaFile)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
|
|
|||
|
|
@ -45,14 +45,16 @@ func schemaPath(tpl, resourceKind, resourceAPIVersion, k8sVersion string, strict
|
|||
}
|
||||
|
||||
tplData := struct {
|
||||
NormalizedVersion string
|
||||
StrictSuffix string
|
||||
ResourceKind string
|
||||
KindSuffix string
|
||||
NormalizedKubernetesVersion string
|
||||
StrictSuffix string
|
||||
ResourceKind string
|
||||
ResourceAPIVersion string
|
||||
KindSuffix string
|
||||
}{
|
||||
normalisedVersion,
|
||||
strictSuffix,
|
||||
strings.ToLower(resourceKind),
|
||||
groupParts[len(groupParts)-1],
|
||||
kindSuffix,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ func TestSchemaPath(t *testing.T) {
|
|||
errExpected error
|
||||
}{
|
||||
{
|
||||
"https://kubernetesjsonschema.dev/{{ .NormalizedVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json",
|
||||
"https://kubernetesjsonschema.dev/{{ .NormalizedKubernetesVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json",
|
||||
"Deployment",
|
||||
"apps/v1",
|
||||
"1.16.0",
|
||||
|
|
@ -20,7 +20,7 @@ func TestSchemaPath(t *testing.T) {
|
|||
nil,
|
||||
},
|
||||
{
|
||||
"https://kubernetesjsonschema.dev/{{ .NormalizedVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json",
|
||||
"https://kubernetesjsonschema.dev/{{ .NormalizedKubernetesVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json",
|
||||
"Deployment",
|
||||
"apps/v1",
|
||||
"1.16.0",
|
||||
|
|
@ -29,7 +29,7 @@ func TestSchemaPath(t *testing.T) {
|
|||
nil,
|
||||
},
|
||||
{
|
||||
"https://kubernetesjsonschema.dev/{{ .NormalizedVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json",
|
||||
"https://kubernetesjsonschema.dev/{{ .NormalizedKubernetesVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json",
|
||||
"Service",
|
||||
"v1",
|
||||
"1.18.0",
|
||||
|
|
@ -38,7 +38,7 @@ func TestSchemaPath(t *testing.T) {
|
|||
nil,
|
||||
},
|
||||
{
|
||||
"https://kubernetesjsonschema.dev/{{ .NormalizedVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json",
|
||||
"https://kubernetesjsonschema.dev/{{ .NormalizedKubernetesVersion }}-standalone{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json",
|
||||
"Service",
|
||||
"v1",
|
||||
"master",
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ func FromStream(ctx context.Context, path string, r io.Reader) (<-chan Resource,
|
|||
|
||||
go func() {
|
||||
scanner := bufio.NewScanner(r)
|
||||
const maxResourceSize = 1024 * 1024
|
||||
buf := make([]byte, maxResourceSize)
|
||||
scanner.Buffer(buf, maxResourceSize)
|
||||
scanner.Split(SplitYAMLDocument)
|
||||
|
||||
SCAN:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue