kr8s-org / kr8s

A batteries-included Python client library for Kubernetes that feels familiar for folks who already know how to use kubectl
https://kr8s.org
BSD 3-Clause "New" or "Revised" License
839 stars 45 forks source link

When delete() is called on object its fields are reset #470

Closed jumpojoy closed 2 months ago

jumpojoy commented 3 months ago

Which project are you reporting a bug for?

kr8s

What happened?

The object is completely rest after we call delete() method on it, and we can't use it later.

Example of the code:

from kr8s.objects import Secret

secret = Secret({
        "apiVersion": "v1",
        "kind": "Secret",
        "metadata": {
            "name": "mysecret",
        },
        "type": "Opaque",
        "data": {
            "password": b64encode("s33msi4".encode()).decode(),
            "username": b64encode("jane".encode()).decode(),
        },
    })

secret.create()
secret.name
secret.delete()
secret.name

Produce the following exception:

Traceback (most recent call last):
  File "/root/kr8s/../diff-exporter/1.py", line 20, in <module>
    secret.name
  File "/root/kr8s/kr8s/_objects.py", line 142, in name
    raise ValueError("Resource does not have a name")
ValueError: Resource does not have a name

Anything else?

No response