mirror of
https://gitlab.com/itsulu-odoo/runboat.git
synced 2026-05-30 23:41:27 +00:00
Abstract out image
The image, as part of build settings is only passed to kubefiles rendering, and not exposed outside.
This commit is contained in:
parent
73866fe377
commit
b34dd38a7b
5 changed files with 13 additions and 14 deletions
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue