mirror of
https://github.com/moghtech/komodo.git
synced 2026-04-27 19:33:08 -05:00
sync working
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[[deployment]]
|
||||
name = "monitor-proxy"
|
||||
description = ""
|
||||
description = "An NGINX proxy for mogh.tech"
|
||||
tags = ["monitor"]
|
||||
|
||||
[deployment.config]
|
||||
|
||||
@@ -7,7 +7,7 @@ use monitor_client::{
|
||||
builder::BuilderListItem, deployment::DeploymentListItem,
|
||||
procedure::ProcedureListItem, repo::RepoListItem,
|
||||
server::ServerListItem, server_template::ServerTemplateListItem,
|
||||
user::User, user_group::UserGroup,
|
||||
tag::Tag, user::User, user_group::UserGroup,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -258,7 +258,7 @@ pub fn name_to_user_group() -> &'static HashMap<String, UserGroup> {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListUserGroups::default()),
|
||||
)
|
||||
.expect("failed to get procedures from monitor")
|
||||
.expect("failed to get user groups from monitor")
|
||||
.into_iter()
|
||||
.map(|user_group| (user_group.name.clone(), user_group))
|
||||
.collect()
|
||||
@@ -272,9 +272,22 @@ pub fn id_to_user() -> &'static HashMap<String, User> {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListUsers::default()),
|
||||
)
|
||||
.expect("failed to get procedures from monitor")
|
||||
.expect("failed to get users from monitor")
|
||||
.into_iter()
|
||||
.map(|user| (user.id.clone(), user))
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn id_to_tag() -> &'static HashMap<String, Tag> {
|
||||
static ID_TO_TAG: OnceLock<HashMap<String, Tag>> = OnceLock::new();
|
||||
ID_TO_TAG.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListTags::default()),
|
||||
)
|
||||
.expect("failed to get tags from monitor")
|
||||
.into_iter()
|
||||
.map(|tag| (tag.id.clone(), tag))
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use monitor_client::{
|
||||
};
|
||||
use partial_derive2::MaybeNone;
|
||||
|
||||
use crate::{cli_args, monitor_client};
|
||||
use crate::{cli_args, maps::id_to_tag, monitor_client};
|
||||
|
||||
pub mod alerter;
|
||||
pub mod build;
|
||||
@@ -84,11 +84,19 @@ pub trait ResourceSync {
|
||||
Self::minimize_update(original.config, resource.config)
|
||||
.await?;
|
||||
|
||||
let original_tags = original
|
||||
.tags
|
||||
.iter()
|
||||
.filter_map(|id| {
|
||||
id_to_tag().get(id).map(|t| t.name.clone())
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Only try to update if there are any fields to update,
|
||||
// or a change to tags / description
|
||||
if !resource.config.is_none()
|
||||
|| resource.description != original.description
|
||||
|| resource.tags != original.tags
|
||||
|| resource.tags != original_tags
|
||||
{
|
||||
to_update.push((id, resource));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user