The method _exec_inspect_command is only obtaining the repo name
where an URL was passed: this will allow to scale KDUs based on local
Helm Charts; did also some refactor work: the _split_repo method now
returns both the Chart's name and Repo's name, in order to avoid using
similar blocks of code in other portions (with this, made some changes
to the _exec_inspect_command and _find_repo methods, to use this method,
instead of a similar block of code); added some information to the
description of some changed methods; other small changes.
Change-Id: I7302623ad2bfeef9be3b7c17376cab67f5eda630
Signed-off-by: Pedro Escaleira <escaleira@av.it.pt>
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
return []
def _get_inspect_command(
return []
def _get_inspect_command(
- self, inspect_command: str, kdu_model: str, repo_str: str, version: str
+ self, show_command: str, kdu_model: str, repo_str: str, version: str
):
"""Generates the command to obtain the information about an Helm Chart package
(´helm show ...´ command)
):
"""Generates the command to obtain the information about an Helm Chart package
(´helm show ...´ command)
"""
inspect_command = "{} show {} {}{} {}".format(
"""
inspect_command = "{} show {} {}{} {}".format(
- self._helm_command, inspect_command, kdu_model, repo_str, version
+ self._helm_command, show_command, kdu_model, repo_str, version
# version
kdu_model, version = self._split_version(kdu_model)
# version
kdu_model, version = self._split_version(kdu_model)
- repo = self._split_repo(kdu_model)
+ _, repo = self._split_repo(kdu_model)
if repo:
await self.repo_update(cluster_id, repo)
if repo:
await self.repo_update(cluster_id, repo)
# version
kdu_model, version = self._split_version(kdu_model)
# version
kdu_model, version = self._split_version(kdu_model)
- repo = self._split_repo(kdu_model)
+ _, repo = self._split_repo(kdu_model)
if repo:
await self.repo_update(cluster_uuid, repo)
if repo:
await self.repo_update(cluster_uuid, repo)
if repo_url:
repo_str = " --repo {}".format(repo_url)
if repo_url:
repo_str = " --repo {}".format(repo_url)
- idx = kdu_model.find("/")
- if idx >= 0:
- idx += 1
- kdu_model = kdu_model[idx:]
+ # Obtain the Chart's name and store it in the var kdu_model
+ kdu_model, _ = self._split_repo(kdu_model=kdu_model)
kdu_model, version = self._split_version(kdu_model)
if version:
kdu_model, version = self._split_version(kdu_model)
if version:
version_str = ""
full_command = self._get_inspect_command(
version_str = ""
full_command = self._get_inspect_command(
- inspect_command, kdu_model, repo_str, version_str
+ show_command=inspect_command,
+ kdu_model=kdu_model,
+ repo_str=repo_str,
+ version=version_str,
- output, _rc = await self._local_async_exec(command=full_command)
+ output, _ = await self._local_async_exec(command=full_command)
kdu_model = parts[0]
return kdu_model, version
kdu_model = parts[0]
return kdu_model, version
- def _split_repo(self, kdu_model: str) -> str:
+ def _split_repo(self, kdu_model: str) -> (str, str):
+ """Obtain the Helm Chart's repository and Chart's names from the KDU model
+
+ Args:
+ kdu_model (str): Associated KDU model
+
+ Returns:
+ (str, str): Tuple with the Chart name in index 0, and the repo name
+ in index 2; if there was a problem finding them, return None
+ for both
+ """
+
+ chart_name = None
idx = kdu_model.find("/")
if idx >= 0:
idx = kdu_model.find("/")
if idx >= 0:
+ chart_name = kdu_model[idx + 1 :]
repo_name = kdu_model[:idx]
repo_name = kdu_model[:idx]
+
+ return chart_name, repo_name
async def _find_repo(self, kdu_model: str, cluster_uuid: str) -> str:
"""Obtain the Helm repository for an Helm Chart
async def _find_repo(self, kdu_model: str, cluster_uuid: str) -> str:
"""Obtain the Helm repository for an Helm Chart
str: the repository URL; if Helm Chart is a local one, the function returns None
"""
str: the repository URL; if Helm Chart is a local one, the function returns None
"""
+ _, repo_name = self._split_repo(kdu_model=kdu_model)
+
- idx = kdu_model.find("/")
- if idx >= 0:
- repo_name = kdu_model[:idx]
# Find repository link
local_repo_list = await self.repo_list(cluster_uuid)
for repo in local_repo_list:
# Find repository link
local_repo_list = await self.repo_list(cluster_uuid)
for repo in local_repo_list:
- repo_url = repo["url"] if repo["name"] == repo_name else None
+ if repo["name"] == repo_name:
+ repo_url = repo["url"]
+ break # it is not necessary to continue the loop if the repo link was found...
+