refactor: set image/dockerfile from provider default first, override after
Since every provider always has a dockerfile, establish the default image and dockerfile_path from the provider up front and override for per-bottle or manifest-specified cases. Removes the image_default intermediate variable and the trailing else branch.
This commit is contained in:
@@ -93,21 +93,17 @@ def resolve_plan(
|
|||||||
# written (via apply_capability_change), the base image becomes
|
# written (via apply_capability_change), the base image becomes
|
||||||
# per_bottle_image_tag(slug) built from that file. --cwd still
|
# per_bottle_image_tag(slug) built from that file. --cwd still
|
||||||
# layers a derived image on top.
|
# layers a derived image on top.
|
||||||
dockerfile_path = ""
|
if provider.template in PROVIDER_TEMPLATES:
|
||||||
|
image = provider_runtime.image
|
||||||
|
else:
|
||||||
|
image = f"bot-bottle-{provider.template}:{slug}"
|
||||||
|
dockerfile_path = str(provider_obj.dockerfile)
|
||||||
if per_bottle_dockerfile(slug) is not None:
|
if per_bottle_dockerfile(slug) is not None:
|
||||||
image_default = per_bottle_image_tag(slug)
|
image = per_bottle_image_tag(slug)
|
||||||
dockerfile_path = str(per_bottle_dockerfile_path(slug))
|
dockerfile_path = str(per_bottle_dockerfile_path(slug))
|
||||||
elif provider.dockerfile:
|
elif provider.dockerfile:
|
||||||
image_default = f"bot-bottle-{provider.template}:{slug}"
|
image = f"bot-bottle-{provider.template}:{slug}"
|
||||||
dockerfile_path = _resolve_manifest_dockerfile(provider.dockerfile, spec)
|
dockerfile_path = _resolve_manifest_dockerfile(provider.dockerfile, spec)
|
||||||
else:
|
|
||||||
p_dockerfile = provider_obj.dockerfile
|
|
||||||
if provider.template in PROVIDER_TEMPLATES:
|
|
||||||
image_default = provider_runtime.image
|
|
||||||
else:
|
|
||||||
image_default = f"bot-bottle-{provider.template}:{slug}"
|
|
||||||
dockerfile_path = str(p_dockerfile)
|
|
||||||
image = image_default
|
|
||||||
derived_image = ""
|
derived_image = ""
|
||||||
runtime_image = image
|
runtime_image = image
|
||||||
if spec.copy_cwd:
|
if spec.copy_cwd:
|
||||||
|
|||||||
@@ -116,18 +116,14 @@ def resolve_plan(
|
|||||||
prompt_file.chmod(0o600)
|
prompt_file.chmod(0o600)
|
||||||
|
|
||||||
machine_name = f"bot-bottle-{slug}"
|
machine_name = f"bot-bottle-{slug}"
|
||||||
agent_dockerfile_path = ""
|
if provider.template in PROVIDER_TEMPLATES:
|
||||||
if provider.dockerfile:
|
agent_image_ref = provider_runtime.image
|
||||||
agent_dockerfile_path = _resolve_manifest_dockerfile(provider.dockerfile, spec)
|
|
||||||
image_default = f"bot-bottle-{provider.template}:{slug}"
|
|
||||||
else:
|
else:
|
||||||
p_dockerfile = provider_obj.dockerfile
|
agent_image_ref = f"bot-bottle-{provider.template}:{slug}"
|
||||||
agent_dockerfile_path = str(p_dockerfile)
|
agent_dockerfile_path = str(provider_obj.dockerfile)
|
||||||
if provider.template in PROVIDER_TEMPLATES:
|
if provider.dockerfile:
|
||||||
image_default = provider_runtime.image
|
agent_image_ref = f"bot-bottle-{provider.template}:{slug}"
|
||||||
else:
|
agent_dockerfile_path = _resolve_manifest_dockerfile(provider.dockerfile, spec)
|
||||||
image_default = f"bot-bottle-{provider.template}:{slug}"
|
|
||||||
agent_image_ref = image_default
|
|
||||||
agent_provision = agent_provision_plan(
|
agent_provision = agent_provision_plan(
|
||||||
template=provider.template,
|
template=provider.template,
|
||||||
dockerfile=agent_dockerfile_path,
|
dockerfile=agent_dockerfile_path,
|
||||||
|
|||||||
Reference in New Issue
Block a user