def load(self) -> typing.Iterable[Engine]: engine_source = [ ShimPathEngineSource(name="shim", description="shim based root dir source") ] engine_parts = [ CoreEnginePart(source_path="engine-core", source_name="shim"), BashExecutorEnginePart(source_path="executor-bash", source_name="shim"), AWSEnginePluginPart(source_path="engine-plugin-aws", source_name="shim"), AzureEnginePluginPart(source_path="engine-plugin-azure", source_name="shim"), CMDBEnginePluginPart(source_path="engine-plugin-cmdb", source_name="shim"), WrapperEnginePart(source_path="engine-wrapper", source_name="shim"), ] engine = GlobalEngine( name=ENGINE_GLOBAL_NAME, description="The engine used to provide global part mappings", ) engine.parts = engine_parts engine.sources = engine_source yield engine
def load(self) -> typing.Iterable[Engine]: engine_sources = [ ContainerEngineSource( name="hamlet-engine-base", description="hamlet official engine source", registry_url="https://ghcr.io", repository="hamlet-io/hamlet-engine-base", tag="nightly", ), ] engine_parts = [ WrapperEnginePart(source_path="engine-core/", source_name="hamlet-engine-base"), CoreEnginePart(source_path="engine/", source_name="hamlet-engine-base"), BashExecutorEnginePart(source_path="executor-bash/", source_name="hamlet-engine-base"), AWSEnginePluginPart(source_path="engine-plugin-aws/", source_name="hamlet-engine-base"), AzureEnginePluginPart(source_path="engine-plugin-azure/", source_name="hamlet-engine-base"), ] engine = Engine(name="tram", description="Nightly build of the official engine") engine.parts = engine_parts engine.sources = engine_sources yield engine
def load(self) -> typing.Iterable[Engine]: engine_sources = [ ContainerEngineSource( name="engine", description="hamlet core engine", registry_url="https://ghcr.io", repository="hamlet-io/engine", tag="edge", ), ContainerEngineSource( name="executor-bash", description="hamlet bash executor", registry_url="https://ghcr.io", repository="hamlet-io/executor-bash", tag="edge", ), ContainerEngineSource( name="engine-plugin-aws", description="hamlet aws engine plugin", registry_url="https://ghcr.io", repository="hamlet-io/engine-plugin-aws", tag="edge", ), ContainerEngineSource( name="engine-plugin-azure", description="hamlet azure engine plugin", registry_url="https://ghcr.io", repository="hamlet-io/engine-plugin-azure", tag="edge", ), ContainerEngineSource( name="engine-core", description="hamlet freemarker wrapper", registry_url="https://ghcr.io", repository="hamlet-io/engine-core", tag="edge", ), ] engine_parts = [ WrapperEnginePart(source_path="", source_name="engine-core"), CoreEnginePart(source_path="", source_name="engine"), BashExecutorEnginePart(source_path="", source_name="executor-bash"), AWSEnginePluginPart(source_path="", source_name="engine-plugin-aws"), AzureEnginePluginPart(source_path="", source_name="engine-plugin-azure"), ] engine = Engine( name="unicycle", description="Latest build of the official engine parts") engine.parts = engine_parts engine.sources = engine_sources yield engine
def load(self) -> typing.Iterable[Engine]: container_repo = ContainerRepository( registry_url="https://ghcr.io", repository="hamlet-io/hamlet-engine-base" ) for tag in container_repo.tags: if re.fullmatch("^v?[0-9]*.[0-9]*.[0-9]*.$", tag) is not None: engine_sources = [ ContainerEngineSource( name="hamlet-engine-base", description="hamlet official engine source", registry_url="https://ghcr.io", repository="hamlet-io/hamlet-engine-base", tag=tag, ), ] engine_parts = [ WrapperEnginePart( source_path="engine-core/", source_name="hamlet-engine-base" ), CoreEnginePart( source_path="engine/", source_name="hamlet-engine-base" ), BashExecutorEnginePart( source_path="executor-bash/", source_name="hamlet-engine-base" ), AWSEnginePluginPart( source_path="engine-plugin-aws/", source_name="hamlet-engine-base", ), AzureEnginePluginPart( source_path="engine-plugin-azure/", source_name="hamlet-engine-base", ), ] engine = Engine( name=tag, description="Stable release of the official hamlet engine", ) engine.parts = engine_parts engine.sources = engine_sources yield engine
def load(self) -> typing.Iterable[Engine]: container_repo = ContainerRepository( registry_url="https://ghcr.io", repository="hamlet-io/hamlet-engine-base") for tag in container_repo.tags: if tag.startswith("schedule-") and datetime.datetime.now( ) - datetime.datetime.strptime(tag.split("-")[1], "%Y%m%d") <= datetime.timedelta( days=90): engine_sources = [ ContainerEngineSource( name="hamlet-engine-base", description="hamlet official engine source", registry_url="https://ghcr.io", repository="hamlet-io/hamlet-engine-base", tag=tag, ), ] engine_parts = [ WrapperEnginePart(source_path="engine-core/", source_name="hamlet-engine-base"), CoreEnginePart(source_path="engine/", source_name="hamlet-engine-base"), BashExecutorEnginePart(source_path="executor-bash/", source_name="hamlet-engine-base"), AWSEnginePluginPart( source_path="engine-plugin-aws/", source_name="hamlet-engine-base", ), AzureEnginePluginPart( source_path="engine-plugin-azure/", source_name="hamlet-engine-base", ), ] engine = Engine( name=tag.replace("schedule-", "tram-"), description="Scheduled build of the official hamlet engine", ) engine.parts = engine_parts engine.sources = engine_sources yield engine
def load_engines(cls): """Load engines found in the config file.""" if os.path.exists(HAMLET_GLOBAL_CONFIG.config_dir): if os.path.isdir(HAMLET_GLOBAL_CONFIG.config_dir): cls.config_searchpath.insert(0, HAMLET_GLOBAL_CONFIG.config_dir) config = cls.read_config() for k, v in config.items(): if k.startswith("engine:"): engine = Engine( name=k[len("engine:") :], description=v.get("description", None), ) sources = [] for source_name in v.get("sources"): try: source_config = config[f"engine_source:{source_name}"] except KeyError as e: e.msg = ( f"The provided engine source {source_name}" "could not be found in the configured local sources" ) raise e if source_config["type"] == "local_dir": sources.append( LocalDirectoryEngineSource( name=source_name, description=source_config.get("description", None), env_path=source_config["local_dir_path"], ) ) if source_config["type"] == "container": sources.append( ContainerEngineSource( name=source_name, description=source_config.get("description", None), registry_url=source_config.get( "container_registry_url" ), repository=source_config.get("container_repository"), tag=source_config.get("container_tag"), ) ) parts = [] for part_name in v.get("parts"): part_config = config[f"engine_part:{part_name}"] part_source_config = { "source_name": part_config["source_name"], "source_path": part_config.get("source_path", ""), } if part_config["type"] == "engine": parts.append(CoreEnginePart(**part_source_config)) if part_config["type"] == "engine-plugin-aws": parts.append(AWSEnginePluginPart(**part_source_config)) if part_config["type"] == "engine-plugin-azure": parts.append(AzureEnginePluginPart(**part_source_config)) if part_config["type"] == "engine-plugin-cmdb": parts.append(CMDBEnginePluginPart(**part_source_config)) if part_config["type"] == "executor-bash": parts.append(BashExecutorEnginePart(**part_source_config)) if part_config["type"] == "wrapper": parts.append(WrapperEnginePart(**part_source_config)) engine.sources = sources engine.parts = parts yield engine