mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-22 11:17:01 +00:00
Merge branch 'master' into add-support-for-duration
This commit is contained in:
commit
c6f80859ab
9 changed files with 22151 additions and 9578 deletions
|
|
@ -19,3 +19,8 @@
|
||||||
run bin/kubeconform -schema-location 'fixtures/{{ .ResourceKind }}.json' -schema-location './fixtures/registry/{{ .ResourceKind }}{{ .KindSuffix }}.json' fixtures/test_crd.yaml
|
run bin/kubeconform -schema-location 'fixtures/{{ .ResourceKind }}.json' -schema-location './fixtures/registry/{{ .ResourceKind }}{{ .KindSuffix }}.json' fixtures/test_crd.yaml
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "Pass when using a cached schema with external references" {
|
||||||
|
run bin/kubeconform -cache fixtures/cache -summary -schema-location 'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/{{ .NormalizedKubernetesVersion }}{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json' fixtures/valid.yaml
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -276,6 +276,13 @@ resetCacheFolder() {
|
||||||
[ "$output" = "failed opening cache folder cache_does_not_exist: stat cache_does_not_exist: no such file or directory" ]
|
[ "$output" = "failed opening cache folder cache_does_not_exist: stat cache_does_not_exist: no such file or directory" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "HTTP references should be cached" {
|
||||||
|
resetCacheFolder
|
||||||
|
run bin/kubeconform -cache cache -summary -schema-location 'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/{{ .NormalizedKubernetesVersion }}{{ .StrictSuffix }}/{{ .ResourceKind }}{{ .KindSuffix }}.json' fixtures/valid.yaml
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "`ls cache/ | wc -l`" -eq 2 ]
|
||||||
|
}
|
||||||
|
|
||||||
@test "Produces correct TAP output" {
|
@test "Produces correct TAP output" {
|
||||||
run bin/kubeconform -output tap fixtures/valid.yaml
|
run bin/kubeconform -output tap fixtures/valid.yaml
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
|
|
|
||||||
46
fixtures/cache/603105c17f981119fec20ae25cfb97ff6dd99114a875ae841ef965d9345667e3
vendored
Normal file
46
fixtures/cache/603105c17f981119fec20ae25cfb97ff6dd99114a875ae841ef965d9345667e3
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
"description": "ReplicationController represents the configuration of a replication controller.",
|
||||||
|
"properties": {
|
||||||
|
"apiVersion": {
|
||||||
|
"description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
],
|
||||||
|
"enum": [
|
||||||
|
"v1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"kind": {
|
||||||
|
"description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
],
|
||||||
|
"enum": [
|
||||||
|
"ReplicationController"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"metadata": {
|
||||||
|
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master/_definitions.json#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta",
|
||||||
|
"description": "If the Labels of a ReplicationController are empty, they are defaulted to be the same as the Pod(s) that the replication controller manages. Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata"
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master/_definitions.json#/definitions/io.k8s.api.core.v1.ReplicationControllerSpec",
|
||||||
|
"description": "Spec defines the specification of the desired behavior of the replication controller. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master/_definitions.json#/definitions/io.k8s.api.core.v1.ReplicationControllerStatus",
|
||||||
|
"description": "Status is the most recently observed status of the replication controller. This data may be out of date by some window of time. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": "object",
|
||||||
|
"x-kubernetes-group-version-kind": [
|
||||||
|
{
|
||||||
|
"group": "",
|
||||||
|
"kind": "ReplicationController",
|
||||||
|
"version": "v1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"$schema": "http://json-schema.org/schema#"
|
||||||
|
}
|
||||||
22067
fixtures/cache/6dc6142c64b944d783a3e783526114da8e747a14a11d8b32dd1f12e2d89a8330
vendored
Normal file
22067
fixtures/cache/6dc6142c64b944d783a3e783526114da8e747a14a11d8b32dd1f12e2d89a8330
vendored
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -56,7 +56,7 @@ func (l *HTTPURLLoader) Load(url string) (any, error) {
|
||||||
|
|
||||||
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(body))
|
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, NewNonJSONResponseError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
|
|
|
||||||
|
|
@ -10,3 +10,13 @@ func NewNotFoundError(err error) *NotFoundError {
|
||||||
}
|
}
|
||||||
func (e *NotFoundError) Error() string { return e.err.Error() }
|
func (e *NotFoundError) Error() string { return e.err.Error() }
|
||||||
func (e *NotFoundError) Retryable() bool { return false }
|
func (e *NotFoundError) Retryable() bool { return false }
|
||||||
|
|
||||||
|
type NonJSONResponseError struct {
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNonJSONResponseError(err error) *NotFoundError {
|
||||||
|
return &NotFoundError{err}
|
||||||
|
}
|
||||||
|
func (e *NonJSONResponseError) Error() string { return e.err.Error() }
|
||||||
|
func (e *NonJSONResponseError) Retryable() bool { return false }
|
||||||
|
|
|
||||||
|
|
@ -390,6 +390,10 @@ func downloadSchema(registries []registry.Registry, l jsonschema.SchemeURLLoader
|
||||||
if _, notfound := err.(*loader.NotFoundError); notfound {
|
if _, notfound := err.(*loader.NotFoundError); notfound {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if _, nonJSONError := err.(*loader.NonJSONResponseError); nonJSONError {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,7 @@ lastName: bar
|
||||||
}`),
|
}`),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
Error,
|
Valid,
|
||||||
[]ValidationError{},
|
[]ValidationError{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -361,7 +361,7 @@ lastName: bar
|
||||||
[]byte(`<html>error page</html>`),
|
[]byte(`<html>error page</html>`),
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
Error,
|
Skipped,
|
||||||
[]ValidationError{},
|
[]ValidationError{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -475,6 +475,9 @@ interval: test
|
||||||
return "", nil, loader.NewNotFoundError(nil)
|
return "", nil, loader.NewNotFoundError(nil)
|
||||||
}
|
}
|
||||||
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(testCase.schemaRegistry1))
|
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(testCase.schemaRegistry1))
|
||||||
|
if err != nil {
|
||||||
|
return "", s, loader.NewNonJSONResponseError(err)
|
||||||
|
}
|
||||||
return "", s, err
|
return "", s, err
|
||||||
}),
|
}),
|
||||||
newMockRegistry(func() (string, any, error) {
|
newMockRegistry(func() (string, any, error) {
|
||||||
|
|
@ -482,6 +485,9 @@ interval: test
|
||||||
return "", nil, loader.NewNotFoundError(nil)
|
return "", nil, loader.NewNotFoundError(nil)
|
||||||
}
|
}
|
||||||
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(testCase.schemaRegistry2))
|
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(testCase.schemaRegistry2))
|
||||||
|
if err != nil {
|
||||||
|
return "", s, loader.NewNonJSONResponseError(err)
|
||||||
|
}
|
||||||
return "", s, err
|
return "", s, err
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
@ -550,6 +556,9 @@ age: not a number
|
||||||
regs: []registry.Registry{
|
regs: []registry.Registry{
|
||||||
newMockRegistry(func() (string, any, error) {
|
newMockRegistry(func() (string, any, error) {
|
||||||
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(schema))
|
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(schema))
|
||||||
|
if err != nil {
|
||||||
|
return "", s, loader.NewNonJSONResponseError(err)
|
||||||
|
}
|
||||||
return "", s, err
|
return "", s, err
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue