Skip to content

Commit

Permalink
Merge pull request kelproject#83 from Chris-Dee/add_rollout_undo
Browse files Browse the repository at this point in the history
Add rollout undo feature support
brosner authored Mar 6, 2017
2 parents ba184da + 4f95343 commit 856a342
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pykube/objects.py
Original file line number Diff line number Diff line change
@@ -169,6 +169,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):

0 comments on commit 856a342

Please sign in to comment.