Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helm: add pass-credentials key #282

Merged
merged 7 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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