diff --git a/src/tools/genpolicy/src/config_map.rs b/src/tools/genpolicy/src/config_map.rs index da6290f3e7..ac84c623b7 100644 --- a/src/tools/genpolicy/src/config_map.rs +++ b/src/tools/genpolicy/src/config_map.rs @@ -9,13 +9,11 @@ use crate::obj_meta; use crate::pod; use crate::policy; -use crate::settings; use crate::utils::Config; use crate::yaml; use async_trait::async_trait; use log::debug; -use protocols::agent; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::fs::File; @@ -89,20 +87,6 @@ impl yaml::K8sResource for ConfigMap { self.doc_mapping = doc_mapping.clone(); } - fn get_sandbox_name(&self) -> Option { - panic!("Unsupported"); - } - - fn get_container_mounts_and_storages( - &self, - _policy_mounts: &mut Vec, - _storages: &mut Vec, - _container: &pod::Container, - _settings: &settings::Settings, - ) { - panic!("Unsupported"); - } - fn generate_policy(&self, _agent_policy: &policy::AgentPolicy) -> String { "".to_string() } @@ -111,19 +95,7 @@ impl yaml::K8sResource for ConfigMap { serde_yaml::to_string(&self.doc_mapping).unwrap() } - fn get_containers(&self) -> &Vec { - panic!("Unsupported"); - } - fn get_annotations(&self) -> &Option> { &self.metadata.annotations } - - fn use_host_network(&self) -> bool { - panic!("Unsupported"); - } - - fn use_sandbox_pidns(&self) -> bool { - panic!("Unsupported"); - } } diff --git a/src/tools/genpolicy/src/list.rs b/src/tools/genpolicy/src/list.rs index 3b6667261b..e88d5a1ded 100644 --- a/src/tools/genpolicy/src/list.rs +++ b/src/tools/genpolicy/src/list.rs @@ -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)] @@ -50,10 +49,6 @@ impl yaml::K8sResource for List { } } - fn get_sandbox_name(&self) -> Option { - panic!("Unsupported"); - } - fn get_container_mounts_and_storages( &self, _policy_mounts: &mut Vec, @@ -85,20 +80,4 @@ impl yaml::K8sResource for List { } serde_yaml::to_string(&self).unwrap() } - - fn get_containers(&self) -> &Vec { - panic!("Unsupported"); - } - - fn get_annotations(&self) -> &Option> { - panic!("Unsupported"); - } - - fn use_host_network(&self) -> bool { - panic!("Unsupported"); - } - - fn use_sandbox_pidns(&self) -> bool { - panic!("Unsupported"); - } } diff --git a/src/tools/genpolicy/src/no_policy.rs b/src/tools/genpolicy/src/no_policy.rs index e5af283319..ce9f5ec554 100644 --- a/src/tools/genpolicy/src/no_policy.rs +++ b/src/tools/genpolicy/src/no_policy.rs @@ -6,15 +6,11 @@ // Allow K8s YAML field names. #![allow(non_snake_case)] -use crate::pod; use crate::policy; -use crate::settings; use crate::utils::Config; use crate::yaml; use async_trait::async_trait; -use protocols::agent; -use std::collections::BTreeMap; #[derive(Clone, Debug)] pub struct NoPolicyResource { @@ -31,20 +27,6 @@ impl yaml::K8sResource for NoPolicyResource { ) { } - fn get_sandbox_name(&self) -> Option { - panic!("Unsupported"); - } - - fn get_container_mounts_and_storages( - &self, - _policy_mounts: &mut Vec, - _storages: &mut Vec, - _container: &pod::Container, - _settings: &settings::Settings, - ) { - panic!("Unsupported"); - } - fn generate_policy(&self, _agent_policy: &policy::AgentPolicy) -> String { "".to_string() } @@ -52,20 +34,4 @@ impl yaml::K8sResource for NoPolicyResource { fn serialize(&mut self, _policy: &str) -> String { self.yaml.clone() } - - fn get_containers(&self) -> &Vec { - panic!("Unsupported"); - } - - fn get_annotations(&self) -> &Option> { - panic!("Unsupported"); - } - - fn use_host_network(&self) -> bool { - panic!("Unsupported"); - } - - fn use_sandbox_pidns(&self) -> bool { - panic!("Unsupported"); - } } diff --git a/src/tools/genpolicy/src/secret.rs b/src/tools/genpolicy/src/secret.rs index 62f8fe9ca0..7b870886d7 100644 --- a/src/tools/genpolicy/src/secret.rs +++ b/src/tools/genpolicy/src/secret.rs @@ -9,13 +9,11 @@ use crate::obj_meta; use crate::pod; use crate::policy; -use crate::settings; use crate::utils::Config; use crate::yaml; use async_trait::async_trait; use base64::{engine::general_purpose, Engine as _}; -use protocols::agent; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; @@ -78,20 +76,6 @@ impl yaml::K8sResource for Secret { self.doc_mapping = doc_mapping.clone(); } - fn get_sandbox_name(&self) -> Option { - panic!("Unsupported"); - } - - fn get_container_mounts_and_storages( - &self, - _policy_mounts: &mut Vec, - _storages: &mut Vec, - _container: &pod::Container, - _settings: &settings::Settings, - ) { - panic!("Unsupported"); - } - fn generate_policy(&self, _agent_policy: &policy::AgentPolicy) -> String { "".to_string() } @@ -99,20 +83,4 @@ impl yaml::K8sResource for Secret { fn serialize(&mut self, _policy: &str) -> String { serde_yaml::to_string(&self.doc_mapping).unwrap() } - - fn get_containers(&self) -> &Vec { - panic!("Unsupported"); - } - - fn get_annotations(&self) -> &Option> { - panic!("Unsupported"); - } - - fn use_host_network(&self) -> bool { - panic!("Unsupported"); - } - - fn use_sandbox_pidns(&self) -> bool { - panic!("Unsupported"); - } } diff --git a/src/tools/genpolicy/src/yaml.rs b/src/tools/genpolicy/src/yaml.rs index 9ac1302f33..6b7bf0065c 100644 --- a/src/tools/genpolicy/src/yaml.rs +++ b/src/tools/genpolicy/src/yaml.rs @@ -49,26 +49,47 @@ pub trait K8sResource { silent_unsupported_fields: bool, ); - fn generate_policy(&self, agent_policy: &policy::AgentPolicy) -> String; - fn serialize(&mut self, policy: &str) -> String; + fn generate_policy(&self, _agent_policy: &policy::AgentPolicy) -> String { + panic!("Unsupported"); + } + + fn serialize(&mut self, _policy: &str) -> String { + panic!("Unsupported"); + } + + fn get_sandbox_name(&self) -> Option { + panic!("Unsupported"); + } - fn get_sandbox_name(&self) -> Option; fn get_namespace(&self) -> Option { panic!("Unsupported"); } fn get_container_mounts_and_storages( &self, - policy_mounts: &mut Vec, - storages: &mut Vec, - container: &pod::Container, - settings: &settings::Settings, - ); + _policy_mounts: &mut Vec, + _storages: &mut Vec, + _container: &pod::Container, + _settings: &settings::Settings, + ) { + panic!("Unsupported"); + } - fn get_containers(&self) -> &Vec; - fn get_annotations(&self) -> &Option>; - fn use_host_network(&self) -> bool; - fn use_sandbox_pidns(&self) -> bool; + fn get_containers(&self) -> &Vec { + panic!("Unsupported"); + } + + fn get_annotations(&self) -> &Option> { + panic!("Unsupported"); + } + + fn use_host_network(&self) -> bool { + panic!("Unsupported"); + } + + fn use_sandbox_pidns(&self) -> bool { + panic!("Unsupported"); + } } /// See Reference / Kubernetes API / Common Definitions / LabelSelector.