Skip to content

Commit

Permalink
Add the force_update arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Mor Cohen committed Aug 22, 2022
1 parent c4c12ca commit dfb743f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion plugins/modules/helm_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@
type: path
aliases: [ ssl_ca_cert ]
version_added: "2.3.0"
force_update:
description:
- Whether or not to replace (overwrite) the repo if it already exists.
type: bool
aliases: [ force ]
default: False
version_added: "2.3.3"
"""

EXAMPLES = r"""
Expand Down Expand Up @@ -195,6 +202,7 @@ def install_repository(
repository_username,
repository_password,
pass_credentials,
force_update
):
install_command = command + " repo add " + repository_name + " " + repository_url

Expand All @@ -205,6 +213,9 @@ def install_repository(
if pass_credentials:
install_command += " --pass-credentials"

if force_update:
install_command += " --force-update"

return install_command


Expand Down Expand Up @@ -242,6 +253,11 @@ def main():
aliases=["verify_ssl"],
fallback=(env_fallback, ["K8S_AUTH_VERIFY_SSL"]),
),
force_update=dict(
type="bool",
default=False,
aliases=["force"],
),
api_key=dict(
type="str", no_log=True, fallback=(env_fallback, ["K8S_AUTH_API_KEY"])
),
Expand All @@ -263,6 +279,7 @@ def main():
repo_password = module.params.get("repo_password")
repo_state = module.params.get("repo_state")
pass_credentials = module.params.get("pass_credentials")
force_update = module.params.get("force_update")

if bin_path is not None:
helm_cmd = bin_path
Expand All @@ -275,14 +292,15 @@ def main():
helm_cmd = delete_repository(helm_cmd, repo_name)
changed = True
elif repo_state == "present":
if repository_status is None:
if repository_status is None or force_update:
helm_cmd = install_repository(
helm_cmd,
repo_name,
repo_url,
repo_username,
repo_password,
pass_credentials,
force_update
)
changed = True
elif repository_status["url"] != repo_url:
Expand Down

0 comments on commit dfb743f

Please sign in to comment.