async fn resources_discoverable() -> Result<(), Box<dyn std::error::Error>> {
        use crate::{
            core::{DynamicObject, GroupVersionKind},
            discovery::{verbs, Discovery, Scope},
            runtime::wait::{await_condition, conditions},
        };

        let client = Client::try_default().await?;

        // ensure crd is installed
        let crds: Api<CustomResourceDefinition> = Api::all(client.clone());
        let ssapply = PatchParams::apply("kube").force();
        crds.patch("foos.clux.dev", &ssapply, &Patch::Apply(Foo::crd()))
            .await?;
        let establish = await_condition(crds, "foos.clux.dev", conditions::is_crd_established());
        let _ = tokio::time::timeout(std::time::Duration::from_secs(10), establish).await?;

        // run discovery
        let discovery = Discovery::new(client.clone())
            .exclude(&["rbac.authorization.k8s.io"]) // skip something
            .run()
            .await?;
        // check our custom resource first by resolving within groups
        {
            assert!(discovery.has_group("clux.dev"));
            let gvk = GroupVersionKind::gvk("clux.dev", "v1", "Foo");
            let (ar, _caps) = discovery.resolve_gvk(&gvk).unwrap();
            assert_eq!(ar.group, gvk.group);
            assert_eq!(ar.version, gvk.version);
            assert_eq!(ar.kind, gvk.kind);
        }
        // check all non-excluded groups that are iterable
        for group in discovery.groups() {
            for (ar, caps) in group.recommended_resources() {
                if !caps.supports_operation(verbs::LIST) {
                    continue;
                }
                let api: Api<DynamicObject> = if caps.scope == Scope::Namespaced {
                    Api::default_namespaced_with(client.clone(), &ar)
                } else {
                    Api::all_with(client.clone(), &ar)
                };
                api.list(&Default::default()).await?;
            }
        }
        Ok(())
    }
// needs cluster (fetches api resources, and lists all)
needs cluster (fetches api resources, and lists all)
needs cluster ( fetches api resources and lists all )
async fn resources_discoverable() -> Result<(), Box<dyn std::error::Error>> {
        use crate::{
            core::{DynamicObject, GroupVersionKind},
            discovery::{verbs, Discovery, Scope},
            runtime::wait::{await_condition, conditions},
        };
        let client = Client::try_default().await?;
        // ensure crd is installed
        let crds: Api<CustomResourceDefinition> = Api::all(client.clone());
        let ssapply = PatchParams::apply("kube").force();
        crds.patch("foos.clux.dev", &ssapply, &Patch::Apply(Foo::crd()))
            .await?;
        let establish = await_condition(crds, "foos.clux.dev", conditions::is_crd_established());
        let _ = tokio::time::timeout(std::time::Duration::from_secs(10), establish).await?;
        // run discovery
        let discovery = Discovery::new(client.clone())
            .exclude(&["rbac.authorization.k8s.io"]) // skip something
            .run()
            .await?;
        // check our custom resource first by resolving within groups
        {
            assert!(discovery.has_group("clux.dev"));
            let gvk = GroupVersionKind::gvk("clux.dev", "v1", "Foo");
            let (ar, _caps) = discovery.resolve_gvk(&gvk).unwrap();
            assert_eq!(ar.group, gvk.group);
            assert_eq!(ar.version, gvk.version);
            assert_eq!(ar.kind, gvk.kind);
        }
        // check all non-excluded groups that are iterable
        for group in discovery.groups() {
            for (ar, caps) in group.recommended_resources() {
                if !caps.supports_operation(verbs::LIST) {
                    continue;
                }
                let api: Api<DynamicObject> = if caps.scope == Scope::Namespaced {
                    Api::default_namespaced_with(client.clone(), &ar)
                } else {
                    Api::all_with(client.clone(), &ar)
                };
                api.list(&Default::default()).await?;
            }
        }
        Ok(())
    }
async fn resources_discoverable ( ) -> Result < ( ) , Box < dyn std :: error :: Error > > { use crate :: { core :: { DynamicObject , GroupVersionKind } , discovery :: { verbs , Discovery , Scope } , runtime :: wait :: { await_condition , conditions } , } ; let client = Client :: try_default ( ) . await ? ; // ensure crd is installed let crds : Api < CustomResourceDefinition > = Api :: all ( client . clone ( ) ) ; let ssapply = PatchParams :: apply ( " " ) . force ( ) ; crds . patch ( " " , & ssapply , & Patch :: Apply ( Foo :: crd ( ) ) ) . await ? ; let establish = await_condition ( crds , " " , conditions :: is_crd_established ( ) ) ; let _ = tokio :: time :: timeout ( std :: time :: Duration :: from_secs ( 10 ) , establish ) . await ? ; // run discovery let discovery = Discovery :: new ( client . clone ( ) ) . exclude ( & [ " " ] ) // skip something . run ( ) . await ? ; // check our custom resource first by resolving within groups { assert ! ( discovery has_group ( " " ) ) ; let gvk = GroupVersionKind :: gvk ( " " , " " , " " ) ; let ( ar , _caps ) = discovery . resolve_gvk ( & gvk ) . unwrap ( ) ; assert_eq ! ( ar group gvk group ) ; assert_eq ! ( ar version gvk version ) ; assert_eq ! ( ar kind gvk kind ) ; } // check all non-excluded groups that are iterable for group in discovery . groups ( ) { for ( ar , caps ) in group . recommended_resources ( ) { if ! caps . supports_operation ( verbs :: LIST ) { continue ; } let api : Api < DynamicObject > = if caps . scope == Scope :: Namespaced { Api :: default_namespaced_with ( client . clone ( ) , & ar ) } else { Api :: all_with ( client . clone ( ) , & ar ) } ; api . list ( & Default :: default ( ) ) . await ? ; } } Ok ( ( ) ) }
needs cluster (fetches api resources, and lists all)
needs cluster ( fetches api resources and lists all )