Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove helm #49

Merged
merged 3 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ repos:
hooks:
- id: check-added-large-files
- id: check-yaml
exclude: src/ibek/helm-template/templates
- id: check-merge-conflict

- repo: local
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ IOC Builder for EPICS and Kubernetes:
image to create a JSON schema of what an IOC using that image can contain
- Write an ``ioc.yaml`` file against that schema listing instances of the
entities with arguments
- Use ``ibek`` to generate a startup script, database and Helm chart that runs
- Use ``ibek`` to generate a startup script and database that runs
up the IOC contained in the image with them

============== ==============================================================
Expand Down
File renamed without changes.
File renamed without changes.
11 changes: 1 addition & 10 deletions docs/developer/explanations/entities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Click the arrows to reveal the files.
<details>
<summary><a>ioc.boot</a></summary>

.. include:: ../../../tests/samples/helm/ioc.boot
.. include:: ../../../tests/samples/boot_scripts/ioc.boot
:literal:

.. raw:: html
Expand Down Expand Up @@ -201,9 +201,6 @@ Thus, the sequence of files is as follows:
- <ioc>.ibek.entities.yaml
- Description of Entities for an IOC instance.
* - 5
- Helm Chart files
- The generated files for deploying the described IOC instance
* - 6
- IOC Startup Script ioc.boot
- Startup script for booting the IOC

Expand Down Expand Up @@ -262,12 +259,6 @@ The ibek commands to progress through the file sequence above are as follows
- ``<ioc>.ibek.entities.yaml``
- Hand crafted at IOC instance design time
* - 5
- Helm Chart files
- ``ibek build-helm <ioc>.ibek.entities.yaml``
run at IOC helm chart generation time. This generates a helm chart
with ``<ioc>.ibek.entities.yaml`` in its config folder and validates it
against the schema defined at the top of the YAML file.
* - 6
- IOC startup script
- ``ibek build-startup <ioc>.ibek.entities.yaml ...``. Run at IOC startup time in the
container. ``...`` == all ``<support>.ibek.defs.yaml`` within the container.
Expand Down
6 changes: 0 additions & 6 deletions docs/user/reference/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ This is the internal API reference for ibek
.. automodule:: ibek.modules
:members:

``ibek.helm``
-------------

.. automodule:: ibek.helm
:members:

``ibek.render``
---------------

Expand Down
File renamed without changes.
11 changes: 6 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ where = src
# Specify any package data to be included in the wheel below.
[options.package_data]
ibek =
helm-template/*/*
helm-template/*
templates/*

[options.entry_points]
Expand All @@ -86,9 +84,12 @@ float_to_top=true
# Make flake8 respect black's line length (default 88),
max-line-length = 88
extend-ignore =
E203, # See https://github.com/PyCQA/pycodestyle/issues/373
F811, # support typing.overload decorator
F722, # allow Annotated[typ, some_func("some string")]
# See https://github.com/PyCQA/pycodestyle/issues/373
E203,
# support typing.overload decorator
F811,
# allow Annotated[typ, some_func("some string")]
F722,
exclude =
.tox
venv
Expand Down
30 changes: 1 addition & 29 deletions src/ibek/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@

from ibek import __version__

from .helm import (
create_boot_script,
create_db_script,
create_helm,
ioc_deserialize,
load_ioc_yaml,
)
from .gen_scripts import create_boot_script, create_db_script, ioc_deserialize
from .ioc import IOC, make_entity_classes
from .support import Support

Expand Down Expand Up @@ -82,28 +76,6 @@ def ioc_schema(
output.write_text(schema)


@cli.command()
def build_helm(
entity: Path = typer.Argument(
..., help="The filepath to the ioc instance entity file"
),
out: Path = typer.Argument(
default="iocs", help="Path in which to build the helm chart"
),
no_schema: bool = typer.Option(False, help="disable schema checking"),
):
"""
Build a startup script, database and Helm chart from <ioc>.yaml
"""

ioc_dict = load_ioc_yaml(ioc_instance_yaml=entity, no_schema=no_schema)

with entity.open("r") as stream:
entity_yaml = stream.read()

create_helm(ioc_dict=ioc_dict, entity_yaml=entity_yaml, path=out)


@cli.command()
def build_startup(
instance: Path = typer.Argument(
Expand Down
65 changes: 65 additions & 0 deletions src/ibek/gen_scripts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""
Functions for building the db and boot scripts
"""
import logging
import re
from pathlib import Path
from typing import List

from jinja2 import Template
from ruamel.yaml.main import YAML

from .ioc import IOC, make_entity_classes
from .render import (
render_database_elements,
render_environment_variable_elements,
render_post_ioc_init_elements,
render_script_elements,
)
from .support import Support

log = logging.getLogger(__name__)

TEMPLATES = Path(__file__).parent / "templates"

schema_modeline = re.compile(r"# *yaml-language-server *: *\$schema=([^ ]*)")
url_f = r"file://"


def ioc_deserialize(ioc_instance_yaml: Path, definition_yaml: List[Path]) -> IOC:
"""
Takes an ioc instance entities file, list of generic ioc definitions files.

Returns an in memory object graph of the resulting ioc instance
"""
# Read and load the support module definitions
for yaml in definition_yaml:
support = Support.deserialize(YAML(typ="safe").load(yaml))
make_entity_classes(support)

# Create an IOC instance from it
return IOC.deserialize(YAML(typ="safe").load(ioc_instance_yaml))


def create_db_script(ioc_instance: IOC) -> str:
"""
Create make_db.sh script for expanding the database templates
"""
with open(TEMPLATES / "make_db.jinja", "r") as f:
template = Template(f.read())

return template.render(database_elements=render_database_elements(ioc_instance))


def create_boot_script(ioc_instance: IOC) -> str:
"""
Create the boot script for an IOC
"""
with open(TEMPLATES / "ioc.boot.jinja", "r") as f:
template = Template(f.read())

return template.render(
env_var_elements=render_environment_variable_elements(ioc_instance),
script_elements=render_script_elements(ioc_instance),
post_ioc_init_elements=render_post_ioc_init_elements(ioc_instance),
)
22 changes: 0 additions & 22 deletions src/ibek/helm-template/Chart.yaml.jinja

This file was deleted.

50 changes: 0 additions & 50 deletions src/ibek/helm-template/config/start.sh

This file was deleted.

10 changes: 0 additions & 10 deletions src/ibek/helm-template/templates/ioc.yaml

This file was deleted.

1 change: 0 additions & 1 deletion src/ibek/helm-template/values.yaml.jinja

This file was deleted.

Loading