Skip to content

Commit

Permalink
Remove platform from push
Browse files Browse the repository at this point in the history
  • Loading branch information
d4nj1 committed Jan 3, 2024
1 parent e4b966e commit 47ebe5a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions python_on_whales/components/image/cli_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def pull(
return [self._pull_single_tag(x[0], quiet=quiet, platform=platform)]
elif len(x) >= 2:
pool = ThreadPool(4)
generator = self._generate_args_push_pull(x, quiet, platform)
generator = self._generate_args_pull(x, quiet, platform)
all_images = pool.starmap(self._pull_single_tag, generator)
pool.close()
pool.join()
Expand All @@ -523,7 +523,7 @@ def _pull_single_tag(self, image_name: str, quiet: bool, platform: str):
run(full_cmd, capture_stdout=quiet, capture_stderr=quiet)
return Image(self.client_config, image_name)

def push(self, x: Union[str, List[str]], quiet: bool = False, platform: str = ""):
def push(self, x: Union[str, List[str]], quiet: bool = False):
"""Push a tag or a repository to a registry
Alias: `docker.push(...)`
Expand All @@ -534,7 +534,6 @@ def push(self, x: Union[str, List[str]], quiet: bool = False, platform: str = ""
multiple threads. The progress bars might look strange as multiple
processes are drawing on the terminal at the same time.
quiet: If you don't want to see the progress bars.
platform: If you want to enforce a platform.
# Raises
`python_on_whales.exceptions.NoSuchImage` if one of the images does not exists.
Expand All @@ -547,27 +546,28 @@ def push(self, x: Union[str, List[str]], quiet: bool = False, platform: str = ""
if x == []:
return
elif len(x) == 1:
self._push_single_tag(x[0], quiet=quiet, platform=platform)
self._push_single_tag(x[0], quiet=quiet)
elif len(x) >= 2:
pool = ThreadPool(4)
generator = self._generate_args_push_pull(x, quiet, platform)
generator = self._generate_args_push(x, quiet)
pool.starmap(self._push_single_tag, generator)
pool.close()
pool.join()

def _generate_args_push_pull(self, _list: List[str], quiet: bool, platform: str):
def _generate_args_pull(self, _list: List[str], quiet: bool, platform: str):
for tag in _list:
yield tag, quiet, platform

def _generate_args_push(self, _list: List[str], quiet: bool):
for tag in _list:
yield tag, quiet

def _push_single_tag(self, tag_or_repo: str, quiet: bool, platform: str):
full_cmd = self.docker_cmd + ["image", "push"]

if quiet:
full_cmd.append("--quiet")

if platform:
full_cmd.append(f"--platform={platform}")

full_cmd.append(tag_or_repo)
run(full_cmd, capture_stdout=quiet, capture_stderr=quiet)

Expand Down

0 comments on commit 47ebe5a

Please sign in to comment.