task: make helm_home, bin, and kubectl bin configurable
Refs /salt-formulas/salt-formula-helm#2
diff --git a/_states/helm_release.py b/_states/helm_release.py
index d4a1b69..0fb6468 100644
--- a/_states/helm_release.py
+++ b/_states/helm_release.py
@@ -14,17 +14,18 @@
def present(name, chart_name, namespace, version=None, values=None,
tiller_namespace='kube-system', tiller_host=None,
- kube_config=None, gce_service_token=None):
- tiller_args = {
+ kube_config=None, gce_service_token=None, helm_home=None):
+ kwargs = {
'tiller_namespace': tiller_namespace,
'tiller_host': tiller_host,
'kube_config': kube_config,
'gce_service_token': gce_service_token,
+ 'helm_home': helm_home
}
- exists = __salt__['helm.release_exists'](name, namespace, **tiller_args)
+ exists = __salt__['helm.release_exists'](name, namespace, **kwargs)
if not exists:
err = __salt__['helm.release_create'](
- name, chart_name, namespace, version, values, **tiller_args)
+ name, chart_name, namespace, version, values, **kwargs)
if err:
return failure(name, err)
return {
@@ -34,13 +35,13 @@
'comment': 'Release "{}" was created'.format(name),
}
- old_values = __salt__['helm.get_values'](name, **tiller_args)
+ old_values = __salt__['helm.get_values'](name, **kwargs)
err = __salt__['helm.release_upgrade'](
- name, chart_name, namespace, version, values, **tiller_args)
+ name, chart_name, namespace, version, values, **kwargs)
if err:
return failure(name, err)
- new_values = __salt__['helm.get_values'](name, **tiller_args)
+ new_values = __salt__['helm.get_values'](name, **kwargs)
if new_values == old_values:
return {
'name': name,
@@ -62,14 +63,15 @@
def absent(name, namespace, tiller_namespace='kube-system', tiller_host=None,
- kube_config=None, gce_service_token=None):
- tiller_args = {
+ kube_config=None, gce_service_token=None, helm_home=None):
+ kwargs = {
'tiller_namespace': tiller_namespace,
'tiller_host': tiller_host,
'kube_config': kube_config,
'gce_service_token': gce_service_token,
+ 'helm_home': helm_home
}
- exists = __salt__['helm.release_exists'](name, namespace, **tiller_args)
+ exists = __salt__['helm.release_exists'](name, namespace, **kwargs)
if not exists:
return {
'name': name,
@@ -77,7 +79,7 @@
'result': True,
'comment': 'Release "{}" doesn\'t exist'.format(name),
}
- err = __salt__['helm.release_delete'](name, **tiller_args)
+ err = __salt__['helm.release_delete'](name, **kwargs)
if err:
return failure(name, err)
return {
diff --git a/_states/helm_repos.py b/_states/helm_repos.py
index 88f0894..ee1d556 100644
--- a/_states/helm_repos.py
+++ b/_states/helm_repos.py
@@ -2,7 +2,7 @@
from salt.exceptions import CommandExecutionError
-def managed(name, present={}, absent=[], exclusive=False):
+def managed(name, present={}, absent=[], exclusive=False, helm_home=None):
'''
Ensure the supplied repositories are available to the helm client. If the
`exclusive` flag is set to a truthy value, any extra repositories in the
@@ -17,9 +17,13 @@
absent
A list of repository names to ensure are unregistered from the Helm client
+
exclusive
A boolean flag indicating whether the state should ensure only the
supplied repositories are availabe to the target minion.
+
+ helm_home
+ An optional path to the Helm home directory
'''
ret = {'name': name,
'changes': {},
@@ -30,7 +34,8 @@
result = __salt__['helm.manage_repos'](
present=present,
absent=absent,
- exclusive=exclusive
+ exclusive=exclusive,
+ helm_home=helm_home
)
if result['failed']:
@@ -52,7 +57,7 @@
ret['comment'] = "Failed to add some repositories: %s" % e
return ret
-def updated(name):
+def updated(name, helm_home=None):
'''
Ensure the local Helm repository cache is up to date with each of the
helm client's configured remote chart repositories. Because the `helm repo
@@ -63,6 +68,9 @@
name
The name of the state
+
+ helm_home
+ An optional path to the Helm home directory
'''
ret = {'name': name,
'changes': {},
@@ -71,7 +79,7 @@
output = None
try:
- output = __salt__['helm.update_repos']()
+ output = __salt__['helm.update_repos'](helm_home=helm_home)
except CommandExecutionError as e:
ret['result'] = False
ret['comment'] = "Failed to update repos: %s" % e