Skip to content

Commit

Permalink
Added project install by release name with context and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nuwang committed Oct 28, 2020
1 parent 1e41a8e commit 2ea90b0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
8 changes: 7 additions & 1 deletion cloudman/helmsman/tests/mock_helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ def __init__(self):
'CHART VERSION': '3.0.0',
'APP VERSION': '10.01',
'DESCRIPTION': 'Another dummy chart'
},
{
'NAME': 'cloudve/jupyterhub\\v',
'CHART VERSION': '3.0.0',
'APP VERSION': '10.01',
'DESCRIPTION': 'Another dummy chart'
}
]
self.chart_list_field_names = ["NAME", "REVISION", "UPDATED", "STATUS",
Expand Down Expand Up @@ -220,7 +226,7 @@ def _helm_list(self, args):

def _helm_install(self, args):
repo_name, chart_name = args.chart.split('/')
release_name = '%s-%s' % (chart_name, uuid.uuid4().hex[:6])
release_name = args.name or '%s-%s' % (chart_name, uuid.uuid4().hex[:6])
revision = {
'NAME': release_name,
'REVISION': 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ def install_template_in_project(project_name, template_name,
print("Cannot find project {}.")
return None
try:
existing = proj.charts.find(release_name or template_name)
if release_name:
existing = proj.charts.get(release_name)
else:
existing = proj.charts.find(template_name)
if existing and upgrade_chart:
ch = proj.charts.update(existing, values, context=context)
print(f"Successfully updated template '{template_name}' "
Expand Down
1 change: 1 addition & 0 deletions cloudman/projman/tests/data/helmsman_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ install_templates:
baseUrl: '{{context.project.access_path}}/jupyterhub'
proxy:
secretToken: '{{random_alphanumeric(65)}}'
greeting: {{context.dummy}}
galaxy:
repo: cloudve
chart: galaxy
Expand Down
3 changes: 3 additions & 0 deletions cloudman/projman/tests/data/projman_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ projects:
galaxy:
install_template: galaxy
jupyterhub:
release_name: jup
install_template: jupyter
context:
dummy: "hello"
4 changes: 4 additions & 0 deletions cloudman/projman/tests/data/projman_config_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ projects:
storageclass: updated-provisioner
upgrade: true
jupyterhub:
release_name: jup
install_template: jupyter
upgrade: true
context:
dummy: "world"
12 changes: 12 additions & 0 deletions cloudman/projman/tests/test_mgmt_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,15 @@ def test_projman_update_config(self):
chart2 = proj2.charts.find("galaxy")
self.assertEqual(chart2.values['postgresql']['persistence']['storageClass'],
"updated-provisioner")

def test_projman_context_update_by_release_name(self):
call_command('helmsman_load_config', self.INITIAL_HELMSMAN_DATA)
call_command('projman_load_config', self.INITIAL_PROJECT_DATA)
projman_api = ProjManAPI(PMServiceContext(
user=User.objects.get_or_create(username='admin', is_superuser=True)[0]))
proj = projman_api.projects.find("second")
chart = proj.charts.get("jup")
self.assertEqual(chart.values['greeting'], "hello")
call_command('projman_load_config', self.INITIAL_PROJECT_DATA_UPDATE)
chart = proj.charts.get("jup")
self.assertEqual(chart.values['greeting'], "world")

0 comments on commit 2ea90b0

Please sign in to comment.