Update repo-add command to raise errors with some options in OSM repos 59/15559/1
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 27 Nov 2025 16:46:45 +0000 (17:46 +0100)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 27 Nov 2025 16:55:09 +0000 (17:55 +0100)
Change-Id: Ibb2387d29eac9fd6c805fc3a4ebb7c99d9288f42
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osmclient/cli_commands/repo.py
osmclient/sol005/repo.py

index 3a80735..c4d5016 100755 (executable)
@@ -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:
index 00b95eb..47c240e 100644 (file)
@@ -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):