Skip to content

Commit

Permalink
Try casting resource to dict (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtomlinson authored Jul 13, 2023
1 parent 226049c commit 47eeb24
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kr8s/_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import asyncio
import contextlib
import json
import pathlib
import re
Expand Down Expand Up @@ -36,7 +37,8 @@ class APIObject:

def __init__(self, resource: dict, namespace: str = None, api: Api = None) -> None:
"""Initialize an APIObject."""
# TODO support passing pykube or kubernetes objects in addition to dicts
with contextlib.suppress(TypeError, ValueError):
resource = dict(resource)
if isinstance(resource, str):
self._raw = {"metadata": {"name": resource}}
elif isinstance(resource, dict):
Expand Down

0 comments on commit 47eeb24

Please sign in to comment.