diff --git a/src/runboat/api.py b/src/runboat/api.py index 542dd53..7d8f4f4 100644 --- a/src/runboat/api.py +++ b/src/runboat/api.py @@ -44,7 +44,6 @@ class Repo(BaseModel): class Build(BaseModel): name: str commit_info: github.CommitInfo - image: str deploy_link: str repo_target_branch_link: str repo_pr_link: Optional[str] diff --git a/src/runboat/db.py b/src/runboat/db.py index 1de887e..c613868 100644 --- a/src/runboat/db.py +++ b/src/runboat/db.py @@ -59,7 +59,6 @@ class BuildsDb: " target_branch TEXT NOT NULL, " " pr INTEGER, " " git_commit TEXT NOT NULL, " - " image TEXT NOT NULL," " desired_replicas INTEGER NOT NULL," " status TEXT NOT NULL, " " init_status TEXT NOT NULL, " @@ -118,14 +117,13 @@ class BuildsDb: " target_branch," " pr," " git_commit," - " image," " desired_replicas," " status," " init_status, " " last_scaled, " " created" ") " - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", ( build.name, build.deployment_name, @@ -133,7 +131,6 @@ class BuildsDb: build.commit_info.target_branch, build.commit_info.pr, build.commit_info.git_commit, - build.image, build.desired_replicas, build.status, build.init_status, diff --git a/src/runboat/k8s.py b/src/runboat/k8s.py index 1ee7d32..5c2a063 100644 --- a/src/runboat/k8s.py +++ b/src/runboat/k8s.py @@ -20,7 +20,7 @@ from kubernetes.client.models.v1_job import V1Job from pydantic import BaseModel from .github import CommitInfo -from .settings import settings +from .settings import BuildSettings, settings from .utils import sync_to_async, sync_to_async_iterator _logger = logging.getLogger(__name__) @@ -160,9 +160,9 @@ def make_deployment_vars( build_name: str, slug: str, commit_info: CommitInfo, - image: str, + build_settings: BuildSettings, ) -> DeploymentVars: - image_name, image_tag = _split_image_name_tag(image) + image_name, image_tag = _split_image_name_tag(build_settings.image) return DeploymentVars( mode=mode, namespace=settings.build_namespace, diff --git a/src/runboat/models.py b/src/runboat/models.py index 1921284..6fa36b4 100644 --- a/src/runboat/models.py +++ b/src/runboat/models.py @@ -41,7 +41,6 @@ class Build(BaseModel): name: str deployment_name: str commit_info: CommitInfo - image: str status: BuildStatus init_status: BuildInitStatus desired_replicas: int @@ -86,7 +85,6 @@ class Build(BaseModel): pr=deployment.metadata.annotations.get("runboat/pr") or None, git_commit=deployment.metadata.annotations["runboat/git-commit"], ), - image=deployment.spec.template.spec.containers[0].image, init_status=deployment.metadata.annotations["runboat/init-status"], status=cls._status_from_deployment(deployment), desired_replicas=deployment.spec.replicas or 0, @@ -193,7 +191,7 @@ class Build(BaseModel): name, slug, commit_info, - build_settings[0].image, + build_settings[0], ) await k8s.deploy(deployment_vars) await github.notify_status( @@ -257,7 +255,9 @@ class Build(BaseModel): self.name, self.slug, self.commit_info, - self.image, + settings.get_build_settings( + self.commit_info.repo, self.commit_info.target_branch + )[0], ) await k8s.deploy(deployment_vars) @@ -275,7 +275,9 @@ class Build(BaseModel): self.name, self.slug, self.commit_info, - self.image, + settings.get_build_settings( + self.commit_info.repo, self.commit_info.target_branch + )[0], ) await k8s.deploy(deployment_vars) diff --git a/tests/test_render_kubefiles.py b/tests/test_render_kubefiles.py index b6111c9..05d294a 100644 --- a/tests/test_render_kubefiles.py +++ b/tests/test_render_kubefiles.py @@ -1,5 +1,6 @@ from runboat.github import CommitInfo from runboat.k8s import DeploymentMode, _render_kubefiles, make_deployment_vars +from runboat.settings import BuildSettings EXPECTED = """\ resources: @@ -77,7 +78,7 @@ def test_render_kubefiles() -> None: pr=None, git_commit="abcdef123456789", ), - image="ghcr.io/oca/oca-ci:py3.8-odoo15.0", + build_settings=BuildSettings(image="ghcr.io/oca/oca-ci:py3.8-odoo15.0"), ) with _render_kubefiles(deployment_vars) as tmp_path: assert (tmp_path / "kustomization.yaml").is_file()