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