-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
142 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use std::collections::HashMap; | ||
use chrono::{Local, SecondsFormat}; | ||
use itertools::Itertools; | ||
use crate::filestore::ObjectListItem; | ||
use crate::get::{GetObjectArgs, IdCommand, Lister}; | ||
use crate::skatelet::{PodmanPodInfo, PodmanPodStatus, SystemInfo}; | ||
use crate::state::state::ClusterState; | ||
use crate::util::age; | ||
|
||
pub(crate) struct SecretLister {} | ||
|
||
impl Lister<ObjectListItem> for SecretLister { | ||
fn selector(&self, si: &SystemInfo, ns: &str, id: &str) -> Option<Vec<ObjectListItem>> { | ||
si.secrets.clone() | ||
} | ||
|
||
fn print(&self, items: Vec<ObjectListItem>) { | ||
let map = items.iter().fold(HashMap::<String, Vec<ObjectListItem>>::new(), |mut acc, item| { | ||
acc.entry(item.name.to_string()).or_insert(vec![]).push(item.clone()); | ||
acc | ||
}); | ||
|
||
macro_rules! cols { | ||
() => ("{0: <15} {1: <15} {2: <15} {3: <15} {4: <10}") | ||
} | ||
println!( | ||
cols!(), | ||
"NAMESPACE", "NAME", "TYPE", "DATA", "AGE", | ||
); | ||
|
||
// TODO - get from manifest | ||
let data = 1; | ||
|
||
for item in map { | ||
let item = item.1.first().unwrap(); | ||
println!(cols!(), item.name.namespace, item.name.name, "Opaque", data, age(item.created_at)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::collections::HashMap; | ||
use chrono::{DateTime, Local}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub(crate) struct PodmanSecret { | ||
#[serde(rename = "ID")] | ||
pub id: String, | ||
pub created_at: DateTime<Local>, | ||
pub updated_at: DateTime<Local>, | ||
pub spec: PodmanSecretSpec, | ||
pub secret_data: String, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub(crate) struct PodmanSecretSpec { | ||
pub name: String, | ||
pub driver: PodmanSecretDriver, | ||
pub labels: HashMap<String, String>, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub(crate) struct PodmanSecretDriver { | ||
pub name: String, | ||
pub options: HashMap<String, String>, | ||
} |