carvel-dev / kapp

kapp is a simple deployment tool focused on the concept of "Kubernetes application" — a set of resources with the same label
https://carvel.dev/kapp
Apache License 2.0
899 stars 108 forks source link

Error out when configuration key is unknown #196

Open joaopapereira opened 3 years ago

joaopapereira commented 3 years ago

Describe the problem/challenge you have When a user provides configuration to kapp but that configuration contains a typo or a key that should not be part of the configuration, kapp does not error out or tell the user that the configuration has keys that kapp does not know off.

One example would be

apiVersion: kapp.k14s.io/v1alpha1
kind: Config

minimumRequiredVersion: 0.23.0
rebaseRules:
- paths:
  - [spec, replicas]
  type: copy
  sources: [existing]
  resourcesMatchers:
  - hasAnnotationMatcher:
      keys:
      - cluster.k8s.io/cluster-api-autoscaler-node-group-min-size
unknownKey: 1

the key resourcesMatchers does not exist

Describe the solution you'd like kapp should return an error saying something like

Error: Configuration have the following unknown fields:
  rebaseRules[0].resourcesMatchers
  unknownKey

Anything else you would like to add: For a better UX maybe if it would be easy we should provide the line of the file where this error occurs. We should be mindful that maybe the configuration can be piped into kapp so there will be no filename.

renuy commented 3 years ago

upgradability issue: If keys are introduced in newer version, validation will fail older versions. (using new config with old kapp). Needs to be also seen how it will work with kapp-controller.