-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathstderr-plugin.rs
50 lines (41 loc) · 1.12 KB
/
stderr-plugin.rs
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
//! This is just an example plugin, do not use it in production!
use netavark::{
network::types,
plugin::{Info, Plugin, PluginExec, API_VERSION},
};
fn main() {
let info = Info::new("0.1.0-dev".to_owned(), API_VERSION.to_owned(), None);
PluginExec::new(Exec {}, info).exec();
}
struct Exec {}
impl Plugin for Exec {
fn create(
&self,
network: types::Network,
) -> Result<types::Network, Box<dyn std::error::Error>> {
eprintln!("stderr create");
Ok(network)
}
fn setup(
&self,
_netns: String,
_opts: types::NetworkPluginExec,
) -> Result<types::StatusBlock, Box<dyn std::error::Error>> {
eprintln!("stderr setup");
// StatusBlock response
let response = types::StatusBlock {
dns_server_ips: None,
dns_search_domains: None,
interfaces: None,
};
Ok(response)
}
fn teardown(
&self,
_netns: String,
_opts: types::NetworkPluginExec,
) -> Result<(), Box<dyn std::error::Error>> {
eprintln!("stderr teardown");
Ok(())
}
}