Skip to content

Commit fcf9d2f

Browse files
committed
fix crds
1 parent c75a5ac commit fcf9d2f

1 file changed

Lines changed: 36 additions & 3 deletions

File tree

src/types/replica.rs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use std::collections::{BTreeMap, HashMap};
1+
use std::{
2+
borrow::Cow,
3+
collections::{BTreeMap, HashMap},
4+
};
25

36
use jiff::Span;
47
use k8s_openapi::{
@@ -9,7 +12,7 @@ use k8s_openapi::{
912
},
1013
};
1114
use kube::{CustomResource, ResourceExt as _};
12-
use schemars::JsonSchema;
15+
use schemars::{JsonSchema, Schema, SchemaGenerator, json_schema};
1316
use serde::{Deserialize, Serialize};
1417

1518
use crate::util::TimeSpan;
@@ -181,13 +184,43 @@ pub struct SnapshotFilter {
181184
pub description_pattern: Option<String>,
182185
}
183186

184-
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
187+
#[derive(Debug, Clone, Deserialize, Serialize)]
185188
#[serde(rename_all = "camelCase", tag = "target")]
186189
pub enum NotificationConfig {
187190
Webhook(WebhookConfig),
188191
GraphQL(GraphQLConfig),
189192
}
190193

194+
impl JsonSchema for NotificationConfig {
195+
fn inline_schema() -> bool {
196+
true
197+
}
198+
199+
fn schema_name() -> Cow<'static, str> {
200+
"NotificationConfig".into()
201+
}
202+
203+
fn json_schema(generator: &mut SchemaGenerator) -> Schema {
204+
let header_schema = generator.subschema_for::<Option<HashMap<String, HeaderValue>>>();
205+
json_schema!({
206+
"type": "object",
207+
"required": ["target", "url"],
208+
"properties": {
209+
"target": {
210+
"type": "string",
211+
"enum": ["webhook", "graphQL"]
212+
},
213+
"url": { "type": "string" },
214+
"method": { "type": "string" },
215+
"mutation": { "type": "string" },
216+
"variablesTemplate": { "type": "string" },
217+
"headers": header_schema,
218+
"includePassword": { "type": "boolean" }
219+
}
220+
})
221+
}
222+
}
223+
191224
impl NotificationConfig {
192225
pub fn name(&self) -> String {
193226
match self {

0 commit comments

Comments
 (0)