Files
orchard/internal/tests/wait/wait.go
T
Nikolay Edigaryev d59bc7f8a7 Orchard Controller: implement an SSH server that acts as a jump host (#179)
* proxy.Connections(): require io.ReadWriteCloser instead of net.Conn

* Orchard Controller: implement an SSH server that acts as a jump host

* Issue a warning if the name used will be invalid in the future

* Further restrict uppercase characters in names in the future

The rationale is similar to https://github.com/kubernetes/kubernetes/issues/71140.

We won't want to munge the user's input and introduce subtle bugs doing
lowercase comparisons.
2024-06-11 19:32:45 +04:00

25 lines
347 B
Go

package wait
import (
"context"
"time"
)
func Wait(duration time.Duration, predicate func() bool) bool {
ctx, cancel := context.WithTimeout(context.Background(), duration)
defer cancel()
for {
if predicate() {
return true
}
select {
case <-ctx.Done():
return false
case <-time.After(1 * time.Second):
continue
}
}
}