Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The ignore_fields argument behaves differently from what you'd expect after reading the docs #83

Closed
zenekron opened this issue Mar 13, 2021 · 4 comments

Comments

@zenekron
Copy link

The documentation page currently gives a pretty general description of the ignore_fields argument and then provides an example that suggests that setting ignore_fields = ["caBundle"] is enough for the provider to ignore any caBundle fields in the manifest, however deep they are.

This doesn't seem to be the case: from observation and then looking at the getLiveManifestFilteredForUserProvidedOnlyWithIgnoredFields function, it looks like fields are ignored by full path and prefix rather than name, meaning that given the documentation's example manifest:

apiVersion: admissionregistration.k8s.io/v1beta1
kind: MutatingWebhookConfiguration
metadata:
  name: istio-sidecar-injector
webhooks:
  - clientConfig:
      caBundle: ""

the correct value for the ignore_fields argument is ["webhooks.0.clientConfig.caBundle"] and not ["caBundle"].

Side notes

While updating the documentation to reflect the actual behaviour of ignore_fields would probably be enough, that would leave a lot to be desired in terms of functionality and ergonomics (imagine wanting to ignore a field that's 3 arrays deep).

Some other thoughs:

  • ignoring by name (disregarding the path) seems really dangerous as it could lead users into inadvertently ignoring fields they actually care about;
  • a jq-like syntax would offer the greatest flexibility (all array elements with webhooks[].clientConfig.caBundle or a specific one webhooks[13].clientConfig.caBundle) but sounds unnecessary and a pain to implement;
  • having the user provide regex patterns seems more likely than [2] but increases user fatigue and is arguably more dangerous than [1];
  • implicitly skipping array indices (webhooks.clientConfig.caBundle) or having a placeholder character (webhooks.*.clientConfig.caBundle) looks like the cleanest solution to me.
@whiskeysierra
Copy link

Instead of inventing a new language, maybe using JsonPath would be an option? E.g. https://github.com/yalp/jsonpath

@tehlers320
Copy link

Or a regex, also why cant i just ignore "spec" ? i know some thing are immutable, but i dont care. Let me fail.

@iAlexBLR
Copy link

Any progress on this? I'm also unable to ignore annotations using both annotation names or the pull path to it in the YAML object.

@gavinbunney
Copy link
Owner

Updated the docs to make it clearer. There are also some more tests in the provider which should help with different syntax styles. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants