-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from Josh-Diamond/jkeslar/qatask-1039-v29
adds support for deleting init node
- Loading branch information
Showing
3 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package steve | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
"time" | ||
|
||
"github.com/rancher/shepherd/clients/rancher" | ||
"github.com/sirupsen/logrus" | ||
kwait "k8s.io/apimachinery/pkg/util/wait" | ||
) | ||
|
||
const ( | ||
notFound = "not found" | ||
) | ||
|
||
// WaitForSteveResourceDeletion accepts a client, steve resource type, and resource ID, then waits for a steve resource to be deleted | ||
func WaitForSteveResourceDeletion(client *rancher.Client, interval, timeout time.Duration, steveResourceType, steveID string) error { | ||
err := kwait.PollUntilContextTimeout(context.TODO(), interval, timeout, true, func(ctx context.Context) (done bool, err error) { | ||
_, err = client.Steve.SteveType(steveResourceType).ByID(steveID) | ||
if err != nil { | ||
if strings.Contains(err.Error(), notFound) { | ||
logrus.Info("Resource was successfully removed!") | ||
return true, nil | ||
} else { | ||
return false, err | ||
} | ||
} | ||
|
||
return false, nil | ||
}) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |