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 support for history-max parameter #164

Merged
merged 5 commits into from
Jul 15, 2021
Merged
Changes from 1 commit
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
16 changes: 12 additions & 4 deletions plugins/modules/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@
type: bool
default: False
version_added: "1.2.0"
history_max:
description:
- Limit the maximum number of revisions saved per release.
type: int
default: False
vvanouytsel marked this conversation as resolved.
Show resolved Hide resolved
version_added: "2.1.2"
vvanouytsel marked this conversation as resolved.
Show resolved Hide resolved
extends_documentation_fragment:
- kubernetes.core.helm_common_options
'''
Expand Down Expand Up @@ -357,7 +363,7 @@ def fetch_chart_info(module, command, chart_ref):


def deploy(command, release_name, release_values, chart_name, wait,
wait_timeout, disable_hook, force, values_files, atomic=False,
wait_timeout, disable_hook, force, values_files, history_max, atomic=False,
create_namespace=False, replace=False, skip_crds=False):
"""
Install/upgrade/rollback release chart
Expand Down Expand Up @@ -404,7 +410,7 @@ def deploy(command, release_name, release_values, chart_name, wait,
if skip_crds:
deploy_command += " --skip-crds"

deploy_command += " " + release_name + " " + chart_name
deploy_command += " --history-max=" + str(history_max) + " " + release_name + " " + chart_name
vvanouytsel marked this conversation as resolved.
Show resolved Hide resolved

return deploy_command

Expand Down Expand Up @@ -532,6 +538,7 @@ def main():
create_namespace=dict(type='bool', default=False),
replace=dict(type='bool', default=False),
skip_crds=dict(type='bool', default=False),
history_max=dict(type='int', default=10),

# Generic auth key
host=dict(type='str', fallback=(env_fallback, ['K8S_AUTH_HOST'])),
Expand Down Expand Up @@ -575,6 +582,7 @@ def main():
create_namespace = module.params.get('create_namespace')
replace = module.params.get('replace')
skip_crds = module.params.get('skip_crds')
history_max = module.params.get('history_max')

if bin_path is not None:
helm_cmd_common = bin_path
Expand Down Expand Up @@ -610,7 +618,7 @@ def main():
helm_cmd = deploy(helm_cmd, release_name, release_values, chart_ref, wait, wait_timeout,
disable_hook, False, values_files=values_files, atomic=atomic,
create_namespace=create_namespace, replace=replace,
skip_crds=skip_crds)
skip_crds=skip_crds, history_max=history_max)
changed = True

else:
Expand All @@ -627,7 +635,7 @@ def main():
helm_cmd = deploy(helm_cmd, release_name, release_values, chart_ref, wait, wait_timeout,
disable_hook, force, values_files=values_files, atomic=atomic,
create_namespace=create_namespace, replace=replace,
skip_crds=skip_crds)
skip_crds=skip_crds, history_max=history_max)
changed = True

if module.check_mode:
Expand Down