kapicorp / kapitan

Generic templated configuration management for Kubernetes, Terraform and other things
https://kapitan.dev
Apache License 2.0
1.83k stars 199 forks source link

Update inventory validation schema to incorporate constraints on output_type #272

Closed pranavgupta1234 closed 5 years ago

pranavgupta1234 commented 5 years ago

Currently the schema for validation of inventory structure does not incorporate constraint on output_type, instead they are handled at compilation phase. I think if we incorporate this at schema level then the error can be shown much before and this can make Kapitan more responsive and fast.

I have the modified schema ready for this which will put constraint on output_type to be only yaml or json(in case input_type is jsonnet or kadet) and allow all output_type for jinja2(it doesn't matter if one specifies it in current implemetation as well).

By looking, it seems like current schema is defined on abstraction for validation of basic structure only and not for any specific type of key that's why I am not sure about making this change or not.

pranavgupta1234 commented 5 years ago

After giving a bit more thought about this issue I think just before invoking worker threads for doing compilation, inside load_target_inventory(...) where we are currently doing two step validation :

Now we can add one more step which includes validation of our currently supported types or just modify the schema of inside valid_target_obj to put the necessary constraint. Just a sample draft for above change https://github.com/deepmind/kapitan/pull/285