37 Star 403 Fork 75

GVPrancher/rancher

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
wait.go 891 Bytes
Copy Edit Raw Blame History
package compose
import (
"time"
"github.com/pkg/errors"
"github.com/rancher/norman/clientbase"
managementClient "github.com/rancher/types/client/management/v3"
)
var (
// WaitCondition is a set of function that can be customized to wait for a resource
WaitCondition = map[string]func(baseClient *clientbase.APIBaseClient, id, schemaType string) error{}
)
func WaitCluster(baseClient *clientbase.APIBaseClient, id, schemaType string) error {
start := time.Now()
for {
respObj := managementClient.Cluster{}
if err := baseClient.ByID(schemaType, id, &respObj); err != nil {
return err
}
for _, cond := range respObj.Conditions {
if cond.Type == "Ready" && cond.Status == "True" {
return nil
}
}
time.Sleep(time.Second * 10)
if time.Now().After(start.Add(time.Minute * 30)) {
return errors.Errorf("Timeout wait for cluster %s to be ready", id)
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.13

Search