genpolicy: expose create as library

This commit allows to programmatically invoke genpolicy. This allows for other
rust tools that don't want to consume genpolicy as binary to generate policies.
One such use-case is the policy integration test implemented in the following
commits.

Signed-off-by: Leonard Cohnen <lc@edgeless.systems>
This commit is contained in:
Leonard Cohnen 2024-12-03 20:56:05 +01:00
parent cf54a1b0e1
commit d03738a757
3 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,30 @@
// Copyright (c) 2024 Edgeless Systems GmbH
//
// SPDX-License-Identifier: Apache-2.0
//
pub mod config_map;
pub mod containerd;
pub mod cronjob;
pub mod daemon_set;
pub mod deployment;
pub mod job;
pub mod list;
pub mod mount_and_storage;
pub mod no_policy;
pub mod obj_meta;
pub mod persistent_volume_claim;
pub mod pod;
pub mod pod_template;
pub mod policy;
pub mod registry;
pub mod registry_containerd;
pub mod replica_set;
pub mod replication_controller;
pub mod secret;
pub mod settings;
pub mod stateful_set;
pub mod utils;
pub mod verity;
pub mod volume;
pub mod yaml;

View File

@ -33,7 +33,7 @@ use std::io::Write;
/// Intermediary format of policy data.
pub struct AgentPolicy {
/// K8s resources described by the input YAML file.
resources: Vec<boxed::Box<dyn yaml::K8sResource + Send + Sync>>,
pub resources: Vec<boxed::Box<dyn yaml::K8sResource + Send + Sync>>,
/// K8s ConfigMap resources described by an additional input YAML file
/// or by the "main" input YAML file, containing additional pod settings.

View File

@ -161,3 +161,9 @@ impl Config {
}
}
}
impl Default for Config {
fn default() -> Self {
Self::new()
}
}