-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathconfig.rs
130 lines (106 loc) · 4.04 KB
/
config.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
use kuma_client::deserialize::DeserializeVecLenient;
use serde::{Deserialize, Serialize};
use serde_alias::serde_alias;
use serde_inline_default::serde_inline_default;
use serde_with::{formats::SemicolonSeparator, serde_as, PickFirst, StringWithSeparator};
use std::collections::HashMap;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum DockerSource {
#[serde(alias = "container")]
Containers,
#[serde(alias = "service")]
Services,
#[serde(alias = "both")]
Both,
}
#[serde_alias(ScreamingSnakeCase)]
#[serde_inline_default]
#[serde_as]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct DockerConfig {
/// Whether docker integration should be enabled or not.
#[serde_inline_default(true)]
pub enabled: bool,
/// Path to the Docker socket. If not set, the DOCKER_HOST will be used.
#[serde_inline_default(None)]
pub socket_path: Option<String>,
/// List of Docker hosts. If set this will override socker_path. Use a semicolon separated string when setting using an env variable.
#[serde_as(
as = "Option<PickFirst<(DeserializeVecLenient<String>, StringWithSeparator::<SemicolonSeparator, String>)>>"
)]
#[serde(default)]
pub hosts: Option<Vec<String>>,
/// Whether monitors should be created from container or service labels (or both).
#[serde_inline_default(DockerSource::Containers)]
pub source: DockerSource,
/// Prefix used when scanning for container labels.
#[serde_inline_default("kuma".to_owned())]
pub label_prefix: String,
}
#[serde_alias(ScreamingSnakeCase)]
#[serde_inline_default]
#[serde_as]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct KubernetesConfig {
/// Whether kubernetes integration should be enabled or not.
#[serde_inline_default(false)]
pub enabled: bool,
}
#[serde_alias(ScreamingSnakeCase)]
#[serde_inline_default]
#[serde_as]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct FilesConfig {
/// Whether files source should be enabled or not.
#[serde_inline_default(true)]
pub enabled: bool,
/// Whether the files source should follow symlinks or not.
#[serde_inline_default(false)]
pub follow_symlinks: bool,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum DeleteBehavior {
#[serde(alias = "delete")]
Delete,
#[serde(alias = "keep")]
Keep,
}
#[serde_alias(ScreamingSnakeCase)]
#[serde_inline_default]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Config {
pub kuma: kuma_client::Config,
pub docker: DockerConfig,
pub kubernetes: KubernetesConfig,
pub files: FilesConfig,
/// The interval in between syncs.
#[serde_inline_default(5.0)]
pub sync_interval: f64,
/// The path to the folder in which AutoKuma will search for static Monitor definitions.
#[serde_inline_default(None)]
pub static_monitors: Option<String>,
/// Specify what to do when a monitor with given autokuma id is not found anymore.
#[serde_inline_default(DeleteBehavior::Delete)]
pub on_delete: DeleteBehavior,
/// The name of the AutoKuma tag, used to track managed containers
#[serde_inline_default("AutoKuma".to_owned())]
pub tag_name: String,
/// The color of the AutoKuma tag
#[serde_inline_default("#42C0FB".to_owned())]
pub tag_color: String,
/// Where to store application data
#[serde_inline_default(None)]
pub data_path: Option<String>,
/// Default settings applied to all generated Monitors.
#[serde_inline_default("".to_owned())]
pub default_settings: String,
/// Default settings applied to all generated Monitors.
#[serde_inline_default(HashMap::new())]
pub snippets: HashMap<String, String>,
/// A directory where log files should be stored
#[serde_inline_default(None)]
pub log_dir: Option<String>,
/// Allow access to all env variables in templates, by default only variables starting with AUTOKUMA__ENV__ can be accessed.
#[serde_inline_default(false)]
pub insecure_env_access: bool,
}