basic design up and balling

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
pull/30616/head
Austin Abro 2 years ago committed by Andrea Tartaglia
parent ef0c6c3841
commit fb8c977b4e
No known key found for this signature in database

@ -168,9 +168,19 @@ func (c *Client) SetWaiter(ws WaitStrategy) error {
}
// New creates a new Client.
func New(getter genericclioptions.RESTClientGetter) *Client {
func New(getter genericclioptions.RESTClientGetter, waiter Waiter) *Client {
if getter == nil {
getter = genericclioptions.NewConfigFlags(true)
}
factory := cmdutil.NewFactory(getter)
if waiter == nil {
sw, err := getStatusWatcher(factory)
if err != nil {
// TODO, likely will move how the stats watcher is created so it doesn't need to be created
// unless it's going to be used
panic(err)
}
waiter = &kstatusWaiter{sw, nopLogger}
}
factory := cmdutil.NewFactory(getter)
c := &Client{

@ -616,10 +616,10 @@ func TestPerform(t *testing.T) {
}
}
// Likely it is not possible to get this test to work with kstatus given that it seems
// Likely it is not possible to get this test to work with kstatus given that it seems
// kstatus is not making constant get checks on the resources and is instead waiting for events
// Potentially the test could be reworked to make the pods after five seconds
// would need this ->
// would need this ->
func TestWait(t *testing.T) {
podList := newPodList("starfish", "otter", "squid")
@ -836,7 +836,7 @@ func TestWaitDelete(t *testing.T) {
func TestReal(t *testing.T) {
t.Skip("This is a live test, comment this line to run")
c := New(nil)
c := New(nil, nil)
resources, err := c.Build(strings.NewReader(guestbookManifest), false)
if err != nil {
t.Fatal(err)
@ -846,7 +846,7 @@ func TestReal(t *testing.T) {
}
testSvcEndpointManifest := testServiceManifest + "\n---\n" + testEndpointManifest
c = New(nil)
c = New(nil, nil)
resources, err = c.Build(strings.NewReader(testSvcEndpointManifest), false)
if err != nil {
t.Fatal(err)

@ -64,6 +64,10 @@ type Waiter interface {
// WaitForDelete wait up to the given timeout for the specified resources to be deleted.
WaitForDelete(resources ResourceList, timeout time.Duration) error
// Update updates one or more resources or creates the resource
// if it doesn't exist.
Update(original, target ResourceList, force bool) (*Result, error)
// WatchUntilReady watches the resources given and waits until it is ready.
//
// This method is mainly for hook implementations. It watches for a resource to
@ -73,6 +77,7 @@ type Waiter interface {
// For Pods, "ready" means the Pod phase is marked "succeeded".
// For all other kinds, it means the kind was created or modified without
// error.
// TODO: Is watch until ready really behavior we want over the resources actually being ready?
WatchUntilReady(resources ResourceList, timeout time.Duration) error
}

@ -61,6 +61,19 @@ func (hw *legacyWaiter) WaitWithJobs(resources ResourceList, timeout time.Durati
return hw.waitForResources(resources, timeout)
}
func (w *waiter) Wait(resources ResourceList, timeout time.Duration) error {
w.timeout = timeout
return w.waitForResources(resources)
}
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 pass context instead
w.timeout = timeout
return w.waitForResources(resources)
}
// waitForResources polls to get the current status of all pods, PVCs, Services and
// Jobs(optional) until all are ready or a timeout is reached
func (hw *legacyWaiter) waitForResources(created ResourceList, timeout time.Duration) error {

Loading…
Cancel
Save