Skip to content

Commit

Permalink
DoUntilTrue condition function
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Jellick authored and ibuildthecloud committed Jan 8, 2018
1 parent 82272b3 commit 399b7d3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions condition/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,19 @@ func (c Cond) Once(obj runtime.Object, f func() (runtime.Object, error)) (runtim
return obj, nil
}

func (c Cond) DoUntilTrue(obj runtime.Object, f func() (runtime.Object, error)) (runtime.Object, error) {
if c.IsTrue(obj) {
return obj, nil
}

return c.do(obj, f)
}

func (c Cond) Do(obj runtime.Object, f func() (runtime.Object, error)) (runtime.Object, error) {
return c.do(obj, f)
}

func (c Cond) do(obj runtime.Object, f func() (runtime.Object, error)) (runtime.Object, error) {
c.Unknown(obj)
newObj, err := f()
if newObj != nil {
Expand Down

0 comments on commit 399b7d3

Please sign in to comment.