Skip to content

Commit

Permalink
helm: add pass-credentials key (#282)
Browse files Browse the repository at this point in the history
helm: add pass-credentials key

SUMMARY
In helm version v3.6.1 when downloading charts from password protected repositories that served from a different domain than the repository, need to use --pass-credentials key.
Add possibility to use the pass-credentials key in helm_repository.py
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
helm_repository

Reviewed-by: None <None>
Reviewed-by: Abhijeet Kasurde <None>
Reviewed-by: Mike Graves <[email protected]>
Reviewed-by: None <None>
  • Loading branch information
nkromano authored Nov 19, 2021
1 parent 39b6c43 commit ba5cb30
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- helm_repository - add support for pass-credentials cli parameter (https://github.com/ansible-collections/kubernetes.core/pull/282).
26 changes: 24 additions & 2 deletions plugins/modules/helm_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@
default: present
aliases: [ state ]
type: str
pass_credentials:
description:
- Pass credentials to all domains.
required: false
default: false
type: bool
version_added: 2.3.0
"""

EXAMPLES = r"""
Expand Down Expand Up @@ -157,14 +164,22 @@ def get_repository_status(module, command, repository_name):

# Install repository
def install_repository(
command, repository_name, repository_url, repository_username, repository_password
command,
repository_name,
repository_url,
repository_username,
repository_password,
pass_credentials,
):
install_command = command + " repo add " + repository_name + " " + repository_url

if repository_username is not None and repository_password is not None:
install_command += " --username=" + repository_username
install_command += " --password=" + repository_password

if pass_credentials:
install_command += " --pass-credentials"

return install_command


Expand All @@ -188,6 +203,7 @@ def main():
repo_state=dict(
default="present", choices=["present", "absent"], aliases=["state"]
),
pass_credentials=dict(type="bool", default=False),
),
required_together=[["repo_username", "repo_password"]],
required_if=[("repo_state", "present", ["repo_url"])],
Expand All @@ -205,6 +221,7 @@ def main():
repo_username = module.params.get("repo_username")
repo_password = module.params.get("repo_password")
repo_state = module.params.get("repo_state")
pass_credentials = module.params.get("pass_credentials")

if bin_path is not None:
helm_cmd = bin_path
Expand All @@ -219,7 +236,12 @@ def main():
elif repo_state == "present":
if repository_status is None:
helm_cmd = install_repository(
helm_cmd, repo_name, repo_url, repo_username, repo_password
helm_cmd,
repo_name,
repo_url,
repo_username,
repo_password,
pass_credentials,
)
changed = True
elif repository_status["url"] != repo_url:
Expand Down

0 comments on commit ba5cb30

Please sign in to comment.