mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-02 04:51:25 +02:00
* 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.
25 lines
347 B
Go
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
|
|
}
|
|
}
|
|
}
|