typo in selector implementation

This commit is contained in:
tahahawa 2025-06-25 16:43:10 -04:00
parent a1ad610198
commit 8dee6a7162
2 changed files with 18 additions and 18 deletions

View File

@ -21,7 +21,6 @@ use harmony::{
};
use harmony_macros::http_scheme;
use serde_yaml::{Mapping, Value};
#[tokio::main]
async fn main() {
@ -58,24 +57,20 @@ async fn main() {
relabelings: vec![],
};
let mut selector = HashMap::new();
selector.insert(
"matchExpressions".to_string(),
vec![Selector {
key: "monitored".to_string(),
operator: "In".to_string(),
values: vec!["test-service-1".to_string()],
}],
);
let service_monitor = ServiceMonitor {
name: "test-service-monitor".to_string(),
additional_labels: None,
job_label: None,
target_labels: vec![],
pod_target_labels: vec![],
selector: selector,
match_labels: None,
selector: Selector {
match_labels: None,
match_expressions: vec![MatchExpression {
key: "test".to_string(),
operator: "In".to_string(),
values: vec!["test-service".to_string()],
}],
},
namespace_selector: None,
endpoints: vec![service_monitor_endpoint],
fallback_scrape_protocol: None,

View File

@ -145,12 +145,20 @@ pub struct ServiceMonitorEndpoint {
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Selector {
pub struct MatchExpression {
pub key: String,
pub operator: String,
pub values: Vec<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Selector {
// # label selector for services
pub match_labels: Option<HashMap<String, String>>,
pub match_expressions: Vec<MatchExpression>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ServiceMonitor {
@ -178,10 +186,7 @@ pub struct ServiceMonitor {
// values:
// - example-service-1
// - example-service-2
pub selector: HashMap<String, Vec<Selector>>,
// # label selector for services
pub match_labels: Option<Mapping>,
pub selector: Selector,
// # Namespaces from which services are selected
// # Match any namespace