cyrgim
cda284dac5
Fix schema matching for custom schema files without kind constraints
...
When using multiple custom schema locations with direct JSON files,
kubeconform incorrectly applied the first schema to all resources.
This occurred because schemas without explicit kind constraints
(enum/const values) would match any resource type.
Added intelligent path-based matching for schemas without kind
constraints, allowing proper validation of resources like SecretStore
against their intended schemas rather than defaulting to the first
available schema.
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-18 09:44:05 +02:00
Emil Thorenfeldt
5582d069a8
Fix schema matching when using multiple schema locations
...
When multiple schema locations are provided, ensure each resource
is validated against the correct schema by checking if the schema's
kind constraints match the expected resource type.
Fixes #299
🤖 Generated with [Claude Code](https://claude.ai/code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-12 14:13:15 +02:00
Yann Hamon
e65429b1e5
Add support for duration ( #328 )
...
* Add custom validation logic for durations
2025-05-12 11:15:53 +02:00
Yann Hamon
a23275d5ca
Invalid JSON should not be considered an error - see https://github.com/yannh/kubeconform/issues/67 ( #327 )
2025-05-12 10:21:02 +02:00
Yann Hamon
31e9679c96
Update jsonschema library to v6 ( #324 )
2025-05-11 02:05:01 +02:00
Yann Hamon
7062384492
Slightly improve the coverage of the validator test ( #271 )
2024-05-09 16:37:20 +02:00
Michael Lee
20805f652c
Stop validating output of closed channel in Validate ( #265 )
...
Currently, Validate and ValidateWithContext always returns a
result with status `Empty` and a `missing 'kind' key` error as
the final item in the returned slice.
This is because ValidateWithContext currently will parse the output of
`resourcesChan`, even when the context is finished and we get back
a default `Resource` struct.
This PR modifies the code to skip validating this case.
2024-05-09 16:27:59 +02:00
Yann Hamon
13a78ebad8
Avoid unnecessary type conversions ( #222 )
2023-07-16 10:27:26 +02:00
Yann Hamon
ae67bb4709
Force Draft version of JsonSchema ( #221 )
...
* Force Draft version of JsonSchema
* Add test validating using CRD that misses explicit draft version
2023-07-16 09:42:11 +02:00
Aleksey Levenstein
e3bb34851d
fix: expose error instance path instead of schema path ( #177 )
2023-02-27 16:16:00 +01:00
Yann Hamon
563e1db94c
Try to expose JSON paths ( #173 )
...
* Try to expose JSON paths
* update validationErrors format in json output
* Add test to JSON output with validationError
2023-02-26 12:32:51 +01:00
Yann Hamon
ee7c498580
Migrate to santhosh-tekuri/jsonschema ( #168 )
...
* Migrate to santhosh-tekuri/jsonschema
2023-01-23 19:22:20 +01:00
Andrea Tosatto
d8e348a597
Allow to skip resources using the GVK notation ( #92 )
...
* Allow to skip resources using the GVK notation
* Update flags description, add integration tests and update readme
Co-authored-by: Yann Hamon <yann@mandragor.org>
2022-10-16 14:59:48 +02:00
Yann Hamon
f68d6ec6ea
Add debug information to help understand failures finding schemas ( #133 )
...
* Add debug information to help understand failures finding schemas
* Add debug information to help understand failures finding schemas
2022-10-16 12:28:11 +02:00
Bill Franklin
9a6fff13cb
Forbid duplicate keys in strict mode ( #121 )
...
* Forbid duplicate keys in strict mode
Prevents specifying duplicate keys using
UnmarshallStrict: https://pkg.go.dev/gopkg.in/yaml.v2#UnmarshalStrict
* Add acceptance tests for duplicated properties
2022-07-15 14:23:10 +02:00
Yann Hamon
2eefa7fc22
Update Junit tests, fix #45
2021-08-29 12:57:25 +02:00
Victor Cardenas
44b7ba9aef
Properly handle successful http requests to registries sending invalid schema responses
2021-08-03 19:46:18 -04:00
Yann Hamon
3a697f3ce2
validate against master by default, not 1.18.0
2021-07-11 22:53:23 +02:00
Christoph Mertz
65968cf540
remove gosimple offences
2021-02-19 17:01:54 +01:00
Yann Hamon
61e708277d
Use a custom, more up-to-date fork of kubernetes-json-schema by default
2021-01-24 01:17:35 +01:00
Yann Hamon
18927ddf75
cache schemas downloaded over HTTP
2021-01-01 15:49:18 +01:00
Yann Hamon
9a56fc4176
Indicate field on validation error
2020-12-28 13:03:36 +01:00
Yann Hamon
509ad8e997
add test for missing apiVersion - better error message
2020-12-23 18:25:46 +01:00
Yann Hamon
031f83cbde
linting
2020-12-15 22:20:02 +01:00
Yann Hamon
07dec90112
tap plan can be at the end, that way we can stream the output and not buffer
2020-12-15 21:54:44 +01:00
Yann Hamon
29a8f4c09e
avoid double unmarshalling
2020-12-15 18:35:33 +01:00
Yann Hamon
f63d329742
throw error when file with key/values is missing a Kind, add acc test
2020-11-15 23:44:15 +01:00
Yann Hamon
651d3b2c50
fail early when a broken -schema-location template is given
2020-11-15 20:23:37 +01:00
Yann Hamon
300b571c33
linting / refactor
2020-11-15 12:12:37 +01:00
Yann Hamon
22e82c4922
Properly close streams after processing them
2020-11-15 10:19:09 +01:00
Yann Hamon
4e96b44a8b
Add example how to use kubeconform as a library
2020-11-15 10:01:36 +01:00
Yann Hamon
4672ded043
only expose interfac
2020-11-14 16:23:33 +01:00
Yann Hamon
9936e43d47
opts should not be a pointer
2020-11-14 15:57:39 +01:00
Yann Hamon
649c2ca4d6
refactor validator pkg so it can be usable in a third party app
2020-11-14 15:54:45 +01:00
Yann Hamon
4b16128b75
Add comments to most exported functions/types
2020-11-08 22:35:17 +01:00
Yann Hamon
0c22457919
refactor
2020-11-01 16:35:38 +01:00
Yann Hamon
1bc9283240
refactor
2020-11-01 16:28:32 +01:00
Christoph Mertz
0cffc7994d
reorder imports
...
Reorder imports with `goimports`.
2020-10-18 11:30:20 +02:00
Yann Hamon
b4995aa02c
Support for CRDs
2020-10-17 15:35:41 +02:00
Yann Hamon
d9a6468d09
add a few comments on exported vars
2020-06-06 18:42:44 +02:00
Yann Hamon
cdcacb080d
more unit tests
2020-06-06 16:32:27 +02:00
Yann Hamon
f64ecad867
Add comments on some exported resources
2020-06-04 00:51:36 +02:00
Yann Hamon
90e53c74d0
rename package files
2020-06-01 23:32:20 +02:00
Yann Hamon
8fc1df8d8b
minor nits
2020-06-01 12:20:15 +02:00
Yann Hamon
c6526d7278
Default to non-strict
2020-05-31 04:36:29 +02:00
Yann Hamon
11cfca1498
Better logging messages
2020-05-31 04:27:18 +02:00
Yann Hamon
8eb297d4c4
better logic mgmt in output plugins, go fmt
2020-05-31 02:10:19 +02:00
Yann Hamon
30a6fe69b1
cache Schema unmarshalling, cache schema download failures (WIP)
2020-05-30 21:40:54 +02:00
Yann Hamon
2786a84a4c
add -dir parameter
2020-05-30 15:49:02 +02:00
Yann Hamon
79c9197f38
better errors
2020-05-30 05:34:21 +02:00