Skip to content

Commit

Permalink
black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-Ben committed Nov 16, 2023
1 parent 202c7a0 commit 8ba474c
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def build_image_args(config: DevConfig, image_name: str) -> Dict[str, str]:
"inventory": "inventory.yaml",
# These two options below can probably be removed
"skip_tags": config.skip_tags, # Include skip_tags
"include_tags": config.include_tags # Include include_tags
"include_tags": config.include_tags, # Include include_tags
}

# Handle special cases
Expand All @@ -61,22 +61,29 @@ def build_image_args(config: DevConfig, image_name: str) -> Dict[str, str]:
return arguments


def build_and_push_image(image_name: str, config: DevConfig, args: Dict[str, str], architectures: Set[str],
release: bool):
def build_and_push_image(
image_name: str,
config: DevConfig,
args: Dict[str, str],
architectures: Set[str],
release: bool,
):
for arch in architectures:
image_tag = f"{image_name}-{arch}"
process_image(
image_tag,
build_args=args,
inventory=args["inventory"],
skip_tags=args["skip_tags"],
include_tags=args["include_tags"]
include_tags=args["include_tags"],
)
if release:
# TODO : is the release with gh_run_id still needed ?
push_manifest(config, architectures, args["image_dev"])
push_manifest(config, architectures, args["image"], args["release_version"])
push_manifest(config, architectures, args["image"], args["release_version"] + "-context")
push_manifest(
config, architectures, args["image"], args["release_version"] + "-context"
)


"""
Expand All @@ -90,7 +97,12 @@ def build_and_push_image(image_name: str, config: DevConfig, args: Dict[str, str
"""


def push_manifest(config: DevConfig, architectures: Set[str], image_name: str, image_tag: str = "latest"):
def push_manifest(
config: DevConfig,
architectures: Set[str],
image_name: str,
image_tag: str = "latest",
):
print(f"Pushing manifest for {image_tag}")
final_manifest = "{0}/{1}:{2}".format(config.repo_url, image_name, image_tag)
remove_args = ["docker", "manifest", "rm", final_manifest]
Expand Down Expand Up @@ -120,7 +132,13 @@ def run_cli_command(args: List[str], raise_exception: bool = True):
command = " ".join(args)
print(f"Running: {command}")
try:
cp = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, check=False)
cp = subprocess.run(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
check=False,
)
except Exception as e:
print(f"Error executing command: {e}")
if raise_exception:
Expand Down Expand Up @@ -175,10 +193,12 @@ def main() -> int:
else:
# Default is multi-arch
arch_set = ["amd64", "arm64"]
print("Building for architectures:", ', '.join(map(str, arch_set)))
print("Building for architectures:", ", ".join(map(str, arch_set)))

if image_name not in VALID_IMAGE_NAMES:
print(f"Invalid image name: {image_name}. Valid options are: {VALID_IMAGE_NAMES}")
print(
f"Invalid image name: {image_name}. Valid options are: {VALID_IMAGE_NAMES}"
)
return 1

image_args = build_image_args(config, image_name)
Expand Down

0 comments on commit 8ba474c

Please sign in to comment.