genpolicy: add default implementation for get_annotations

- Provide default implementation for get_annontations.
- Remove default implementation from structs implementing the trait K8sResource

Fixes: #8960
Signed-off-by: Archana Choudhary <archana1@microsoft.com>
This commit is contained in:
Archana Choudhary 2024-04-08 10:45:38 +00:00
parent 7e12d588c0
commit 43e9de8125
4 changed files with 4 additions and 15 deletions

View File

@ -18,7 +18,6 @@ use protocols::agent;
use serde::{Deserialize, Serialize};
use serde_yaml::Value;
use std::boxed;
use std::collections::BTreeMap;
use std::marker::{Send, Sync};
#[derive(Debug, Serialize, Deserialize)]
@ -90,10 +89,6 @@ impl yaml::K8sResource for List {
panic!("Unsupported");
}
fn get_annotations(&self) -> &Option<BTreeMap<String, String>> {
panic!("Unsupported");
}
fn use_host_network(&self) -> bool {
panic!("Unsupported");
}

View File

@ -14,7 +14,6 @@ use crate::yaml;
use async_trait::async_trait;
use protocols::agent;
use std::collections::BTreeMap;
#[derive(Clone, Debug)]
pub struct NoPolicyResource {
@ -57,10 +56,6 @@ impl yaml::K8sResource for NoPolicyResource {
panic!("Unsupported");
}
fn get_annotations(&self) -> &Option<BTreeMap<String, String>> {
panic!("Unsupported");
}
fn use_host_network(&self) -> bool {
panic!("Unsupported");
}

View File

@ -104,10 +104,6 @@ impl yaml::K8sResource for Secret {
panic!("Unsupported");
}
fn get_annotations(&self) -> &Option<BTreeMap<String, String>> {
panic!("Unsupported");
}
fn use_host_network(&self) -> bool {
panic!("Unsupported");
}

View File

@ -66,7 +66,10 @@ pub trait K8sResource {
);
fn get_containers(&self) -> &Vec<pod::Container>;
fn get_annotations(&self) -> &Option<BTreeMap<String, String>>;
fn get_annotations(&self) -> &Option<BTreeMap<String, String>> {
panic!("Unsupported");
}
fn use_host_network(&self) -> bool;
fn use_sandbox_pidns(&self) -> bool;
}