diff --git a/src/skate.rs b/src/skate.rs index 3bd17bb..5c513a7 100644 --- a/src/skate.rs +++ b/src/skate.rs @@ -5,7 +5,7 @@ use async_trait::async_trait; use clap::{Args, Command, Parser, Subcommand}; use k8s_openapi::{List, Metadata, NamespaceResourceScope, Resource, ResourceScope}; use k8s_openapi::api::apps::v1::{DaemonSet, Deployment, DeploymentSpec}; -use k8s_openapi::api::core::v1::Pod; +use k8s_openapi::api::core::v1::{Pod, Secret}; use serde_yaml; use serde::{Deserialize, Serialize}; use tokio; @@ -103,6 +103,8 @@ pub enum SupportedResources { Ingress(Ingress), #[strum(serialize = "CronJob")] CronJob(CronJob), + #[strum(serialize = "Secret")] + Secret(k8s_openapi::api::core::v1::Secret), } @@ -114,6 +116,7 @@ impl SupportedResources { SupportedResources::DaemonSet(r) => metadata_name(r), SupportedResources::Ingress(r) => metadata_name(r), SupportedResources::CronJob(r) => metadata_name(r), + SupportedResources::Secret(s) => metadata_name(s), } } @@ -125,6 +128,7 @@ impl SupportedResources { SupportedResources::DaemonSet(d) => d.clone().spec.unwrap_or_default().template.spec.unwrap_or_default().host_network.unwrap_or_default(), SupportedResources::Ingress(_) => false, SupportedResources::CronJob(c) => c.clone().spec.unwrap_or_default().job_template.spec.unwrap_or_default().template.spec.unwrap_or_default().host_network.unwrap_or_default(), + SupportedResources::Secret(_) => false, } } fn fixup_metadata(meta: ObjectMeta, extra_labels: Option>) -> Result> { @@ -148,6 +152,10 @@ impl SupportedResources { pub fn fixup(self) -> Result> { let mut resource = self.clone(); let resource = match resource { + SupportedResources::Secret(ref mut s) => { + // TODO + resource + } SupportedResources::CronJob(ref mut c) => { let original_name = c.metadata.name.clone().unwrap_or("".to_string()); if original_name.is_empty() { @@ -342,6 +350,13 @@ pub fn read_manifests(filenames: Vec) -> Result, let cronjob: CronJob = serde::Deserialize::deserialize(value)?; result.push(SupportedResources::CronJob(cronjob)) } + (Some(api_version), Some(kind)) if + api_version == ::API_VERSION && + kind == ::KIND => + { + let secret: Secret = serde::Deserialize::deserialize(value)?; + result.push(SupportedResources::Secret(secret)) + } _ => { return Err(anyhow!(format!("kind {:?}", kind)).context("unsupported resource type").into()); }