From 4769418e5c713ef50f9beeec7b15e6c4df2e243f Mon Sep 17 00:00:00 2001 From: Christoph Herzog Date: Thu, 6 Jun 2024 03:05:09 +0200 Subject: [PATCH 1/2] feat(configs): Add headers and max_age to InstaBoot capability --- lib/config/src/app/http.rs | 13 +++++++++++++ lib/config/src/app/mod.rs | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/config/src/app/http.rs b/lib/config/src/app/http.rs index 15e85ade592..b3d9adc4b9c 100644 --- a/lib/config/src/app/http.rs +++ b/lib/config/src/app/http.rs @@ -12,6 +12,10 @@ pub struct HttpRequest { #[serde(skip_serializing_if = "Option::is_none")] pub method: Option, + /// HTTP headers added to the request. + #[serde(skip_serializing_if = "Option::is_none")] + pub headers: Option>, + /// Request body as a string. #[serde(skip_serializing_if = "Option::is_none")] pub body: Option, @@ -26,6 +30,15 @@ pub struct HttpRequest { pub expect: Option, } +/// Definition for an HTTP header. +#[derive( + schemars::JsonSchema, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Debug, +)] +pub struct HttpHeader { + pub name: String, + pub value: String, +} + /// Validation checks for an [`HttpRequest`]. #[derive( schemars::JsonSchema, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Debug, diff --git a/lib/config/src/app/mod.rs b/lib/config/src/app/mod.rs index 5052e655bfc..33605569ddc 100644 --- a/lib/config/src/app/mod.rs +++ b/lib/config/src/app/mod.rs @@ -234,7 +234,17 @@ pub struct AppConfigCapabilityInstaBootV1 { /// /// NOTE: if no requests are configured, then a single HTTP /// request to '/' will be performed instead. + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub requests: Vec, + + /// Maximum age of snapshots. + /// + /// Format: 5m, 1h, 2d, ... + /// + /// After the specified time new snapshots will be created, and the old + /// ones discarded. + #[serde(skip_serializing_if = "Option::is_none")] + pub max_age: Option, } #[cfg(test)] From a7161fd1b5089675d1cd52619eb44cc4b940f5d6 Mon Sep 17 00:00:00 2001 From: Christoph Herzog Date: Thu, 6 Jun 2024 15:35:53 +0200 Subject: [PATCH 2/2] Add forwards compatibility in the config map --- lib/config/src/app/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/config/src/app/mod.rs b/lib/config/src/app/mod.rs index 33605569ddc..4298622ce8f 100644 --- a/lib/config/src/app/mod.rs +++ b/lib/config/src/app/mod.rs @@ -195,6 +195,13 @@ pub struct AppConfigCapabilityMapV1 { /// Enables app bootstrapping with startup snapshots. #[serde(skip_serializing_if = "Option::is_none")] pub instaboot: Option, + + /// Additional unknown capabilities. + /// + /// This provides a small bit of forwards compatibility for newly added + /// capabilities. + #[serde(flatten)] + pub other: HashMap, } /// Memory capability settings.