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] Filter labels/annotations by callbacks with arbitrary logic #328

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

[PR] Filter labels/annotations by callbacks with arbitrary logic #328

kopf-archiver bot opened this issue Aug 18, 2020 · 0 comments
Labels
archive enhancement New feature or request

Comments

@kopf-archiver
Copy link

kopf-archiver bot commented Aug 18, 2020

A pull request by nolar at 2020-03-12 08:46:02+00:00
Original URL: zalando-incubator/kopf#328
Merged by nolar at 2020-03-13 08:33:12+00:00

What do these changes do?

Add filtering callbacks for individual labels/annotations, similar to the whole-object when= filtering callback.

Description

This is a little separate follow-up for #327:

  • We have labels/annotations filters with values & markers for present/absent values.
  • We have callback filters with arbitrary logic for the whole objects.

Why not make callback filters with arbitrary logic for specific labels/annotations?

Just a little feature, which combines the two already existing features:

import kopf


def check_marker(value, spec, **_):
    return value is not None and value == spec.get('field')


@kopf.on.create('zalando.org', 'v1', 'kopfexamples',  
                annotations={'some-marker': check_marker})
def kex_created(**_):
    pass

The value is either a str, or None for an absent label/annotation. The callback is called always.

The kwargs are the same as for the handler or a when= callback.

Issues/PRs

Issues: #98

Related: #258

Type of changes

  • New feature (non-breaking change which adds functionality)

Checklist

  • The code addresses only the mentioned problem, and this problem only
  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
@kopf-archiver kopf-archiver bot closed this as completed Aug 18, 2020
@kopf-archiver kopf-archiver bot changed the title [archival placeholder] [PR] Filter labels/annotations by callbacks with arbitrary logic Aug 19, 2020
@kopf-archiver kopf-archiver bot added the enhancement New feature or request label Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
archive enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

0 participants