-
-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add conditions::is_accepted for crds - closes #655
Signed-off-by: clux <sszynrae@gmail.com>
- Loading branch information
Showing
3 changed files
with
31 additions
and
56 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 |
---|---|---|
|
@@ -51,6 +51,7 @@ where | |
/// Common conditions to wait for | ||
pub mod conditions { | ||
use kube_client::Resource; | ||
use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinition; | ||
|
||
/// An await condition that returns `true` once the object has been deleted. | ||
/// | ||
|
@@ -67,6 +68,28 @@ pub mod conditions { | |
) | ||
} | ||
} | ||
|
||
/// An await condition for `CustomResourceDefinition` that returns `true` once it has been accepted | ||
pub fn is_accepted() -> impl Fn(Option<&CustomResourceDefinition>) -> bool { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
move |obj: Option<&CustomResourceDefinition>| { | ||
obj.map_or( | ||
// Object missing, failure! | ||
false, | ||
|o| { | ||
if let Some(s) = &o.status { | ||
if let Some(conds) = &s.conditions { | ||
if let Some(pcond) = conds.iter().find(|c| c.type_ == "NamesAccepted") { | ||
This comment has been minimized.
Sorry, something went wrong.
nightkr
Member
|
||
if pcond.status == "True" { | ||
return true | ||
} | ||
} | ||
} | ||
} | ||
false | ||
}, | ||
) | ||
} | ||
} | ||
} | ||
|
||
/// Utilities for deleting objects | ||
|
Perhaps we should rename this to
crd_is_accepted
or similar?