More improvements and breaking changes

This commit is contained in:
AaronDewes 2022-04-09 19:39:19 +00:00
parent f6c3f7a192
commit 45941daee9
5 changed files with 55 additions and 23 deletions

View File

@ -31,12 +31,12 @@ properties:
description:
description: A longer description of the app
type: string
developer:
developers:
description: The awesome people behind the app
type: string
website:
description: Displayed version for the app
type: string
type: object
patternProperties:
"^.*$":
type: string
dependencies:
description: >-
The services the app depends on.
@ -49,7 +49,7 @@ properties:
type: string
repo:
description: The development repository for your app
type: string
type: [string, object]
support:
description: A link to the app support wiki/chat/...
type: string
@ -75,15 +75,14 @@ properties:
type:
- string
- array
description: The container(s) the developer system should automatically update.
description: The container(s) the automatic update system should automatically update.
required:
- name
- version
- category
- tagline
- description
- developer
- website
- developers
- repo
- support
- gallery
@ -186,6 +185,11 @@ properties:
restart:
type: string
description: When the container should restart. Can be 'always' or 'on-failure'.
requires:
description: Dependencies this container requires, it is ignored without it.
type: array
items:
type: string
network_mode:
type: string
additionalProperties: false

View File

@ -22,14 +22,14 @@ def convertContainerPermissions(app: App) -> App:
container.environment_allow.extend(permissions()[permission]['environment_allow'])
container.volumes.extend(permissions()[permission]['volumes'])
else:
print("Warning: app {} defines unknown permission {}".format(container.name, app.metadata.name, permission))
print("Warning: app {} defines unknown permission {}".format(app.metadata.name, permission))
else:
for subPermission in permission:
if subPermission in permissions():
container.environment_allow.extend(permissions()[subPermission]['environment_allow'])
container.volumes.extend(permissions()[subPermission]['volumes'])
else:
print("Warning: app {} defines unknown permission {}".format(container.name, app.metadata.name, subPermission))
print("Warning: app {} defines unknown permission {}".format(app.metadata.name, subPermission))
return app
def convertDataDirToVolumeGen3(app: App) -> AppStage2:
@ -69,7 +69,7 @@ def convertDataDirToVolumeGen3(app: App) -> AppStage2:
def createComposeConfigFromV3(app: dict, nodeRoot: str):
envFile = os.path.join(nodeRoot, ".env")
networkingFile = os.path.join(nodeRoot, "apps", "networking.json")
ignoredContainers = []
newApp: App = generateApp(app)
newApp = convertContainerPermissions(newApp)
newApp = validateEnv(newApp)
@ -80,10 +80,21 @@ def createComposeConfigFromV3(app: dict, nodeRoot: str):
for container in newApp.containers:
container.ports = container.requiredPorts
del container.requiredPorts
for container in newApp.containers:
# TODO: Make this dynamic and not hardcoded
if container.requires and "c-lightning" in container.requires:
ignoredContainers.append(container.name)
container.ignored = True
elif container.requires:
del container.requires
newApp = configureHiddenServices(newApp, nodeRoot)
for container in newApp.containers:
del container.ignored
finalConfig: AppStage4 = convertContainersToServices(newApp)
newApp = classToDict(finalConfig)
del newApp['metadata']
for container in ignoredContainers:
del newApp['services'][container]
if "version" in newApp:
del newApp["version"]
# Set version to 3.8 (current compose file version)

View File

@ -18,6 +18,10 @@ def getMainContainer(app: App) -> Container:
# Main is recommended, support web for easier porting from Umbrel
if container.name == 'main' or container.name == 'web':
return container
for container in app.containers:
# Also allow names to start with main
if container.name.startswith("main") and not container.ignored:
return container
# Fallback to first container
return app.containers[0]

View File

@ -10,12 +10,11 @@ class Metadata:
category: str
tagline: str
description: str
developer: str
website: str
repo: str
support: str
developers: dict = field(default_factory=dict)
gallery: List[Union[list,str]] = field(default_factory=list)
dependencies: List[str] = field(default_factory=list)
dependencies: List[Union[List[str], str]] = field(default_factory=list)
updateContainer: Union[str, Union[list, None]] = field(default_factory=list)
path: str = ""
defaultPassword: str = ""
@ -53,11 +52,13 @@ class Container:
noNetwork: Union[bool, None] = None
hiddenServicePorts: Union[dict, Union[int, Union[None, list]]] = field(default_factory=list)
environment_allow: list = field(default_factory=list)
requires: list = field(default_factory=list)
network_mode: Union[str, None] = None
# Only added later
volumes: list = field(default_factory=list)
restart: Union[str, None] = None
ports: list = field(default_factory=list)
ignored: bool = False
@dataclass
class App:
@ -99,6 +100,7 @@ class ContainerStage2:
networks: NetworkConfig = field(default_factory=NetworkConfig)
restart: Union[str, None] = None
network_mode: Union[str, None] = None
requires: Union[List[str], None] = field(default_factory=list)
@dataclass
class AppStage2:

View File

@ -92,14 +92,25 @@ def findAndValidateApps(dir: str):
should_continue=True
if appyml['metadata']['dependencies']:
for dependency in appyml['metadata']['dependencies']:
if dependency not in apps and dependency not in ["bitcoind", "lnd", "electrum"]:
print("WARNING: App '{}' has unknown dependency '{}'".format(app, dependency))
apps.remove(app)
should_continue=False
if dependency == app:
print("WARNING: App '{}' depends on itself".format(app))
apps.remove(app)
should_continue=False
if isinstance(dependency, str):
if dependency not in apps and dependency not in ["bitcoind", "lnd", "electrum"]:
print("WARNING: App '{}' has unknown dependency '{}'".format(app, dependency))
apps.remove(app)
should_continue=False
if dependency == app:
print("WARNING: App '{}' depends on itself".format(app))
apps.remove(app)
should_continue=False
else:
for subDependency in dependency:
if subDependency not in apps and subDependency not in ["bitcoind", "lnd", "electrum", "c-lightning"]:
print("WARNING: App '{}' has unknown dependency '{}'".format(app, subDependency))
apps.remove(app)
should_continue=False
if subDependency == app:
print("WARNING: App '{}' depends on itself".format(app))
apps.remove(app)
should_continue=False
if not should_continue:
continue
for container in appyml['containers']: