/
utilities.go
29 lines (25 loc) · 1.14 KB
/
utilities.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package helper
import (
"context"
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
)
// WaitTimeoutForDaemonSetInNamespace waits the given timeout duration for the specified ds.
func (h *H) WaitTimeoutForDaemonSetInNamespace(ctx context.Context, daemonSetName string, namespace string, timeout time.Duration, poll time.Duration) error {
return wait.PollUntilContextTimeout(ctx, poll, timeout, false, func(ctx context.Context) (bool, error) {
if _, err := h.Kube().AppsV1().DaemonSets(namespace).Get(ctx, daemonSetName, metav1.GetOptions{}); err != nil {
return false, err
}
return true, nil
})
}
// WaitTimeoutForServiceInNamespace waits the given timeout duration for the specified service.
func (h *H) WaitTimeoutForServiceInNamespace(ctx context.Context, serviceName string, namespace string, timeout time.Duration, poll time.Duration) error {
return wait.PollUntilContextTimeout(ctx, poll, timeout, false, func(ctx context.Context) (bool, error) {
if _, err := h.Kube().CoreV1().Services(namespace).Get(ctx, serviceName, metav1.GetOptions{}); err != nil {
return false, err
}
return true, nil
})
}