mirror of
https://codeberg.org/icewind/haze.git
synced 2026-10-01 08:44:09 +02:00
feat(pin): Store pinned state in a file within the container
Signed-off-by: Louis Chmn <louis@chmn.me>
This commit is contained in:
parent
8f7c4e1078
commit
8841570e0a
2 changed files with 39 additions and 43 deletions
18
src/main.rs
18
src/main.rs
|
|
@ -68,9 +68,15 @@ async fn main() -> Result<ExitCode> {
|
|||
match args {
|
||||
HazeArgs::Clean => {
|
||||
let list = Cloud::list(&docker, None, &config).await?;
|
||||
let (retain, remove) = list
|
||||
.into_iter()
|
||||
.partition::<Vec<_>, _>(|cloud| cloud.pinned);
|
||||
let mut retain = Vec::new();
|
||||
let mut remove = Vec::new();
|
||||
for cloud in list {
|
||||
if cloud.is_pinned(&docker).await.unwrap_or(false) {
|
||||
retain.push(cloud);
|
||||
} else {
|
||||
remove.push(cloud);
|
||||
}
|
||||
}
|
||||
|
||||
for cloud in remove {
|
||||
if let Err(e) = cloud.destroy(&docker).await {
|
||||
|
|
@ -102,7 +108,11 @@ async fn main() -> Result<ExitCode> {
|
|||
let mut services: Vec<_> = cloud.services().map(Service::name).collect();
|
||||
services.push(cloud.db().name());
|
||||
let services = services.join(", ");
|
||||
let pin = if cloud.pinned { "*" } else { "" };
|
||||
let pin = if cloud.is_pinned(&docker).await.unwrap_or(false) {
|
||||
"*"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
let version = match cloud.options.version.as_ref() {
|
||||
Some(version) => format!(", v{version}"),
|
||||
None => String::new(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue