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

Add rollout undo feature support #83

Merged
merged 1 commit into from
Mar 6, 2017
Merged
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
27 changes: 27 additions & 0 deletions pykube/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,33 @@ def ready(self):
self.obj["status"]["updatedReplicas"] == self.replicas
)

def rollout_undo(self, target_revision=None):
"""Produces same action as kubectl rollout undo deployment command.
Input variable is revision to rollback to (in kubectl, --to-revision)
"""
if target_revision is None:
revision = {}
else:
revision = {
"revision": target_revision
}

params = {
"kind": "DeploymentRollback",
"apiVersion": self.version,
"name": self.name,
"rollbackTo": revision
}

kwargs = {
"version": self.version,
"namespace": self.namespace,
"operation": "rollback",
}
r = self.api.post(**self.api_kwargs(data=json.dumps(params), **kwargs))
r.raise_for_status()
return r.text


class Endpoint(NamespacedAPIObject):

Expand Down