Skip to content

Commit

Permalink
Merge pull request #127 from galaxyproject/add_screenshot_url
Browse files Browse the repository at this point in the history
Added screenshot property to install template
  • Loading branch information
Alexandru Mahmoud committed Jun 24, 2020
2 parents bc34710 + cac9d3e commit 054a652
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions cloudman/helmsman/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ def info_url(self):
def icon_url(self):
return self.template_obj.icon_url

@property
def screenshot_url(self):
return self.template_obj.screenshot_url

def render_values(self, context):
if not context:
context = {}
Expand Down
9 changes: 6 additions & 3 deletions cloudman/helmsman/management/commands/add_install_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def add_arguments(self, parser):
help='chart info url')
parser.add_argument('--icon_url', required=False,
help='chart icon url')
parser.add_argument('--screenshot_url', required=False,
help='chart screenshot url')

def handle(self, *args, **options):
self.add_install_template(
Expand All @@ -50,12 +52,13 @@ def handle(self, *args, **options):
options.get('description'),
options.get('maintainers'),
options.get('info_url'),
options.get('icon_url'))
options.get('icon_url'),
options.get('screenshot_url'))

@staticmethod
def add_install_template(name, repo, chart, chart_version, template,
context, display_name, summary, description,
maintainers, info_url, icon_url):
maintainers, info_url, icon_url, screenshot_url):
try:
print(f"Adding template: {name}")
admin = User.objects.filter(is_superuser=True).first()
Expand All @@ -69,7 +72,7 @@ def add_install_template(name, repo, chart, chart_version, template,
name, repo, chart, chart_version, template, context,
display_name=display_name, summary=summary,
description=description, maintainers=maintainers,
info_url=info_url, icon_url=icon_url)
info_url=info_url, icon_url=icon_url, screenshot_url=screenshot_url)
print(f"Successfully added template named: '{name}'"
f" for chart: '{repo}/{chart}'.")
except Exception as e:
Expand Down
2 changes: 2 additions & 0 deletions cloudman/helmsman/management/commands/helmsman_load_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def process_settings(settings):
extra_args += ["--info_url", template.get('info_url')]
if template.get('icon_url'):
extra_args += ["--icon_url", template.get('icon_url')]
if template.get('screenshot_url'):
extra_args += ["--screenshot_url", template.get('screenshot_url')]
if template.get('template'):
with helpers.TempInputFile(template.get('template')) as f:
extra_args += ["--template_file", f.name]
Expand Down
1 change: 1 addition & 0 deletions cloudman/helmsman/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Migration(migrations.Migration):
('maintainers', models.TextField(blank=True, null=True)),
('info_url', models.TextField(blank=True, null=True)),
('icon_url', models.TextField(blank=True, null=True)),
('screenshot_url', models.TextField(blank=True, null=True)),
],
options={
'verbose_name': 'Install Template',
Expand Down
1 change: 1 addition & 0 deletions cloudman/helmsman/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class HMInstallTemplate(models.Model):
maintainers = models.TextField(blank=True, null=True)
info_url = models.TextField(blank=True, null=True)
icon_url = models.TextField(blank=True, null=True)
screenshot_url = models.TextField(blank=True, null=True)

class Meta:
verbose_name = "Install Template"
Expand Down
4 changes: 3 additions & 1 deletion cloudman/helmsman/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class HMInstallTemplateSerializer(serializers.Serializer):
maintainers = serializers.CharField(allow_blank=True, required=False)
info_url = serializers.CharField(allow_blank=True, required=False)
icon_url = serializers.CharField(allow_blank=True, required=False)
screenshot_url = serializers.CharField(allow_blank=True, required=False)

def create(self, valid_data):
return HelmsManAPI.from_request(
Expand All @@ -33,7 +34,8 @@ def create(self, valid_data):
description=valid_data.get('description'),
maintainers=valid_data.get('maintainers'),
info_url=valid_data.get('info_url'),
icon_url=valid_data.get('icon_url'))
icon_url=valid_data.get('icon_url'),
screenshot_url=valid_data.get('screenshot_url'))

def render_values(self, valid_data):
return HelmsManAPI.from_request(self.context['request']
Expand Down
1 change: 1 addition & 0 deletions cloudman/helmsman/tests/data/helmsman_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ install_templates:
maintainers: jupyter
info_url: https://jupyter.org/
icon_url: https://jupyter.org/assets/hublogo.svg
screenshot_url: https://jupyter.org/assets/hublogo.svg
template: |
ingress:
enabled: true
Expand Down
1 change: 1 addition & 0 deletions cloudman/helmsman/tests/test_helmsman_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ class InstallTemplateServiceTests(HelmsManServiceTestBase):
'maintainers': 'Galaxy Team',
'info_url': 'https://usegalaxy.org',
'icon_url': 'https://usegalaxy.org/some_icon.png',
'screenshot_url': 'https://usegalaxy.org/some_screenshot.png',
'context': {'project': 'test'},
'template': """ingress:
enabled: true
Expand Down

0 comments on commit 054a652

Please sign in to comment.