Changeset View
Changeset View
Standalone View
Standalone View
python_modules/automation/automation/helm/schema/scheduler.py
- This file was added.
from enum import Enum | |||||
from typing import List, Optional | |||||
from pydantic import BaseModel, Extra # pylint: disable=E0611 | |||||
from .kubernetes import Image, SecretEnvSource | |||||
class SchedulerType(str, Enum): | |||||
CRON_SCHEDULER = "CronScheduler" | |||||
K8S_SCHEDULER = "K8sScheduler" | |||||
class K8sSchedulerConfig(BaseModel): | |||||
image: Image | |||||
schedulerNamespace: str | |||||
loadInclusterConfig: Optional[bool] | |||||
kubeconfigFile: Optional[str] | |||||
envSecrets: Optional[List[SecretEnvSource]] | |||||
class Config: | |||||
extra = Extra.forbid | |||||
class SchedulerConfig(BaseModel): | |||||
K8sScheduler: Optional[K8sSchedulerConfig] | |||||
class Config: | |||||
extra = Extra.forbid | |||||
class Scheduler(BaseModel): | |||||
type: SchedulerType | |||||
config: SchedulerConfig | |||||
class Config: | |||||
extra = Extra.forbid | |||||
schema_extra = { | |||||
"allOf": [ | |||||
rexledesma: support for conditional schemas isn't first class in pydantic so we'll have to override the… | |||||
Not Done Inline Actionsmaybe leave this is a comment in the code alangenfeld: maybe leave this is a comment in the code | |||||
{ | |||||
"if": {"properties": {"type": {"const": SchedulerType.K8S_SCHEDULER}},}, | |||||
"then": {"properties": {"config": {"required": [SchedulerType.K8S_SCHEDULER]}}}, | |||||
} | |||||
] | |||||
} |
support for conditional schemas isn't first class in pydantic so we'll have to override the schema here (https://github.com/samuelcolvin/pydantic/issues/529)