1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
mod cert;
mod error;
mod list_stream;
mod uri;


mod native;
pub use native::*;

pub use self::error::ClientError;
pub use k8_config::K8Config;

/*
#[cfg(feature = "hyper2")]
mod hyper;
#[cfg(feature = "hyper2")]
pub use crate::hyper::*;
*/


#[cfg(feature = "k8")]
pub mod fixture;

use cert::*;

pub mod metadata {
    pub use k8_metadata_client::*;
}

pub use shared::load_and_share;
pub use shared::new_shared;
pub use shared::SharedK8Client;

mod shared {

    use super::ClientError;
    use super::K8Client;
    use super::K8Config;
    use std::sync::Arc;

    pub type SharedK8Client = Arc<K8Client>;

    /// create new shared k8 client based on k8 config
    pub fn new_shared(config: K8Config) -> Result<SharedK8Client, ClientError> {
        let client = K8Client::new(config)?;
        Ok(Arc::new(client))
    }

    /// load k8 config and create shared k8 client
    pub fn load_and_share() -> Result<SharedK8Client, ClientError> {
        let config = K8Config::load()?;
        new_shared(config)
    }
}