From a6b91f476601b5d88725d5df94e0de71a8148202 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Thu, 27 Nov 2025 17:46:45 +0100 Subject: [PATCH] Update repo-add command to raise errors with some options in OSM repos Change-Id: Ibb2387d29eac9fd6c805fc3a4ebb7c99d9288f42 Signed-off-by: garciadeblas --- osmclient/cli_commands/repo.py | 9 +++++++++ osmclient/sol005/repo.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/osmclient/cli_commands/repo.py b/osmclient/cli_commands/repo.py index 3a80735..c4d5016 100755 --- a/osmclient/cli_commands/repo.py +++ b/osmclient/cli_commands/repo.py @@ -61,10 +61,19 @@ def repo_add(ctx, **kwargs): URI: URI of the repo """ kwargs = {k: v for k, v in kwargs.items() if v is not None} + print(kwargs) repo = kwargs repo["url"] = repo.pop("uri") if repo["url"].startswith("oci://"): repo["oci"] = True + # Some options are incompatible with OSM repos + if repo["type"] == "osm": + if "username" in repo or "password" in repo or "ca_file" in repo: + raise ClientException( + "username, password and ca_file options are not valid for OSM repositories" + ) + if "oci" in repo: + repo.pop("oci") if "ca_file" in kwargs: try: with open(kwargs["ca_file"], "r") as ca_cert: diff --git a/osmclient/sol005/repo.py b/osmclient/sol005/repo.py index 00b95eb..47c240e 100644 --- a/osmclient/sol005/repo.py +++ b/osmclient/sol005/repo.py @@ -34,7 +34,7 @@ class Repo(object): ) def check_oci(self, repo): - if repo["oci"] and repo["type"] != "helm-chart": + if repo.get("oci", False) and repo["type"] != "helm-chart": raise ClientException("OCI can only be enabled in helm-chart repos") def create(self, name, repo): -- 2.25.1