genpolicy: add default implementation for get_sandbox_name

- Provide default implementation for get_sandbox_name in K8sResource trait
- 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-21 12:02:28 +00:00
parent 43e9de8125
commit 09b0b4c11d
5 changed files with 4 additions and 17 deletions

View File

@ -89,10 +89,6 @@ impl yaml::K8sResource for ConfigMap {
self.doc_mapping = doc_mapping.clone();
}
fn get_sandbox_name(&self) -> Option<String> {
panic!("Unsupported");
}
fn get_container_mounts_and_storages(
&self,
_policy_mounts: &mut Vec<policy::KataMount>,

View File

@ -49,10 +49,6 @@ impl yaml::K8sResource for List {
}
}
fn get_sandbox_name(&self) -> Option<String> {
panic!("Unsupported");
}
fn get_container_mounts_and_storages(
&self,
_policy_mounts: &mut Vec<policy::KataMount>,

View File

@ -30,10 +30,6 @@ impl yaml::K8sResource for NoPolicyResource {
) {
}
fn get_sandbox_name(&self) -> Option<String> {
panic!("Unsupported");
}
fn get_container_mounts_and_storages(
&self,
_policy_mounts: &mut Vec<policy::KataMount>,

View File

@ -78,10 +78,6 @@ impl yaml::K8sResource for Secret {
self.doc_mapping = doc_mapping.clone();
}
fn get_sandbox_name(&self) -> Option<String> {
panic!("Unsupported");
}
fn get_container_mounts_and_storages(
&self,
_policy_mounts: &mut Vec<policy::KataMount>,

View File

@ -52,7 +52,10 @@ pub trait K8sResource {
fn generate_policy(&self, agent_policy: &policy::AgentPolicy) -> String;
fn serialize(&mut self, policy: &str) -> String;
fn get_sandbox_name(&self) -> Option<String>;
fn get_sandbox_name(&self) -> Option<String> {
panic!("Unsupported");
}
fn get_namespace(&self) -> Option<String> {
panic!("Unsupported");
}