From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer] post-hook: add `$version` field describing document schema version
Date: Tue, 12 Nov 2024 14:18:14 +0100 [thread overview]
Message-ID: <20241112131815.670475-2-c.heiss@proxmox.com> (raw)
This adds a metadata-field `$version` to the post-hook json, indicating
which schema version (and thus structure) this document uses.
The field is of format "<major>.<minor>", following the semantic
versioning meaning for both the major and minor number. A patch version
is left out here, as it doesn't make much sense in this context.
This was suggested by Thomas when originally introducing the post-hook
functionality in [0].
[0] https://lore.proxmox.com/pve-devel/00019f8d-e4f2-420e-892a-b89e8b886748@proxmox.com/
Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
proxmox-post-hook/src/main.rs | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/proxmox-post-hook/src/main.rs b/proxmox-post-hook/src/main.rs
index 8558da2..fb51ba9 100644
--- a/proxmox-post-hook/src/main.rs
+++ b/proxmox-post-hook/src/main.rs
@@ -133,6 +133,17 @@ struct CpuInfo {
#[derive(Serialize)]
#[serde(rename_all = "kebab-case")]
struct PostHookInfo {
+ /// major.minor version describing the schema version of this document, in a semanticy-version
+ /// way.
+ ///
+ /// major: Incremented for incompatible/breaking API changes, e.g. removing an existing
+ /// field.
+ /// minor: Incremented when adding functionality in a backwards-compatible matter, e.g.
+ /// adding a new field.
+ // This field is prefixed by `$` on purpose, to indicate that it is document metadata and not
+ // part of the actual content itself. (E.g. JSON Schema uses a similar naming scheme)
+ #[serde(rename = "$version")]
+ schema_version: String,
/// major.minor version of Debian as installed, retrieved from /etc/debian_version
debian_version: String,
/// PVE/PMG/PBS version as reported by `pveversion`, `pmgversion` or
@@ -166,6 +177,8 @@ struct PostHookInfo {
const SIZE_GIB: usize = 1024 * 1024 * 1024;
impl PostHookInfo {
+ const SCHEMA_VERSION: &str = "1.0";
+
/// Gathers all needed information about the newly installed system for sending
/// it to a specified server.
///
@@ -215,6 +228,7 @@ impl PostHookInfo {
};
Ok(Self {
+ schema_version: Self::SCHEMA_VERSION.to_owned(),
debian_version: read_file("/etc/debian_version")?,
product: Self::gather_product_info(&setup_info, &run_cmd)?,
iso: setup_info.iso_info.clone(),
--
2.47.0
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next reply other threads:[~2024-11-12 13:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 13:18 Christoph Heiss [this message]
2024-11-12 13:44 ` Thomas Lamprecht
2024-11-12 14:06 ` Christoph Heiss
2024-11-12 14:29 ` Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241112131815.670475-2-c.heiss@proxmox.com \
--to=c.heiss@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox