Update repo-add command to raise errors with some options in OSM repos
Change-Id: Ibb2387d29eac9fd6c805fc3a4ebb7c99d9288f42
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
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 @@
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 @@
)
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):