actually works in test now
This commit is contained in:
parent
5c22fc8823
commit
ca4e4d871a
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1161,6 +1161,7 @@ dependencies = [
|
|||||||
"harmony",
|
"harmony",
|
||||||
"harmony_cli",
|
"harmony_cli",
|
||||||
"harmony_macros",
|
"harmony_macros",
|
||||||
|
"serde_yaml",
|
||||||
"tokio",
|
"tokio",
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|||||||
@ -9,5 +9,6 @@ license.workspace = true
|
|||||||
harmony = { version = "0.1.0", path = "../../harmony" }
|
harmony = { version = "0.1.0", path = "../../harmony" }
|
||||||
harmony_cli = { version = "0.1.0", path = "../../harmony_cli" }
|
harmony_cli = { version = "0.1.0", path = "../../harmony_cli" }
|
||||||
harmony_macros = { version = "0.1.0", path = "../../harmony_macros" }
|
harmony_macros = { version = "0.1.0", path = "../../harmony_macros" }
|
||||||
|
serde_yaml.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
url.workspace = true
|
url.workspace = true
|
||||||
|
|||||||
@ -19,6 +19,7 @@ use harmony::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use harmony_macros::http_scheme;
|
use harmony_macros::http_scheme;
|
||||||
|
use serde_yaml::{Mapping, Value};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
@ -55,13 +56,24 @@ async fn main() {
|
|||||||
relabelings: vec![],
|
relabelings: vec![],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut selector = Mapping::new();
|
||||||
|
selector.insert(
|
||||||
|
Value::from("matchExpressions"),
|
||||||
|
serde_yaml::to_value(vec![Selector {
|
||||||
|
key: "monitored".to_string(),
|
||||||
|
operator: "In".to_string(),
|
||||||
|
values: vec!["test-service-1".to_string()],
|
||||||
|
}])
|
||||||
|
.expect("couldn't create mapping value"),
|
||||||
|
);
|
||||||
|
|
||||||
let service_monitor = ServiceMonitor {
|
let service_monitor = ServiceMonitor {
|
||||||
name: "test service monitor".to_string(),
|
name: "test-service-monitor".to_string(),
|
||||||
additional_labels: None,
|
additional_labels: None,
|
||||||
job_label: None,
|
job_label: None,
|
||||||
target_labels: vec![],
|
target_labels: vec![],
|
||||||
pod_target_labels: vec![],
|
pod_target_labels: vec![],
|
||||||
selector: None,
|
selector: selector,
|
||||||
match_labels: None,
|
match_labels: None,
|
||||||
namespace_selector: None,
|
namespace_selector: None,
|
||||||
endpoints: vec![service_monitor_endpoint],
|
endpoints: vec![service_monitor_endpoint],
|
||||||
|
|||||||
@ -143,6 +143,14 @@ pub struct ServiceMonitorEndpoint {
|
|||||||
pub relabelings: Vec<Mapping>,
|
pub relabelings: Vec<Mapping>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Selector {
|
||||||
|
pub key: String,
|
||||||
|
pub operator: String,
|
||||||
|
pub values: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct ServiceMonitor {
|
pub struct ServiceMonitor {
|
||||||
@ -170,7 +178,7 @@ pub struct ServiceMonitor {
|
|||||||
// values:
|
// values:
|
||||||
// - example-service-1
|
// - example-service-1
|
||||||
// - example-service-2
|
// - example-service-2
|
||||||
pub selector: Option<Mapping>,
|
pub selector: Mapping,
|
||||||
|
|
||||||
// # label selector for services
|
// # label selector for services
|
||||||
pub match_labels: Option<Mapping>,
|
pub match_labels: Option<Mapping>,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user