-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-values.py
41 lines (28 loc) · 1.28 KB
/
get-values.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
import os, argparse
from valuestools import valuestools
parser = argparse.ArgumentParser(description="Get a helm chart's default values when using helm dependencies. \n\n Usage: helm get-values <chartname>", formatter_class=argparse.RawTextHelpFormatter )
parser.add_argument('chartname', type=str, help='the name of the charts\' values to append to your values file')
args = vars(parser.parse_args())
tempdir = os.environ['HELM_PLUGIN_DIR'] + "/charts/"
extractpath = tempdir + "extract/"
# Fetch helm chart to temp dir
def chart(chartname):
setupsuccess = valuestools.setup(tempdir)
if not setupsuccess:
print("Please add a values.yaml file")
exit()
print("Getting values from " + chartname)
getchartsuccess = valuestools.getchart(tempdir, extractpath, chartname)
if not getchartsuccess:
print("Could not locate values.yaml in downloaded chart, exiting!")
valuestools.deleteFolder(tempdir)
exit()
# Open downloaded values and append with indent to values file in current directory
updatesuccess = valuestools.appendValues(extractpath)
if updatesuccess:
print("Values file updated with values from the " + chartname + " chart")
# Clean up
valuestools.deleteFolder(tempdir)
if __name__ == '__main__':
chart(args['chartname'])