From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id CD2801FF168 for ; Tue, 12 Nov 2024 14:19:04 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 23A2D299A5; Tue, 12 Nov 2024 14:19:04 +0100 (CET) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Tue, 12 Nov 2024 14:18:14 +0100 Message-ID: <20241112131815.670475-2-c.heiss@proxmox.com> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.030 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH installer] post-hook: add `$version` field describing document schema version X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" 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 ".", 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 Signed-off-by: Christoph Heiss --- 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