Allow App definition without full container definition
This commit is contained in:
parent
86a845a92d
commit
cdb9768086
@ -37,7 +37,7 @@ def install(app_name):
|
||||
for layer in set(required_images):
|
||||
if layer not in local_images:
|
||||
queue.download_image(Image(layer, False))
|
||||
queue.download_app(App(app_name, False))
|
||||
queue.download_app(App(app_name, False, False))
|
||||
queue.process()
|
||||
|
||||
@locked(LOCK_FILE, print_lock)
|
||||
@ -71,7 +71,7 @@ def publish(filename, force):
|
||||
print(f'Application {app_name} already published, skipping publish task')
|
||||
|
||||
def unpublish(app_name):
|
||||
App(app_name, False).unpublish()
|
||||
App(app_name, False, False).unpublish()
|
||||
|
||||
def autostart(value):
|
||||
value = value.lower() in ('1', 'on', 'enable', 'true')
|
||||
|
@ -15,7 +15,7 @@ from .container import Container
|
||||
from .image import Image
|
||||
|
||||
class App:
|
||||
def __init__(self, name, load_from_repo=True):
|
||||
def __init__(self, name, define_containers=True, load_from_repo=True):
|
||||
self.name = name
|
||||
self.version = None
|
||||
self.app_dir = os.path.join(APPS_DIR, name)
|
||||
@ -23,13 +23,13 @@ class App:
|
||||
self.autostart = False
|
||||
self.containers = []
|
||||
if load_from_repo:
|
||||
self.set_definition(repo_local.get_app(name))
|
||||
self.set_definition(repo_local.get_app(name), define_containers)
|
||||
|
||||
def set_definition(self, definition):
|
||||
def set_definition(self, definition, define_containers):
|
||||
self.version = definition['version']
|
||||
self.meta = definition['meta']
|
||||
self.autostart = definition['autostart']
|
||||
self.containers = [Container(container) for container in definition['containers']]
|
||||
self.containers = [Container(container, define_containers) for container in definition['containers']]
|
||||
|
||||
def get_definition(self):
|
||||
return {
|
||||
@ -91,9 +91,7 @@ class App:
|
||||
|
||||
def update(self):
|
||||
# Remove containers
|
||||
# Load the local repo data here instead set_definition() to avoid fully defining containers which may not exist already
|
||||
containers = [Container(container, False) for container in repo_local.get_app(self.name)['containers']]
|
||||
for container in containers:
|
||||
for container in self.containers:
|
||||
container.destroy()
|
||||
# Load online definition
|
||||
definition = repo_online.get_app(self.name)
|
||||
@ -108,14 +106,12 @@ class App:
|
||||
|
||||
def uninstall(self):
|
||||
# Make sure the containers are stopped
|
||||
# Load the local repo data here instead set_definition() to avoid fully defining containers which may not exist already
|
||||
containers = [Container(container, False) for container in repo_local.get_app(self.name)['containers']]
|
||||
for container in containers:
|
||||
for container in self.containers:
|
||||
container.stop()
|
||||
# Run uninstall script
|
||||
self.run_script('uninstall')
|
||||
# Remove containers
|
||||
for container in containers:
|
||||
for container in self.containers:
|
||||
container.destroy()
|
||||
# Unregister app and remove scripts
|
||||
repo_local.unregister_app(self.name)
|
||||
@ -123,7 +119,6 @@ class App:
|
||||
shutil.rmtree(self.app_dir)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
# TODO: Remove unused images
|
||||
|
||||
def start(self):
|
||||
for container in self.containers:
|
||||
|
Loading…
Reference in New Issue
Block a user