actually works in test now

This commit is contained in:
tahahawa 2025-06-25 16:33:43 -04:00
parent 5c22fc8823
commit ca4e4d871a
4 changed files with 25 additions and 3 deletions

1
Cargo.lock generated
View File

@ -1161,6 +1161,7 @@ dependencies = [
"harmony",
"harmony_cli",
"harmony_macros",
"serde_yaml",
"tokio",
"url",
]

View File

@ -9,5 +9,6 @@ license.workspace = true
harmony = { version = "0.1.0", path = "../../harmony" }
harmony_cli = { version = "0.1.0", path = "../../harmony_cli" }
harmony_macros = { version = "0.1.0", path = "../../harmony_macros" }
serde_yaml.workspace = true
tokio.workspace = true
url.workspace = true

View File

@ -19,6 +19,7 @@ use harmony::{
};
use harmony_macros::http_scheme;
use serde_yaml::{Mapping, Value};
#[tokio::main]
async fn main() {
@ -55,13 +56,24 @@ async fn main() {
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 {
name: "test service monitor".to_string(),
name: "test-service-monitor".to_string(),
additional_labels: None,
job_label: None,
target_labels: vec![],
pod_target_labels: vec![],
selector: None,
selector: selector,
match_labels: None,
namespace_selector: None,
endpoints: vec![service_monitor_endpoint],

View File

@ -143,6 +143,14 @@ pub struct ServiceMonitorEndpoint {
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)]
#[serde(rename_all = "camelCase")]
pub struct ServiceMonitor {
@ -170,7 +178,7 @@ pub struct ServiceMonitor {
// values:
// - example-service-1
// - example-service-2
pub selector: Option<Mapping>,
pub selector: Mapping,
// # label selector for services
pub match_labels: Option<Mapping>,