From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.ebner@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id CA45DA216D
 for <pve-devel@lists.proxmox.com>; Fri, 16 Jun 2023 15:43:09 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id ABCA6341A5
 for <pve-devel@lists.proxmox.com>; Fri, 16 Jun 2023 15:42:39 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS
 for <pve-devel@lists.proxmox.com>; Fri, 16 Jun 2023 15:42:39 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id DA9DA45B71
 for <pve-devel@lists.proxmox.com>; Fri, 16 Jun 2023 15:42:38 +0200 (CEST)
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Fri, 16 Jun 2023 15:42:35 +0200
Message-Id: <20230616134235.94438-1-f.ebner@proxmox.com>
X-Mailer: git-send-email 2.39.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.047 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
 T_SCC_BODY_TEXT_LINE    -0.01 -
Subject: [pve-devel] [PATCH v2 widget-toolkit] apt repositories: add
 production ready warnings for Ceph repositories
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Fri, 16 Jun 2023 13:43:09 -0000

Could've been done for the test repository already, but now that there
is a split between no-subscription and enterprise it becomes even more
relevant.

Reported-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

Changes in v2:
    * rebase on current master.

 src/node/APTRepositories.js | 48 ++++++++++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 9 deletions(-)

diff --git a/src/node/APTRepositories.js b/src/node/APTRepositories.js
index 016118e..53af2c7 100644
--- a/src/node/APTRepositories.js
+++ b/src/node/APTRepositories.js
@@ -460,6 +460,11 @@ Ext.define('Proxmox.node.APTRepositories', {
 	    let enterprise = vm.get('enterpriseRepo');
 	    let nosubscription = vm.get('noSubscriptionRepo');
 	    let test = vm.get('testRepo');
+	    let cephRepos = {
+		enterprise: vm.get('cephEnterpriseRepo'),
+		nosubscription: vm.get('cephNoSubscriptionRepo'),
+		test: vm.get('cephTestRepo'),
+	    };
 	    let wrongSuites = vm.get('suitesWarning');
 	    let mixedSuites = vm.get('mixedSuites');
 
@@ -483,17 +488,33 @@ Ext.define('Proxmox.node.APTRepositories', {
 		addWarn(gettext('Detected mixed suites before upgrade'));
 	    }
 
-	    if (!activeSubscription && enterprise) {
-		addWarn(gettext('The enterprise repository is enabled, but there is no active subscription!'));
-	    }
+	    let productionReadyCheck = (repos, type, noSubAlternateName) => {
+		if (!activeSubscription && repos.enterprise) {
+		    addWarn(Ext.String.format(
+			gettext('The {0}enterprise repository is enabled, but there is no active subscription!'),
+			type,
+		    ));
+		}
 
-	    if (nosubscription) {
-		addWarn(gettext('The no-subscription repository is not recommended for production use!'));
-	    }
+		if (repos.nosubscription) {
+		    addWarn(Ext.String.format(
+			gettext('The {0}no-subscription{1} repository is not recommended for production use!'),
+			type,
+			noSubAlternateName,
+		    ));
+		}
 
-	    if (test) {
-		addWarn(gettext('The test repository may pull in unstable updates and is not recommended for production use!'));
-	    }
+		if (repos.test) {
+		    addWarn(Ext.String.format(
+			gettext('The {0}test repository may pull in unstable updates and is not recommended for production use!'),
+			type,
+		    ));
+		}
+	    };
+
+	    productionReadyCheck({ enterprise, nosubscription, test }, '', '');
+	    // TODO drop alternate 'main' name when no longer relevant
+	    productionReadyCheck(cephRepos, 'Ceph ', '/main');
 
 	    if (errors.length > 0) {
 		text = gettext('Fatal parsing error for at least one repository');
@@ -518,6 +539,9 @@ Ext.define('Proxmox.node.APTRepositories', {
 	    noSubscriptionRepo: '',
 	    enterpriseRepo: '',
 	    testRepo: '',
+	    cephEnterpriseRepo: '',
+	    cephNoSubscriptionRepo: '',
+	    cephTestRepo: '',
 	    selectionenabled: false,
 	    state: {},
 	},
@@ -627,6 +651,12 @@ Ext.define('Proxmox.node.APTRepositories', {
 		vm.set('noSubscriptionRepo', status);
 	    } else if (handle === 'test') {
 		vm.set('testRepo', status);
+	    } else if (handle.match(/^ceph-[a-zA-Z]+-enterprise$/)) {
+		vm.set('cephEnterpriseRepo', status);
+	    } else if (handle.match(/^ceph-[a-zA-Z]+-no-subscription$/)) {
+		vm.set('cephNoSubscriptionRepo', status);
+	    } else if (handle.match(/^ceph-[a-zA-Z]+-test$/)) {
+		vm.set('cephTestRepo', status);
 	    }
 	    me.getController().updateState();
 
-- 
2.39.2