kopf icon indicating copy to clipboard operation
kopf copied to clipboard

Implicitly map kinds<=>plurals<=>singulars

Open nolar opened this issue 5 years ago • 0 comments

Currently, the resources' plural names must be used as the only acceptable reference to the resources in the handlers:

@kopf.on.create('zalando.org', 'v1', 'kopfexamples')
def create_fn(**_):
    pass

It would be more convenient to refer to the resource the same way as the YAML files do: by their "kind":

@kopf.on.create('zalando.org', 'v1', 'KopfExample')
def create_fn(**_):
    pass

Or, as even more convenient way, as in kubectl — by any of their names without group/version references:

@kopf.on.create('KopfExample')  # kind
def create_fn(**_):
    pass

@kopf.on.create('kopfexample')  # singular
def create_fn(**_):
    pass

@kopf.on.create('kopfexamples')  # plural
def create_fn(**_):
    pass

Short-names can also be supported. Though it is questionable if they should be on the CRD reference in the operator.

nolar avatar May 10 '19 12:05 nolar