forked from github-starred/komodo
cli much faster
This commit is contained in:
@@ -1,81 +0,0 @@
|
||||
[[build]]
|
||||
name = "monitor_core"
|
||||
description = "Public monitor core build"
|
||||
tags = ["monitor"]
|
||||
|
||||
[build.config]
|
||||
builder_id = "mogh-builder"
|
||||
repo = "mbecker20/monitor"
|
||||
branch = "main"
|
||||
docker_account = "mbecker2020"
|
||||
build_path = "."
|
||||
dockerfile_path = "bin/core/Dockerfile"
|
||||
|
||||
[[build]]
|
||||
name = "monitor_core_dev"
|
||||
description = ""
|
||||
tags = ["monitor", "dev"]
|
||||
|
||||
[build.config]
|
||||
builder_id = "mogh-builder"
|
||||
repo = "mbecker20/monitor"
|
||||
branch = "main"
|
||||
docker_account = "mbecker2020"
|
||||
build_path = "."
|
||||
dockerfile_path = "bin/core/Dockerfile"
|
||||
|
||||
[[build]]
|
||||
name = "monitor_frontend"
|
||||
description = "standalone hosted frontend for monitor.mogh.tech"
|
||||
tags = ["monitor", "frontend"]
|
||||
|
||||
[build.config]
|
||||
builder_id = "mogh-builder"
|
||||
repo = "mbecker20/monitor"
|
||||
branch = "main"
|
||||
docker_account = "mbecker2020"
|
||||
build_path = "."
|
||||
dockerfile_path = "frontend/Dockerfile"
|
||||
|
||||
[[build.config.build_args]]
|
||||
variable = "VITE_MONITOR_HOST"
|
||||
value = "https://monitor.api.mogh.tech"
|
||||
|
||||
[[build]]
|
||||
name = "monitor_frontend_dev"
|
||||
description = "standalone hosted frontend for monitor-dev.mogh.tech"
|
||||
tags = ["monitor", "frontend"]
|
||||
|
||||
[build.config]
|
||||
builder_id = "mogh-builder"
|
||||
repo = "mbecker20/monitor"
|
||||
branch = "main"
|
||||
docker_account = "mbecker2020"
|
||||
build_path = "."
|
||||
dockerfile_path = "frontend/Dockerfile"
|
||||
|
||||
[[build.config.build_args]]
|
||||
variable = "VITE_MONITOR_HOST"
|
||||
value = "https://monitor-dev.api.mogh.tech"
|
||||
|
||||
## BUILDER
|
||||
|
||||
[[builder]]
|
||||
name = "mogh-builder"
|
||||
description = ""
|
||||
tags = []
|
||||
|
||||
[builder.config]
|
||||
type = "Aws"
|
||||
|
||||
[builder.config.params]
|
||||
region = "us-east-2"
|
||||
instance_type = "c5.2xlarge"
|
||||
volume_gb = 20
|
||||
port = 8120
|
||||
ami_id = "ami-0c5d5efd79075c0e3"
|
||||
subnet_id = "subnet-02ae5ad480eacc4bc"
|
||||
security_group_ids = ["sg-049d98c819f9ace58", "sg-006c0ca638af8eb44"]
|
||||
key_pair_name = "mogh-key"
|
||||
assign_public_ip = true
|
||||
use_public_ip = true
|
||||
@@ -1,213 +0,0 @@
|
||||
## MONITOR PROXY
|
||||
[[deployment]]
|
||||
name = "monitor-proxy"
|
||||
description = "An NGINX proxy for mogh.tech"
|
||||
tags = ["monitor"]
|
||||
config.server_id = "monitor-01"
|
||||
config.network = "host"
|
||||
config.restart = "unless-stopped"
|
||||
config.image.type = "Image"
|
||||
config.image.params.image = "jc21/nginx-proxy-manager"
|
||||
|
||||
[[deployment.config.volumes]]
|
||||
local = "/data/nginx/data"
|
||||
container = "/data"
|
||||
|
||||
[[deployment.config.volumes]]
|
||||
local = "/data/nginx/letsencrypt"
|
||||
container = "/etc/letsencrypt"
|
||||
|
||||
## MONITOR MONGO
|
||||
[[deployment]]
|
||||
name = "monitor-mongo"
|
||||
description = "shared mongo deployment"
|
||||
tags = ["monitor"]
|
||||
|
||||
[deployment.config]
|
||||
server_id = "monitor-01"
|
||||
network = "host"
|
||||
restart = "no"
|
||||
|
||||
[deployment.config.image]
|
||||
type = "Image"
|
||||
params.image = "mongo"
|
||||
|
||||
## MONITOR CORE
|
||||
[[deployment]]
|
||||
name = "monitor-core"
|
||||
description = ""
|
||||
tags = ["monitor"]
|
||||
|
||||
[deployment.config]
|
||||
server_id = "monitor-01"
|
||||
network = "host"
|
||||
restart = "no"
|
||||
|
||||
[deployment.config.image]
|
||||
type = "Image"
|
||||
params.image = "mbecker2020/monitor_core"
|
||||
|
||||
## GRAFANA
|
||||
[[deployment]]
|
||||
name = "grafana"
|
||||
description = "runs on port 3080"
|
||||
tags = ["logging"]
|
||||
|
||||
[deployment.config]
|
||||
server_id = "monitor-01"
|
||||
network = "host"
|
||||
restart = "unless-stopped"
|
||||
extra_args = ["--user root"]
|
||||
|
||||
[deployment.config.image]
|
||||
type = "Image"
|
||||
params.image = "grafana/grafana"
|
||||
|
||||
[[deployment.config.volumes]]
|
||||
local = "/data/grafana"
|
||||
container = "/var/lib/grafana"
|
||||
|
||||
[[deployment.config.environment]]
|
||||
variable = "GF_SERVER_HTTP_PORT"
|
||||
value = "3080"
|
||||
|
||||
[[deployment.config.labels]]
|
||||
variable = "vector"
|
||||
value = "key-value"
|
||||
|
||||
## LOKI
|
||||
[[deployment]]
|
||||
name = "loki"
|
||||
description = "runs on 3100"
|
||||
tags = ["logging"]
|
||||
|
||||
[deployment.config]
|
||||
server_id = "monitor-01"
|
||||
network = "host"
|
||||
restart = "unless-stopped"
|
||||
extra_args = ["--user root"]
|
||||
|
||||
[deployment.config.image]
|
||||
type = "Image"
|
||||
params.image = "grafana/loki"
|
||||
|
||||
[[deployment.config.volumes]]
|
||||
local = "/data/loki"
|
||||
container = "/loki"
|
||||
|
||||
[[deployment]]
|
||||
name = "tempo"
|
||||
description = "OTLP: port 4317. HTTP: 3200"
|
||||
tags = ["logging"]
|
||||
|
||||
[deployment.config]
|
||||
server_id = "monitor-01"
|
||||
network = "host"
|
||||
restart = "unless-stopped"
|
||||
command = "-server.http-listen-port=3200 -server.grpc-listen-port=9096 --storage.trace.backend=local --storage.trace.local.path=/tmp/tempo/traces --storage.trace.wal.path=/tmp/tempo/wal"
|
||||
extra_args = ["--user root"]
|
||||
|
||||
[deployment.config.image]
|
||||
type = "Image"
|
||||
params.image = "grafana/tempo"
|
||||
|
||||
[[deployment.config.volumes]]
|
||||
local = "/data/tempo"
|
||||
container = "/tmp/tempo"
|
||||
|
||||
[[deployment.config.labels]]
|
||||
variable = "vector"
|
||||
value = "key-value"
|
||||
|
||||
## VECTOR
|
||||
[[deployment]]
|
||||
name = "vector"
|
||||
description = "collects the docker logs (and alert endpoint)"
|
||||
tags = ["logging"]
|
||||
|
||||
[deployment.config]
|
||||
server_id = "monitor-01"
|
||||
network = "host"
|
||||
restart = "unless-stopped"
|
||||
command = "--config /etc/vector/*.toml"
|
||||
extra_args = ["--user root"]
|
||||
|
||||
[deployment.config.image]
|
||||
type = "Image"
|
||||
params.image = "timberio/vector:latest-debian"
|
||||
|
||||
[[deployment.config.volumes]]
|
||||
local = "/root/.config/vector"
|
||||
container = "/etc/vector"
|
||||
|
||||
[[deployment.config.volumes]]
|
||||
local = "/data/vector"
|
||||
container = "/var/lib/vector"
|
||||
|
||||
[[deployment.config.volumes]]
|
||||
local = "/var/run/docker.sock"
|
||||
container = "/var/run/docker.sock"
|
||||
|
||||
[[deployment.config.labels]]
|
||||
variable = "vector"
|
||||
value = "key-value"
|
||||
|
||||
## MONITOR CORE DEV
|
||||
[[deployment]]
|
||||
name = "monitor-core-dev"
|
||||
description = "runs on 9001"
|
||||
tags = ["monitor", "dev"]
|
||||
|
||||
[deployment.config]
|
||||
server_id = "monitor-01"
|
||||
redeploy_on_build = true
|
||||
network = "host"
|
||||
restart = "no"
|
||||
|
||||
[deployment.config.image]
|
||||
type = "Build"
|
||||
params.build_id = "monitor_core"
|
||||
|
||||
[[deployment.config.volumes]]
|
||||
local = "/root/.config/monitor/dev.core.config.toml"
|
||||
container = "/config/config.toml"
|
||||
|
||||
[[deployment.config.volumes]]
|
||||
local = "/data/repos/monitor-dev-frontend/frontend/dist"
|
||||
container = "/frontend"
|
||||
|
||||
[[deployment.config.labels]]
|
||||
variable = "vector"
|
||||
value = "rust"
|
||||
|
||||
## MONITOR FRONTEND
|
||||
[[deployment]]
|
||||
name = "monitor-frontend"
|
||||
description = ""
|
||||
tags = ["monitor", "frontend"]
|
||||
|
||||
[deployment.config]
|
||||
server_id = "monitor-01"
|
||||
redeploy_on_build = true
|
||||
network = "host"
|
||||
restart = "unless-stopped"
|
||||
image.type = "Build"
|
||||
image.params.build = "monitor_frontend"
|
||||
|
||||
## MONITOR DEV FRONTEND
|
||||
[[deployment]]
|
||||
name = "monitor-dev-frontend"
|
||||
description = ""
|
||||
tags = ["monitor", "dev", "frontend"]
|
||||
|
||||
[deployment.config]
|
||||
server_id = "monitor-01"
|
||||
redeploy_on_build = true
|
||||
network = "host"
|
||||
restart = "unless-stopped"
|
||||
image.type = "Build"
|
||||
image.params.build = "monitor_frontend_dev"
|
||||
|
||||
[[deployment.config.environment]]
|
||||
variable = "PORT"
|
||||
value = "4175"
|
||||
@@ -1,35 +0,0 @@
|
||||
[[procedure]]
|
||||
name = "build-monitor"
|
||||
description = ""
|
||||
tags = ["monitor"]
|
||||
|
||||
[procedure.config]
|
||||
procedure_type = "Parallel"
|
||||
webhook_enabled = true
|
||||
|
||||
[[procedure.config.executions]]
|
||||
enabled = true
|
||||
|
||||
[procedure.config.executions.execution]
|
||||
type = "RunBuild"
|
||||
|
||||
[procedure.config.executions.execution.params]
|
||||
build = "monitor_core"
|
||||
|
||||
[[procedure.config.executions]]
|
||||
enabled = true
|
||||
|
||||
[procedure.config.executions.execution]
|
||||
type = "RunBuild"
|
||||
|
||||
[procedure.config.executions.execution.params]
|
||||
build = "monitor_frontend"
|
||||
|
||||
[[procedure.config.executions]]
|
||||
enabled = false
|
||||
|
||||
[procedure.config.executions.execution]
|
||||
type = "RunBuild"
|
||||
|
||||
[procedure.config.executions.execution.params]
|
||||
build = "monitor_frontend_dev"
|
||||
@@ -1,37 +0,0 @@
|
||||
# [[repo]]
|
||||
# name = "monitor-dev-frontend"
|
||||
# description = "Used as frontend for monitor-core-dev"
|
||||
# tags = ["monitor", "dev"]
|
||||
|
||||
# [repo.config]
|
||||
# server_id = "monitor-01"
|
||||
# repo = "mbecker20/monitor"
|
||||
# branch = "main"
|
||||
# github_account = ""
|
||||
|
||||
# [repo.config.on_clone]
|
||||
# path = ""
|
||||
# command = ""
|
||||
|
||||
# [repo.config.on_pull]
|
||||
# path = "frontend"
|
||||
# command = "sh on_pull.sh"
|
||||
|
||||
[[repo]]
|
||||
name = "monitor-periphery"
|
||||
description = ""
|
||||
tags = ["monitor"]
|
||||
|
||||
[repo.config]
|
||||
server_id = "monitor-01"
|
||||
repo = "mbecker20/monitor"
|
||||
branch = "main"
|
||||
github_account = ""
|
||||
|
||||
[repo.config.on_clone]
|
||||
path = ""
|
||||
command = ""
|
||||
|
||||
[repo.config.on_pull]
|
||||
path = "."
|
||||
command = "/root/.cargo/bin/cargo build -p monitor_periphery --release && cp ./target/release/periphery /home/ubuntu/periphery"
|
||||
@@ -1,81 +0,0 @@
|
||||
[[server]]
|
||||
name = "monitor-01"
|
||||
description = ""
|
||||
tags = ["monitor"]
|
||||
|
||||
[server.config]
|
||||
address = "http://localhost:8120"
|
||||
enabled = true
|
||||
stats_monitoring = true
|
||||
auto_prune = true
|
||||
send_unreachable_alerts = true
|
||||
send_cpu_alerts = true
|
||||
send_mem_alerts = true
|
||||
send_disk_alerts = true
|
||||
region = "us-east-2"
|
||||
|
||||
## TEMPLATE
|
||||
|
||||
[[server_template]]
|
||||
name = "mogh-template"
|
||||
description = ""
|
||||
tags = []
|
||||
|
||||
[server_template.config]
|
||||
type = "Aws"
|
||||
|
||||
[server_template.config.params]
|
||||
region = "us-east-2"
|
||||
instance_type = "t3.medium"
|
||||
ami_id = "ami-0005a05fa63a080ab"
|
||||
subnet_id = "subnet-02ae5ad480eacc4bc"
|
||||
key_pair_name = "mogh-key"
|
||||
assign_public_ip = true
|
||||
use_public_ip = false
|
||||
port = 8120
|
||||
user_data = ""
|
||||
security_group_ids = ["sg-049d98c819f9ace58", "sg-006c0ca638af8eb44"]
|
||||
|
||||
[[server_template.config.params.volumes]]
|
||||
device_name = "/dev/sda1"
|
||||
size_gb = 20
|
||||
volume_type = "gp2"
|
||||
iops = 0
|
||||
throughput = 0
|
||||
|
||||
[[server_template.config.params.volumes]]
|
||||
device_name = "/dev/sdb"
|
||||
size_gb = 10
|
||||
volume_type = "gp3"
|
||||
iops = 0
|
||||
throughput = 0
|
||||
|
||||
[[server_template]]
|
||||
name = "hetzno"
|
||||
description = ""
|
||||
tags = []
|
||||
|
||||
[server_template.config]
|
||||
type = "Hetzner"
|
||||
|
||||
[server_template.config.params]
|
||||
image = "docker-ce"
|
||||
automount = true
|
||||
datacenter = "HillsboroDc1"
|
||||
private_network_ids = [4258025]
|
||||
enable_public_ipv4 = true
|
||||
enable_public_ipv6 = true
|
||||
firewall_ids = [1402830, 1402832, 1410630]
|
||||
server_type = "SharedAmd3Core4Ram80Disk"
|
||||
ssh_keys = ["becker@Beckers-MacBook-Pro.local"]
|
||||
user_data = """
|
||||
#cloud-config
|
||||
runcmd:
|
||||
- curl -sSL 'https://raw.githubusercontent.com/mbecker20/monitor/main/scripts/setup-periphery.py' | python3"""
|
||||
use_public_ip = false
|
||||
port = 8120
|
||||
|
||||
[[server_template.config.params.volumes]]
|
||||
name = "data"
|
||||
format = "Xfs"
|
||||
size_gb = 200
|
||||
@@ -3,22 +3,21 @@ use std::{collections::HashMap, sync::OnceLock};
|
||||
use monitor_client::{
|
||||
api::read,
|
||||
entities::{
|
||||
alerter::AlerterListItem, build::BuildListItem,
|
||||
builder::BuilderListItem, deployment::DeploymentListItem,
|
||||
procedure::ProcedureListItem, repo::RepoListItem,
|
||||
server::ServerListItem, server_template::ServerTemplateListItem,
|
||||
tag::Tag, user::User, user_group::UserGroup,
|
||||
alerter::Alerter, build::Build, builder::Builder,
|
||||
deployment::Deployment, procedure::Procedure, repo::Repo,
|
||||
server::Server, server_template::ServerTemplate, tag::Tag,
|
||||
user::User, user_group::UserGroup,
|
||||
},
|
||||
};
|
||||
|
||||
use crate::monitor_client;
|
||||
|
||||
pub fn name_to_build() -> &'static HashMap<String, BuildListItem> {
|
||||
static NAME_TO_BUILD: OnceLock<HashMap<String, BuildListItem>> =
|
||||
pub fn name_to_build() -> &'static HashMap<String, Build> {
|
||||
static NAME_TO_BUILD: OnceLock<HashMap<String, Build>> =
|
||||
OnceLock::new();
|
||||
NAME_TO_BUILD.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListBuilds::default()),
|
||||
monitor_client().read(read::ListFullBuilds::default()),
|
||||
)
|
||||
.expect("failed to get builds from monitor")
|
||||
.into_iter()
|
||||
@@ -27,12 +26,12 @@ pub fn name_to_build() -> &'static HashMap<String, BuildListItem> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn id_to_build() -> &'static HashMap<String, BuildListItem> {
|
||||
static ID_TO_BUILD: OnceLock<HashMap<String, BuildListItem>> =
|
||||
pub fn id_to_build() -> &'static HashMap<String, Build> {
|
||||
static ID_TO_BUILD: OnceLock<HashMap<String, Build>> =
|
||||
OnceLock::new();
|
||||
ID_TO_BUILD.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListBuilds::default()),
|
||||
monitor_client().read(read::ListFullBuilds::default()),
|
||||
)
|
||||
.expect("failed to get builds from monitor")
|
||||
.into_iter()
|
||||
@@ -41,14 +40,12 @@ pub fn id_to_build() -> &'static HashMap<String, BuildListItem> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn name_to_deployment(
|
||||
) -> &'static HashMap<String, DeploymentListItem> {
|
||||
static NAME_TO_DEPLOYMENT: OnceLock<
|
||||
HashMap<String, DeploymentListItem>,
|
||||
> = OnceLock::new();
|
||||
pub fn name_to_deployment() -> &'static HashMap<String, Deployment> {
|
||||
static NAME_TO_DEPLOYMENT: OnceLock<HashMap<String, Deployment>> =
|
||||
OnceLock::new();
|
||||
NAME_TO_DEPLOYMENT.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListDeployments::default()),
|
||||
monitor_client().read(read::ListFullDeployments::default()),
|
||||
)
|
||||
.expect("failed to get deployments from monitor")
|
||||
.into_iter()
|
||||
@@ -57,14 +54,12 @@ pub fn name_to_deployment(
|
||||
})
|
||||
}
|
||||
|
||||
pub fn id_to_deployment(
|
||||
) -> &'static HashMap<String, DeploymentListItem> {
|
||||
static ID_TO_DEPLOYMENT: OnceLock<
|
||||
HashMap<String, DeploymentListItem>,
|
||||
> = OnceLock::new();
|
||||
pub fn id_to_deployment() -> &'static HashMap<String, Deployment> {
|
||||
static ID_TO_DEPLOYMENT: OnceLock<HashMap<String, Deployment>> =
|
||||
OnceLock::new();
|
||||
ID_TO_DEPLOYMENT.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListDeployments::default()),
|
||||
monitor_client().read(read::ListFullDeployments::default()),
|
||||
)
|
||||
.expect("failed to get deployments from monitor")
|
||||
.into_iter()
|
||||
@@ -73,12 +68,12 @@ pub fn id_to_deployment(
|
||||
})
|
||||
}
|
||||
|
||||
pub fn name_to_server() -> &'static HashMap<String, ServerListItem> {
|
||||
static NAME_TO_SERVER: OnceLock<HashMap<String, ServerListItem>> =
|
||||
pub fn name_to_server() -> &'static HashMap<String, Server> {
|
||||
static NAME_TO_SERVER: OnceLock<HashMap<String, Server>> =
|
||||
OnceLock::new();
|
||||
NAME_TO_SERVER.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListServers::default()),
|
||||
monitor_client().read(read::ListFullServers::default()),
|
||||
)
|
||||
.expect("failed to get servers from monitor")
|
||||
.into_iter()
|
||||
@@ -87,12 +82,12 @@ pub fn name_to_server() -> &'static HashMap<String, ServerListItem> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn id_to_server() -> &'static HashMap<String, ServerListItem> {
|
||||
static ID_TO_SERVER: OnceLock<HashMap<String, ServerListItem>> =
|
||||
pub fn id_to_server() -> &'static HashMap<String, Server> {
|
||||
static ID_TO_SERVER: OnceLock<HashMap<String, Server>> =
|
||||
OnceLock::new();
|
||||
ID_TO_SERVER.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListServers::default()),
|
||||
monitor_client().read(read::ListFullServers::default()),
|
||||
)
|
||||
.expect("failed to get servers from monitor")
|
||||
.into_iter()
|
||||
@@ -101,13 +96,12 @@ pub fn id_to_server() -> &'static HashMap<String, ServerListItem> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn name_to_builder() -> &'static HashMap<String, BuilderListItem>
|
||||
{
|
||||
static NAME_TO_BUILDER: OnceLock<HashMap<String, BuilderListItem>> =
|
||||
pub fn name_to_builder() -> &'static HashMap<String, Builder> {
|
||||
static NAME_TO_BUILDER: OnceLock<HashMap<String, Builder>> =
|
||||
OnceLock::new();
|
||||
NAME_TO_BUILDER.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListBuilders::default()),
|
||||
monitor_client().read(read::ListFullBuilders::default()),
|
||||
)
|
||||
.expect("failed to get builders from monitor")
|
||||
.into_iter()
|
||||
@@ -116,12 +110,12 @@ pub fn name_to_builder() -> &'static HashMap<String, BuilderListItem>
|
||||
})
|
||||
}
|
||||
|
||||
pub fn id_to_builder() -> &'static HashMap<String, BuilderListItem> {
|
||||
static ID_TO_BUILDER: OnceLock<HashMap<String, BuilderListItem>> =
|
||||
pub fn id_to_builder() -> &'static HashMap<String, Builder> {
|
||||
static ID_TO_BUILDER: OnceLock<HashMap<String, Builder>> =
|
||||
OnceLock::new();
|
||||
ID_TO_BUILDER.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListBuilders::default()),
|
||||
monitor_client().read(read::ListFullBuilders::default()),
|
||||
)
|
||||
.expect("failed to get builders from monitor")
|
||||
.into_iter()
|
||||
@@ -130,13 +124,12 @@ pub fn id_to_builder() -> &'static HashMap<String, BuilderListItem> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn name_to_alerter() -> &'static HashMap<String, AlerterListItem>
|
||||
{
|
||||
static NAME_TO_ALERTER: OnceLock<HashMap<String, AlerterListItem>> =
|
||||
pub fn name_to_alerter() -> &'static HashMap<String, Alerter> {
|
||||
static NAME_TO_ALERTER: OnceLock<HashMap<String, Alerter>> =
|
||||
OnceLock::new();
|
||||
NAME_TO_ALERTER.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListAlerters::default()),
|
||||
monitor_client().read(read::ListFullAlerters::default()),
|
||||
)
|
||||
.expect("failed to get alerters from monitor")
|
||||
.into_iter()
|
||||
@@ -145,12 +138,12 @@ pub fn name_to_alerter() -> &'static HashMap<String, AlerterListItem>
|
||||
})
|
||||
}
|
||||
|
||||
pub fn id_to_alerter() -> &'static HashMap<String, AlerterListItem> {
|
||||
static ID_TO_ALERTER: OnceLock<HashMap<String, AlerterListItem>> =
|
||||
pub fn id_to_alerter() -> &'static HashMap<String, Alerter> {
|
||||
static ID_TO_ALERTER: OnceLock<HashMap<String, Alerter>> =
|
||||
OnceLock::new();
|
||||
ID_TO_ALERTER.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListAlerters::default()),
|
||||
monitor_client().read(read::ListFullAlerters::default()),
|
||||
)
|
||||
.expect("failed to get alerters from monitor")
|
||||
.into_iter()
|
||||
@@ -159,12 +152,12 @@ pub fn id_to_alerter() -> &'static HashMap<String, AlerterListItem> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn name_to_repo() -> &'static HashMap<String, RepoListItem> {
|
||||
static NAME_TO_ALERTER: OnceLock<HashMap<String, RepoListItem>> =
|
||||
pub fn name_to_repo() -> &'static HashMap<String, Repo> {
|
||||
static NAME_TO_ALERTER: OnceLock<HashMap<String, Repo>> =
|
||||
OnceLock::new();
|
||||
NAME_TO_ALERTER.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListRepos::default()),
|
||||
monitor_client().read(read::ListFullRepos::default()),
|
||||
)
|
||||
.expect("failed to get repos from monitor")
|
||||
.into_iter()
|
||||
@@ -173,12 +166,12 @@ pub fn name_to_repo() -> &'static HashMap<String, RepoListItem> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn id_to_repo() -> &'static HashMap<String, RepoListItem> {
|
||||
static ID_TO_ALERTER: OnceLock<HashMap<String, RepoListItem>> =
|
||||
pub fn id_to_repo() -> &'static HashMap<String, Repo> {
|
||||
static ID_TO_ALERTER: OnceLock<HashMap<String, Repo>> =
|
||||
OnceLock::new();
|
||||
ID_TO_ALERTER.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListRepos::default()),
|
||||
monitor_client().read(read::ListFullRepos::default()),
|
||||
)
|
||||
.expect("failed to get repos from monitor")
|
||||
.into_iter()
|
||||
@@ -187,14 +180,12 @@ pub fn id_to_repo() -> &'static HashMap<String, RepoListItem> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn name_to_procedure(
|
||||
) -> &'static HashMap<String, ProcedureListItem> {
|
||||
static NAME_TO_PROCEDURE: OnceLock<
|
||||
HashMap<String, ProcedureListItem>,
|
||||
> = OnceLock::new();
|
||||
pub fn name_to_procedure() -> &'static HashMap<String, Procedure> {
|
||||
static NAME_TO_PROCEDURE: OnceLock<HashMap<String, Procedure>> =
|
||||
OnceLock::new();
|
||||
NAME_TO_PROCEDURE.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListProcedures::default()),
|
||||
monitor_client().read(read::ListFullProcedures::default()),
|
||||
)
|
||||
.expect("failed to get procedures from monitor")
|
||||
.into_iter()
|
||||
@@ -203,14 +194,12 @@ pub fn name_to_procedure(
|
||||
})
|
||||
}
|
||||
|
||||
pub fn id_to_procedure() -> &'static HashMap<String, ProcedureListItem>
|
||||
{
|
||||
static ID_TO_PROCEDURE: OnceLock<
|
||||
HashMap<String, ProcedureListItem>,
|
||||
> = OnceLock::new();
|
||||
pub fn id_to_procedure() -> &'static HashMap<String, Procedure> {
|
||||
static ID_TO_PROCEDURE: OnceLock<HashMap<String, Procedure>> =
|
||||
OnceLock::new();
|
||||
ID_TO_PROCEDURE.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListProcedures::default()),
|
||||
monitor_client().read(read::ListFullProcedures::default()),
|
||||
)
|
||||
.expect("failed to get procedures from monitor")
|
||||
.into_iter()
|
||||
@@ -220,13 +209,13 @@ pub fn id_to_procedure() -> &'static HashMap<String, ProcedureListItem>
|
||||
}
|
||||
|
||||
pub fn name_to_server_template(
|
||||
) -> &'static HashMap<String, ServerTemplateListItem> {
|
||||
) -> &'static HashMap<String, ServerTemplate> {
|
||||
static NAME_TO_SERVER_TEMPLATE: OnceLock<
|
||||
HashMap<String, ServerTemplateListItem>,
|
||||
HashMap<String, ServerTemplate>,
|
||||
> = OnceLock::new();
|
||||
NAME_TO_SERVER_TEMPLATE.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListServerTemplates::default()),
|
||||
monitor_client().read(read::ListFullServerTemplates::default()),
|
||||
)
|
||||
.expect("failed to get server templates from monitor")
|
||||
.into_iter()
|
||||
@@ -236,13 +225,13 @@ pub fn name_to_server_template(
|
||||
}
|
||||
|
||||
pub fn id_to_server_template(
|
||||
) -> &'static HashMap<String, ServerTemplateListItem> {
|
||||
) -> &'static HashMap<String, ServerTemplate> {
|
||||
static ID_TO_SERVER_TEMPLATE: OnceLock<
|
||||
HashMap<String, ServerTemplateListItem>,
|
||||
HashMap<String, ServerTemplate>,
|
||||
> = OnceLock::new();
|
||||
ID_TO_SERVER_TEMPLATE.get_or_init(|| {
|
||||
futures::executor::block_on(
|
||||
monitor_client().read(read::ListServerTemplates::default()),
|
||||
monitor_client().read(read::ListFullServerTemplates::default()),
|
||||
)
|
||||
.expect("failed to get server templates from monitor")
|
||||
.into_iter()
|
||||
|
||||
@@ -23,24 +23,27 @@ pub async fn run_sync(path: &Path) -> anyhow::Result<()> {
|
||||
|
||||
info!("computing sync actions...");
|
||||
|
||||
let (server_template_creates, server_template_updates) =
|
||||
ServerTemplate::get_updates(resources.server_templates).await?;
|
||||
let (server_creates, server_updates) =
|
||||
Server::get_updates(resources.servers).await?;
|
||||
let (deployment_creates, deployment_updates) =
|
||||
Deployment::get_updates(resources.deployments).await?;
|
||||
let (build_creates, build_updates) =
|
||||
Build::get_updates(resources.builds).await?;
|
||||
let (builder_creates, builder_updates) =
|
||||
Builder::get_updates(resources.builders).await?;
|
||||
let (alerter_creates, alerter_updates) =
|
||||
Alerter::get_updates(resources.alerters).await?;
|
||||
let (repo_creates, repo_updates) =
|
||||
Repo::get_updates(resources.repos).await?;
|
||||
let (procedure_creates, procedure_updates) =
|
||||
Procedure::get_updates(resources.procedures).await?;
|
||||
let (user_group_creates, user_group_updates) =
|
||||
user_group::get_updates(resources.user_groups).await?;
|
||||
let (
|
||||
(server_template_creates, server_template_updates),
|
||||
(server_creates, server_updates),
|
||||
(deployment_creates, deployment_updates),
|
||||
(build_creates, build_updates),
|
||||
(builder_creates, builder_updates),
|
||||
(alerter_creates, alerter_updates),
|
||||
(repo_creates, repo_updates),
|
||||
(procedure_creates, procedure_updates),
|
||||
(user_group_creates, user_group_updates),
|
||||
) = tokio::try_join!(
|
||||
ServerTemplate::get_updates(resources.server_templates),
|
||||
Server::get_updates(resources.servers),
|
||||
Deployment::get_updates(resources.deployments),
|
||||
Build::get_updates(resources.builds),
|
||||
Builder::get_updates(resources.builders),
|
||||
Alerter::get_updates(resources.alerters),
|
||||
Repo::get_updates(resources.repos),
|
||||
Procedure::get_updates(resources.procedures),
|
||||
user_group::get_updates(resources.user_groups)
|
||||
)?;
|
||||
|
||||
if server_template_creates.is_empty()
|
||||
&& server_template_updates.is_empty()
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use monitor_client::{
|
||||
api::{
|
||||
read::GetAlerter,
|
||||
write::{CreateAlerter, UpdateAlerter},
|
||||
},
|
||||
api::write::{CreateAlerter, UpdateAlerter},
|
||||
entities::{
|
||||
alerter::{
|
||||
Alerter, AlerterConfig, AlerterConfigDiff, AlerterInfo, AlerterListItemInfo, PartialAlerterConfig
|
||||
Alerter, AlerterConfig, AlerterConfigDiff, AlerterInfo,
|
||||
PartialAlerterConfig,
|
||||
},
|
||||
resource::{Resource, ResourceListItem},
|
||||
resource::Resource,
|
||||
toml::ResourceToml,
|
||||
update::ResourceTarget,
|
||||
},
|
||||
@@ -25,7 +23,6 @@ impl ResourceSync for Alerter {
|
||||
type Info = AlerterInfo;
|
||||
type PartialConfig = PartialAlerterConfig;
|
||||
type ConfigDiff = AlerterConfigDiff;
|
||||
type ListItemInfo = AlerterListItemInfo;
|
||||
|
||||
fn display() -> &'static str {
|
||||
"alerter"
|
||||
@@ -36,7 +33,7 @@ impl ResourceSync for Alerter {
|
||||
}
|
||||
|
||||
fn name_to_resource(
|
||||
) -> &'static HashMap<String, ResourceListItem<Self::ListItemInfo>>
|
||||
) -> &'static HashMap<String, Resource<Self::Config, Self::Info>>
|
||||
{
|
||||
name_to_alerter()
|
||||
}
|
||||
@@ -66,12 +63,6 @@ impl ResourceSync for Alerter {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get(
|
||||
id: String,
|
||||
) -> anyhow::Result<Resource<Self::Config, Self::Info>> {
|
||||
monitor_client().read(GetAlerter { alerter: id }).await
|
||||
}
|
||||
|
||||
async fn get_diff(
|
||||
original: Self::Config,
|
||||
update: Self::PartialConfig,
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use monitor_client::{
|
||||
api::{
|
||||
read::GetBuild,
|
||||
write::{CreateBuild, UpdateBuild},
|
||||
},
|
||||
api::write::{CreateBuild, UpdateBuild},
|
||||
entities::{
|
||||
build::{
|
||||
Build, BuildConfig, BuildConfigDiff, BuildInfo,
|
||||
BuildListItemInfo, PartialBuildConfig,
|
||||
PartialBuildConfig,
|
||||
},
|
||||
resource::{Resource, ResourceListItem},
|
||||
resource::Resource,
|
||||
toml::ResourceToml,
|
||||
update::ResourceTarget,
|
||||
},
|
||||
@@ -29,7 +26,6 @@ impl ResourceSync for Build {
|
||||
type Info = BuildInfo;
|
||||
type PartialConfig = PartialBuildConfig;
|
||||
type ConfigDiff = BuildConfigDiff;
|
||||
type ListItemInfo = BuildListItemInfo;
|
||||
|
||||
fn display() -> &'static str {
|
||||
"build"
|
||||
@@ -40,7 +36,7 @@ impl ResourceSync for Build {
|
||||
}
|
||||
|
||||
fn name_to_resource(
|
||||
) -> &'static HashMap<String, ResourceListItem<Self::ListItemInfo>>
|
||||
) -> &'static HashMap<String, Resource<Self::Config, Self::Info>>
|
||||
{
|
||||
name_to_build()
|
||||
}
|
||||
@@ -70,12 +66,6 @@ impl ResourceSync for Build {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get(
|
||||
id: String,
|
||||
) -> anyhow::Result<Resource<Self::Config, Self::Info>> {
|
||||
monitor_client().read(GetBuild { build: id }).await
|
||||
}
|
||||
|
||||
async fn get_diff(
|
||||
mut original: Self::Config,
|
||||
update: Self::PartialConfig,
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use monitor_client::{
|
||||
api::{
|
||||
read::GetBuilder,
|
||||
write::{CreateBuilder, UpdateBuilder},
|
||||
},
|
||||
api::write::{CreateBuilder, UpdateBuilder},
|
||||
entities::{
|
||||
builder::{
|
||||
Builder, BuilderConfig, BuilderConfigDiff, BuilderListItemInfo,
|
||||
PartialBuilderConfig,
|
||||
Builder, BuilderConfig, BuilderConfigDiff, PartialBuilderConfig,
|
||||
},
|
||||
resource::{Resource, ResourceListItem},
|
||||
resource::Resource,
|
||||
toml::ResourceToml,
|
||||
update::ResourceTarget,
|
||||
},
|
||||
@@ -29,7 +25,6 @@ impl ResourceSync for Builder {
|
||||
type Info = ();
|
||||
type PartialConfig = PartialBuilderConfig;
|
||||
type ConfigDiff = BuilderConfigDiff;
|
||||
type ListItemInfo = BuilderListItemInfo;
|
||||
|
||||
fn display() -> &'static str {
|
||||
"builder"
|
||||
@@ -40,7 +35,7 @@ impl ResourceSync for Builder {
|
||||
}
|
||||
|
||||
fn name_to_resource(
|
||||
) -> &'static HashMap<String, ResourceListItem<Self::ListItemInfo>>
|
||||
) -> &'static HashMap<String, Resource<Self::Config, Self::Info>>
|
||||
{
|
||||
name_to_builder()
|
||||
}
|
||||
@@ -70,12 +65,6 @@ impl ResourceSync for Builder {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get(
|
||||
id: String,
|
||||
) -> anyhow::Result<Resource<Self::Config, Self::Info>> {
|
||||
monitor_client().read(GetBuilder { builder: id }).await
|
||||
}
|
||||
|
||||
async fn get_diff(
|
||||
mut original: Self::Config,
|
||||
update: Self::PartialConfig,
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use monitor_client::{
|
||||
api::{read::GetDeployment, write},
|
||||
api::write,
|
||||
entities::{
|
||||
deployment::{
|
||||
Deployment, DeploymentConfig, DeploymentConfigDiff,
|
||||
DeploymentImage, DeploymentListItemInfo,
|
||||
PartialDeploymentConfig,
|
||||
DeploymentImage, PartialDeploymentConfig,
|
||||
},
|
||||
resource::{Resource, ResourceListItem},
|
||||
resource::Resource,
|
||||
toml::ResourceToml,
|
||||
update::ResourceTarget,
|
||||
},
|
||||
@@ -27,7 +26,6 @@ impl ResourceSync for Deployment {
|
||||
type Info = ();
|
||||
type PartialConfig = PartialDeploymentConfig;
|
||||
type ConfigDiff = DeploymentConfigDiff;
|
||||
type ListItemInfo = DeploymentListItemInfo;
|
||||
|
||||
fn display() -> &'static str {
|
||||
"deployment"
|
||||
@@ -38,7 +36,7 @@ impl ResourceSync for Deployment {
|
||||
}
|
||||
|
||||
fn name_to_resource(
|
||||
) -> &'static HashMap<String, ResourceListItem<Self::ListItemInfo>>
|
||||
) -> &'static HashMap<String, Resource<Self::Config, Self::Info>>
|
||||
{
|
||||
name_to_deployment()
|
||||
}
|
||||
@@ -68,14 +66,6 @@ impl ResourceSync for Deployment {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get(
|
||||
id: String,
|
||||
) -> anyhow::Result<Resource<Self::Config, Self::Info>> {
|
||||
monitor_client()
|
||||
.read(GetDeployment { deployment: id })
|
||||
.await
|
||||
}
|
||||
|
||||
async fn get_diff(
|
||||
mut original: Self::Config,
|
||||
update: Self::PartialConfig,
|
||||
|
||||
@@ -4,9 +4,7 @@ use colored::Colorize;
|
||||
use monitor_client::{
|
||||
api::write::{UpdateDescription, UpdateTagsOnResource},
|
||||
entities::{
|
||||
resource::{Resource, ResourceListItem},
|
||||
toml::ResourceToml,
|
||||
update::ResourceTarget,
|
||||
resource::Resource, toml::ResourceToml, update::ResourceTarget,
|
||||
},
|
||||
};
|
||||
use partial_derive2::{Diff, FieldDiff, MaybeNone, PartialDiff};
|
||||
@@ -39,7 +37,7 @@ pub trait ResourceSync {
|
||||
+ Send
|
||||
+ PartialDiff<Self::PartialConfig, Self::ConfigDiff>
|
||||
+ 'static;
|
||||
type Info: Default;
|
||||
type Info: Default + 'static;
|
||||
type PartialConfig: std::fmt::Debug
|
||||
+ Clone
|
||||
+ Send
|
||||
@@ -48,14 +46,13 @@ pub trait ResourceSync {
|
||||
+ MaybeNone
|
||||
+ 'static;
|
||||
type ConfigDiff: Diff + MaybeNone;
|
||||
type ListItemInfo: 'static;
|
||||
|
||||
fn display() -> &'static str;
|
||||
|
||||
fn resource_target(id: String) -> ResourceTarget;
|
||||
|
||||
fn name_to_resource(
|
||||
) -> &'static HashMap<String, ResourceListItem<Self::ListItemInfo>>;
|
||||
) -> &'static HashMap<String, Resource<Self::Config, Self::Info>>;
|
||||
|
||||
/// Creates the resource and returns created id.
|
||||
async fn create(
|
||||
@@ -68,10 +65,6 @@ pub trait ResourceSync {
|
||||
resource: ResourceToml<Self::PartialConfig>,
|
||||
) -> anyhow::Result<()>;
|
||||
|
||||
async fn get(
|
||||
id: String,
|
||||
) -> anyhow::Result<Resource<Self::Config, Self::Info>>;
|
||||
|
||||
/// Diffs the declared toml (partial) against the full existing config.
|
||||
/// Removes all fields from toml (partial) that haven't changed.
|
||||
async fn get_diff(
|
||||
@@ -90,13 +83,11 @@ pub trait ResourceSync {
|
||||
let quiet = cli_args().quiet;
|
||||
|
||||
for mut resource in resources {
|
||||
match map.get(&resource.name).map(|s| s.id.clone()) {
|
||||
Some(id) => {
|
||||
// Get the full original config for the resource.
|
||||
let original = Self::get(id.clone()).await?;
|
||||
|
||||
match map.get(&resource.name) {
|
||||
Some(original) => {
|
||||
let diff =
|
||||
Self::get_diff(original.config, resource.config).await?;
|
||||
Self::get_diff(original.config.clone(), resource.config)
|
||||
.await?;
|
||||
|
||||
let original_tags = original
|
||||
.tags
|
||||
@@ -162,7 +153,7 @@ pub trait ResourceSync {
|
||||
resource.config = diff.into();
|
||||
|
||||
let update = ToUpdateItem {
|
||||
id,
|
||||
id: original.id.clone(),
|
||||
update_description: resource.description
|
||||
!= original.description,
|
||||
update_tags: resource.tags != original_tags,
|
||||
|
||||
@@ -3,14 +3,14 @@ use std::collections::HashMap;
|
||||
use monitor_client::{
|
||||
api::{
|
||||
execute::Execution,
|
||||
read::GetProcedure,
|
||||
write::{CreateProcedure, UpdateProcedure},
|
||||
},
|
||||
entities::{
|
||||
procedure::{
|
||||
PartialProcedureConfig, Procedure, ProcedureConfig, ProcedureConfigDiff, ProcedureListItemInfo
|
||||
PartialProcedureConfig, Procedure, ProcedureConfig,
|
||||
ProcedureConfigDiff,
|
||||
},
|
||||
resource::{Resource, ResourceListItem},
|
||||
resource::Resource,
|
||||
toml::ResourceToml,
|
||||
update::ResourceTarget,
|
||||
},
|
||||
@@ -33,7 +33,6 @@ impl ResourceSync for Procedure {
|
||||
type Info = ();
|
||||
type PartialConfig = PartialProcedureConfig;
|
||||
type ConfigDiff = ProcedureConfigDiff;
|
||||
type ListItemInfo = ProcedureListItemInfo;
|
||||
|
||||
fn display() -> &'static str {
|
||||
"procedure"
|
||||
@@ -44,7 +43,7 @@ impl ResourceSync for Procedure {
|
||||
}
|
||||
|
||||
fn name_to_resource(
|
||||
) -> &'static HashMap<String, ResourceListItem<Self::ListItemInfo>>
|
||||
) -> &'static HashMap<String, Resource<Self::Config, Self::Info>>
|
||||
{
|
||||
name_to_procedure()
|
||||
}
|
||||
@@ -157,12 +156,6 @@ impl ResourceSync for Procedure {
|
||||
warn!("procedure sync loop exited after max iterations");
|
||||
}
|
||||
|
||||
async fn get(
|
||||
id: String,
|
||||
) -> anyhow::Result<Resource<Self::Config, Self::Info>> {
|
||||
monitor_client().read(GetProcedure { procedure: id }).await
|
||||
}
|
||||
|
||||
async fn get_diff(
|
||||
mut original: Self::Config,
|
||||
update: Self::PartialConfig,
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use monitor_client::{
|
||||
api::{
|
||||
read::GetRepo,
|
||||
write::{CreateRepo, UpdateRepo},
|
||||
},
|
||||
api::write::{CreateRepo, UpdateRepo},
|
||||
entities::{
|
||||
repo::{
|
||||
PartialRepoConfig, Repo, RepoConfig, RepoConfigDiff, RepoInfo,
|
||||
RepoListItemInfo,
|
||||
},
|
||||
resource::{Resource, ResourceListItem},
|
||||
resource::Resource,
|
||||
toml::ResourceToml,
|
||||
update::ResourceTarget,
|
||||
},
|
||||
@@ -29,7 +25,6 @@ impl ResourceSync for Repo {
|
||||
type Info = RepoInfo;
|
||||
type PartialConfig = PartialRepoConfig;
|
||||
type ConfigDiff = RepoConfigDiff;
|
||||
type ListItemInfo = RepoListItemInfo;
|
||||
|
||||
fn display() -> &'static str {
|
||||
"repo"
|
||||
@@ -40,7 +35,7 @@ impl ResourceSync for Repo {
|
||||
}
|
||||
|
||||
fn name_to_resource(
|
||||
) -> &'static HashMap<String, ResourceListItem<Self::ListItemInfo>>
|
||||
) -> &'static HashMap<String, Resource<Self::Config, Self::Info>>
|
||||
{
|
||||
name_to_repo()
|
||||
}
|
||||
@@ -70,12 +65,6 @@ impl ResourceSync for Repo {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get(
|
||||
id: String,
|
||||
) -> anyhow::Result<Resource<Self::Config, Self::Info>> {
|
||||
monitor_client().read(GetRepo { repo: id }).await
|
||||
}
|
||||
|
||||
async fn get_diff(
|
||||
mut original: Self::Config,
|
||||
update: Self::PartialConfig,
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use monitor_client::{
|
||||
api::{
|
||||
read::GetServer,
|
||||
write::{CreateServer, UpdateServer},
|
||||
},
|
||||
api::write::{CreateServer, UpdateServer},
|
||||
entities::{
|
||||
resource::{Resource, ResourceListItem},
|
||||
resource::Resource,
|
||||
server::{
|
||||
PartialServerConfig, Server, ServerConfig, ServerConfigDiff,
|
||||
ServerListItemInfo,
|
||||
},
|
||||
toml::ResourceToml,
|
||||
update::ResourceTarget,
|
||||
@@ -26,7 +22,6 @@ impl ResourceSync for Server {
|
||||
type Info = ();
|
||||
type PartialConfig = PartialServerConfig;
|
||||
type ConfigDiff = ServerConfigDiff;
|
||||
type ListItemInfo = ServerListItemInfo;
|
||||
|
||||
fn display() -> &'static str {
|
||||
"server"
|
||||
@@ -37,7 +32,7 @@ impl ResourceSync for Server {
|
||||
}
|
||||
|
||||
fn name_to_resource(
|
||||
) -> &'static HashMap<String, ResourceListItem<Self::ListItemInfo>>
|
||||
) -> &'static HashMap<String, Resource<Self::Config, Self::Info>>
|
||||
{
|
||||
name_to_server()
|
||||
}
|
||||
@@ -67,12 +62,6 @@ impl ResourceSync for Server {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get(
|
||||
id: String,
|
||||
) -> anyhow::Result<Resource<Self::Config, Self::Info>> {
|
||||
monitor_client().read(GetServer { server: id }).await
|
||||
}
|
||||
|
||||
async fn get_diff(
|
||||
original: Self::Config,
|
||||
update: Self::PartialConfig,
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use monitor_client::{
|
||||
api::{
|
||||
read::GetServerTemplate,
|
||||
write::{CreateServerTemplate, UpdateServerTemplate},
|
||||
},
|
||||
api::write::{CreateServerTemplate, UpdateServerTemplate},
|
||||
entities::{
|
||||
resource::{Resource, ResourceListItem},
|
||||
resource::Resource,
|
||||
server_template::{
|
||||
PartialServerTemplateConfig, ServerTemplate, ServerTemplateConfig, ServerTemplateConfigDiff, ServerTemplateListItemInfo
|
||||
PartialServerTemplateConfig, ServerTemplate,
|
||||
ServerTemplateConfig, ServerTemplateConfigDiff,
|
||||
},
|
||||
toml::ResourceToml,
|
||||
update::ResourceTarget,
|
||||
@@ -25,7 +23,6 @@ impl ResourceSync for ServerTemplate {
|
||||
type Info = ();
|
||||
type PartialConfig = PartialServerTemplateConfig;
|
||||
type ConfigDiff = ServerTemplateConfigDiff;
|
||||
type ListItemInfo = ServerTemplateListItemInfo;
|
||||
|
||||
fn display() -> &'static str {
|
||||
"server template"
|
||||
@@ -36,7 +33,7 @@ impl ResourceSync for ServerTemplate {
|
||||
}
|
||||
|
||||
fn name_to_resource(
|
||||
) -> &'static HashMap<String, ResourceListItem<Self::ListItemInfo>>
|
||||
) -> &'static HashMap<String, Resource<Self::Config, Self::Info>>
|
||||
{
|
||||
name_to_server_template()
|
||||
}
|
||||
@@ -66,16 +63,6 @@ impl ResourceSync for ServerTemplate {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get(
|
||||
id: String,
|
||||
) -> anyhow::Result<Resource<Self::Config, Self::Info>> {
|
||||
monitor_client()
|
||||
.read(GetServerTemplate {
|
||||
server_template: id,
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
async fn get_diff(
|
||||
original: Self::Config,
|
||||
update: Self::PartialConfig,
|
||||
|
||||
Reference in New Issue
Block a user