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

[PR] Detect per-field diffs inside of the changed containers #191

Closed
2 tasks
kopf-archiver bot opened this issue Aug 18, 2020 · 0 comments
Closed
2 tasks

[PR] Detect per-field diffs inside of the changed containers #191

kopf-archiver bot opened this issue Aug 18, 2020 · 0 comments
Labels
archive bug Something isn't working

Comments

@kopf-archiver
Copy link

kopf-archiver bot commented Aug 18, 2020

A pull request by nolar at 2019-09-25 20:51:24+00:00
Original URL: zalando-incubator/kopf#191
Merged by nolar at 2019-09-26 10:34:42+00:00

Fix the issue with no calling the field-handlers if the change is too big/generic.

Issue : fixes #190

Description

import kopf

@kopf.on.field('zalando.org', 'v1', 'kopfexamples', field='spec.field')
def fn(**kwargs):
    pass

Example original object (note the absence of spec!):

apiVersion: zalando.org/v1
kind: KopfExample
metadata:
  name: kopf-example-1

Changed object:

apiVersion: zalando.org/v1
kind: KopfExample
metadata:
  name: kopf-example-1
spec:
  field: value

Caused by the diff detection and reduction algorithms:

  • The addition of the whole spec field is detected, so that the diff equals to [('add', ('spec',), None, {'field': 'value'})].
  • The reduction algorithm for spec.field scans the whole diff for all records starting with field-prefix ('spec', 'field'), and finds nothing — ('spec',) does not start with ('spec', 'field').
  • The handler is not selected for execution.

In addition to the fix, the types of diff structures were clarified and restricted, so that later the diffs can be extended with diff-specific DSL (e.g. diff-slicing, etc).

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactoring (types).

Review

List of tasks the reviewer must do to review the PR

  • Tests
  • Documentation
@kopf-archiver kopf-archiver bot closed this as completed Aug 18, 2020
@kopf-archiver kopf-archiver bot changed the title [archival placeholder] [PR] Detect per-field diffs inside of the changed containers Aug 19, 2020
@kopf-archiver kopf-archiver bot added the bug Something isn't working label Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
archive bug Something isn't working
Projects
None yet
Development

No branches or pull requests

0 participants