mirror of https://github.com/helm/helm.git
context
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
This commit is contained in:
parent
b337790c10
commit
28a9183ee3
|
|
@ -40,16 +40,18 @@ type kstatusWaiter struct {
|
|||
}
|
||||
|
||||
func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error {
|
||||
return w.wait(resourceList, timeout, false)
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
return w.wait(ctx, resourceList, false)
|
||||
}
|
||||
|
||||
func (w *kstatusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error {
|
||||
return w.wait(resourceList, timeout, true)
|
||||
}
|
||||
|
||||
func (w *kstatusWaiter) wait(resourceList ResourceList, timeout time.Duration, waitForJobs bool) error {
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
return w.wait(ctx, resourceList, true)
|
||||
}
|
||||
|
||||
func (w *kstatusWaiter) wait(ctx context.Context, resourceList ResourceList, waitForJobs bool) error {
|
||||
cancelCtx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
runtimeObjs := []runtime.Object{}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package kube // import "helm.sh/helm/v3/pkg/kube"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"testing"
|
||||
|
|
@ -194,7 +195,10 @@ func TestKWaitJob(t *testing.T) {
|
|||
resourceList = append(resourceList, list...)
|
||||
}
|
||||
|
||||
err := kwaiter.wait(resourceList, time.Second*3, tt.waitForJobs)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
|
||||
defer cancel()
|
||||
|
||||
err := kwaiter.wait(ctx, resourceList, tt.waitForJobs)
|
||||
if tt.expectErrs != nil {
|
||||
assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error())
|
||||
return
|
||||
|
|
|
|||
|
|
@ -51,8 +51,9 @@ func (w *waiter) Wait(resources ResourceList, timeout time.Duration) error {
|
|||
|
||||
func (w *waiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error {
|
||||
// Implementation
|
||||
// TODO this function doesn't make sense unless you pass a readyChecker to it
|
||||
// TODO this function doesn't make sense unless you pass a readyChecker to it
|
||||
// TODO pass context instead
|
||||
// checker := NewReadyChecker(cs, w.c.Log, PausedAsReady(true), CheckJobs(true))
|
||||
w.timeout = timeout
|
||||
return w.waitForResources(resources)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue