Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
Merge branch 'gree-gorey-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
hjacobs committed Apr 14, 2019
2 parents 92797d6 + 7ec5fa1 commit 8b745ef
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pykube/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,18 @@ def update(self):
self.api.raise_for_status(r)
self.set_obj(r.json())

def delete(self):
r = self.api.delete(**self.api_kwargs())
def delete(self, propagation_policy: str = None):
'''
Delete the Kubernetes resource by calling the API.
The parameter propagation_policy defines whether to cascade the delete. It can be "Foreground", "Background" or "Orphan".
See https://kubernetes.io/docs/concepts/workloads/controllers/garbage-collection/#setting-the-cascading-deletion-policy
'''
if propagation_policy:
options = {"propagationPolicy": propagation_policy}
else:
options = {}
r = self.api.delete(**self.api_kwargs(data=json.dumps(options)))
if r.status_code != 404:
self.api.raise_for_status(r)

Expand Down

0 comments on commit 8b745ef

Please sign in to comment.