cisco-open / k8s-objectmatcher

A Kubernetes object matcher library to avoid unnecessary K8s object updates
Apache License 2.0
157 stars 29 forks source link

patch.IgnoreField() should take the path to the entity to be ignored #55

Closed jchenz closed 2 years ago

jchenz commented 2 years ago

Is your feature request related to a problem? Please describe.

I have this env in deployment spec

spec: replicas: 3 selector: matchLabels: app: gcs mciroservice: athena realm: production template: metadata: annotations: vaultproject.io/policies: default, mongodb-athena vaultproject.io/ttl: 72h labels: app: gcs mciroservice: athena realm: production spec: containers:

when it is deployed, this env is expanded to:

"env":[{"name":"KUBE_POD_NAME","valueFrom":{"fieldRef":{"apiVersion":"v1","fieldPath":"metadata.name"}}}

which is always different from the spec.

Describe the solution you'd like to see ignore field should use the path, such as the following: spec.template.spec.env.name:KUBE_POD_NAME

Since the kubernetes resource is changed to map[string]interface{}, it can find the key/value by using the path and remove the item in this example