Skip to content

Commit

Permalink
feat(cli): tag imge with latest when dowloaded with --latest option
Browse files Browse the repository at this point in the history
  • Loading branch information
titom73 committed Mar 20, 2024
1 parent 101fdf2 commit f58ca47
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion eos_downloader/cli/get/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def eos(
console = Console()
# Get from Context
token = ctx.obj["token"]
is_latest: bool = False
if token is None or token == "":
console.print(
"❗ Token is unset ! Please configure ARISTA_TOKEN or use --token option",
Expand Down Expand Up @@ -156,6 +157,7 @@ def eos(
my_download.authenticate()

elif latest:
is_latest = True
my_download = eos_downloader.eos.EOSDownloader(
image=image_type,
software="EOS",
Expand All @@ -180,7 +182,7 @@ def eos(
my_download.download_local(file_path=output, checksum=True)

if import_docker:
my_download.docker_import(image_name=docker_name)
my_download.docker_import(image_name=docker_name, is_latest=is_latest)
console.print("✅ processing done !")
sys.exit(0)

Expand Down
7 changes: 6 additions & 1 deletion eos_downloader/object_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,9 @@ def provision_eve(self, noztp: bool = False, checksum: bool = True) -> None:
if noztp:
self._disable_ztp(file_path=file_path)

def docker_import(self, image_name: str = "arista/ceos") -> None:
def docker_import(
self, image_name: str = "arista/ceos", is_latest: bool = False
) -> None:
"""
Import docker container to your docker server.
Expand All @@ -561,6 +563,9 @@ def docker_import(self, image_name: str = "arista/ceos") -> None:
logger.info(f"Importing image {self.filename} to {docker_image}")
console.print(f"🚀 Importing image {self.filename} to {docker_image}")
os.system(f"$(which docker) import {self.filename} {docker_image}")
if is_latest:
console.print(f"🚀 Configuring {docker_image}:{self.version} to be latest")
os.system(f"$(which docker) tag {docker_image} {image_name}:latest")
for filename in glob.glob(f"{self.filename}*"):
try:
os.remove(filename)
Expand Down

0 comments on commit f58ca47

Please sign in to comment.