mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-03-26 21:33:02 +00:00
helm: add support for history-max parameter (#164)
* helm: add support for history-max parameter The --history-max parameter allows the user to set a maximum amount of revisions per release to be kept in the history. By default helm keeps 10 revisions per release, which means that 10 secrets will be kept per release. * helm: remove default for history_max When the history_max option is not set, the module will not pass '--history-max' to the CLI command. This ensures that the defaults of the helm CLI will alwasy be used. * helm: remove whitespace trail * helm: add mutually exclusive logic The 'history_max' parameter is not available when using the 'helm install' command, it is only implemented for 'helm ugprade'. The 'replace' option uses the 'install' parameter, thus 'replace' and 'history_max' have to be mutually exclusive. * helm: formatting changes
This commit is contained in:
committed by
GitHub
parent
2e98493010
commit
a0a6d7121f
2
changelogs/fragments/164-add-history-max.yaml
Normal file
2
changelogs/fragments/164-add-history-max.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
minor_changes:
|
||||
- helm - add support for history_max cli parameter (https://github.com/ansible-collections/kubernetes.core/pull/164).
|
||||
@@ -130,6 +130,7 @@ options:
|
||||
description:
|
||||
- Reuse the given name, only if that name is a deleted release which remains in the history.
|
||||
- This is unsafe in production environment.
|
||||
- mutually exclusive with with C(history_max).
|
||||
type: bool
|
||||
default: False
|
||||
version_added: "1.11.0"
|
||||
@@ -139,6 +140,12 @@ options:
|
||||
type: bool
|
||||
default: False
|
||||
version_added: "1.2.0"
|
||||
history_max:
|
||||
description:
|
||||
- Limit the maximum number of revisions saved per release.
|
||||
- mutually exclusive with with C(replace).
|
||||
type: int
|
||||
version_added: "2.2.0"
|
||||
extends_documentation_fragment:
|
||||
- kubernetes.core.helm_common_options
|
||||
'''
|
||||
@@ -357,7 +364,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
|
||||
@@ -404,8 +411,10 @@ def deploy(command, release_name, release_values, chart_name, wait,
|
||||
if skip_crds:
|
||||
deploy_command += " --skip-crds"
|
||||
|
||||
deploy_command += " " + release_name + " " + chart_name
|
||||
if history_max is not None:
|
||||
deploy_command += " --history-max=%s" % str(history_max)
|
||||
|
||||
deploy_command += " " + release_name + " " + chart_name
|
||||
return deploy_command
|
||||
|
||||
|
||||
@@ -532,6 +541,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'),
|
||||
|
||||
# Generic auth key
|
||||
host=dict(type='str', fallback=(env_fallback, ['K8S_AUTH_HOST'])),
|
||||
@@ -546,6 +556,7 @@ def main():
|
||||
mutually_exclusive=[
|
||||
("context", "ca_cert"),
|
||||
("kubeconfig", "ca_cert"),
|
||||
("replace", "history_max"),
|
||||
],
|
||||
supports_check_mode=True,
|
||||
)
|
||||
@@ -575,6 +586,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
|
||||
@@ -610,7 +622,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:
|
||||
@@ -627,7 +639,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:
|
||||
|
||||
Reference in New Issue
Block a user