1
0
mirror of https://github.com/containers/netavark.git synced 2026-02-05 15:45:47 +01:00
Files
netavark/examples/stderr-plugin.rs
Paul Holzinger 3ad293dbf8 add stderr example plugin to test stderr passthrough
Plugins are allowed to log on stderr, add a small pluign to test it.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-04-04 17:58:27 +02:00

51 lines
1.1 KiB
Rust

//! 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(())
}
}