gardener / diki

Apache License 2.0
7 stars 8 forks source link

Revise the `Validation()` method of the `Option` interface #322

Open AleksandarSavchev opened 5 days ago

AleksandarSavchev commented 5 days ago

What would you like to be added: Currently there are places for improving the Validation() method of the Option interface in the pkg/shared/ruleset/disak8sstig/option package https://github.com/gardener/diki/blob/db51f2847096aa32a15dfcdbbf4b75641636ea99/pkg/shared/ruleset/disak8sstig/option/options.go#L15-L19

  1. Most implementations of Option add field.Path to the errors returned from Validate(). ex: https://github.com/gardener/diki/blob/db51f2847096aa32a15dfcdbbf4b75641636ea99/pkg/shared/ruleset/disak8sstig/option/options.go#L116-L120 We should allow field.Path to be passed to the Validate() method to have a better description of which options are not valid.

  2. Currently Validate() returns field.ErrorList. We should look into weather it is better to return an error which contains all other errors merged with errors.Join()

Why is this needed: Enhance user options validation experience.