Skip to content

fix: add platform argument to preflight calls #12

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

Merged
merged 6 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 3 additions & 5 deletions src/image_tools/args.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# This is the stackable release version
from argparse import Namespace, ArgumentParser
from typing import List
import re
import importlib.util
import sys
Expand Down Expand Up @@ -43,7 +42,7 @@ def bake_args() -> Namespace:
"--architecture",
help="Target platform for image. Default: linux/amd64.",
nargs="+",
default=["linux/amd64"],
default="linux/amd64",
type=check_architecture_input,
)
parser.add_argument(
Expand Down Expand Up @@ -132,8 +131,7 @@ def preflight_args() -> Namespace:
"-a",
"--architecture",
help="Target platform for image. Default: linux/amd64.",
nargs="+",
default=["linux/amd64"],
default="linux/amd64",
type=check_architecture_input,
)
parser.add_argument(
Expand Down Expand Up @@ -174,7 +172,7 @@ def preflight_args() -> Namespace:
return result


def check_architecture_input(architecture) -> List[str]:
def check_architecture_input(architecture: str) -> str:
supported_arch = ["linux/amd64", "linux/arm64"]

if architecture not in supported_arch:
Expand Down
8 changes: 8 additions & 0 deletions src/image_tools/preflight.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ def preflight_commands(images: List[str], args: Namespace, conf) -> Dict[str, Co
f"ospid-{conf.open_shift_projects[args.product]['id']}",
]
)
if args.architecture:
cmd_args.extend(
["--platform",
# this argument value has already been checked against valid values with an expected prefix.
# Preflight provides the same "linux/" prefix and so it must be removed here.
args.architecture.split("linux/")[1],
]
)
result[img] = Command(args=cmd_args)
return result

Expand Down
Loading