Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

make ready generic #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* `HorizontalPodAutoscaler`
* `KubeConfig` learned to handle empty or missing user configuration
* `HTTPClient` learned to create an HTTP session with no authentication
* ready supported on all objects if exposed by the kubernetes api

### Bug fixes

Expand Down
16 changes: 9 additions & 7 deletions pykube/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ def delete(self):
if r.status_code != 404:
self.api.raise_for_status(r)

@property
def ready(self):
try:
return (
self.obj["status"]["observedGeneration"] >= self.obj["metadata"]["generation"]
)
except KeyError as e:
raise NotImplementedError(e)


class NamespacedAPIObject(APIObject):

Expand Down Expand Up @@ -128,13 +137,6 @@ class Deployment(NamespacedAPIObject, ReplicatedMixin, ScalableMixin):
endpoint = "deployments"
kind = "Deployment"

@property
def ready(self):
return (
self.obj["status"]["observedGeneration"] >= self.obj["metadata"]["generation"] and
self.obj["status"]["updatedReplicas"] == self.replicas
)


class Endpoint(NamespacedAPIObject):

Expand Down