Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added core update function #123

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions src/viur_cli/package.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import shutil
import subprocess
import zipfile
import click
import requests
Expand Down Expand Up @@ -84,9 +85,9 @@ def get_version_info(software: str, version: str) -> tuple[str, str]:

@cli.command()
@click.argument('operation', type=click.Choice(['update', 'install']))
@click.argument('component', type=click.Choice(['vi', 'admin', 'scriptor', 'all']))
@click.argument('profile', default='default')
@click.argument('component', type=click.Choice(['vi', 'admin', 'scriptor', 'core', 'all']))
@click.argument("version", default="latest")
@click.argument('profile', default='default')
def package(operation, component, profile, version):
"""
Performs installements and updates of ViUR Ecosystem packages
Expand All @@ -95,14 +96,21 @@ def package(operation, component, profile, version):
operations_links = {
'vi': vi,
'admin': admin,
'scriptor': scriptor
'scriptor': scriptor,
'core': core,
}

def perform_operation(component, version):
if operation == 'install':
operations_links[component](version, target=component, profile=profile)
else:
operations_links[component](version="latest", target=component, profile=profile)
if component == 'core':
operations_links[component](version)
else:
operations_links[component](version, target=component, profile=profile)
elif operation == 'update':
if component == 'core':
operations_links[component](version)
else:
operations_links[component](version="latest", target=component, profile=profile)

match component:
case 'vi':
Expand All @@ -111,11 +119,15 @@ def perform_operation(component, version):
perform_operation('admin', version)
case 'scriptor':
perform_operation('scriptor', version)
case 'core':
perform_operation('core', version)

case 'all':
if operation == 'update':
for build in conf["builds"]:
if build in operations_links:
perform_operation(build, "latest")
perform_operation("core", "latest")
else:
# We want to force the User to use the new Admin, so Vi can only be installed explicitly!!
for build in ["admin", "scriptor"]:
Expand Down Expand Up @@ -246,3 +258,11 @@ def step_label(step: int) -> str:
elif element == 5:
tmp_zip_file.unlink()
bar.label = "updated successful"

def core(version):
command = 'pipenv install viur-core'
if version not in ["latest", "*"]:
command += f'=="{version}"'
process = subprocess.check_output(command, shell=True).decode('utf-8')
echo_info(process)

Grashalmbeisser marked this conversation as resolved.
Show resolved Hide resolved