Skip to content

Commit 6f25221

Browse files
committed
update for lscr.io
1 parent 1b02f98 commit 6f25221

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

glpi_docker_update_report.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,18 @@ def update(self):
309309
)
310310

311311

312+
class LscrImage(GhcrImage):
313+
314+
BASE_URL = "https://hub.linuxserver.io/v2"
315+
316+
@property
317+
def link(self) -> str:
318+
return f'https://docs.linuxserver.io/images/docker-{self.repository}/'
319+
320+
def link_for_tag(self, tag: str) -> str:
321+
return f'https://github.com/{self.namespace}/docker-{self.repository}/releases/tag/{tag}'
322+
323+
312324
class GcrImage(Image):
313325

314326
def update(self):
@@ -325,6 +337,9 @@ def get_image(name: str) -> Image:
325337
if name.startswith('gcr.io/'):
326338
cls = GcrImage
327339
name = name[7:]
340+
if name.startswith('lscr.io/'):
341+
cls = LscrImage
342+
name = name[8:]
328343
if '/' in name:
329344
try:
330345
namespace, repository = name.split('/')
@@ -525,7 +540,7 @@ def _send_email(self, html: str) -> None:
525540
logger.info('EMail sent.')
526541
s.quit()
527542

528-
def run(self, html_file_only: bool = False, skip_names: List[str] = []):
543+
def run(self, html_file_only: bool = False, skip_names: List[str] = [], skip_images: List[str] = []):
529544
if not html_file_only:
530545
email_vars = [
531546
"SMTP_HOST", "SMTP_USER", "SMTP_PASSWORD", "EMAIL_ADDR"
@@ -550,6 +565,9 @@ def run(self, html_file_only: bool = False, skip_names: List[str] = []):
550565
img: Image
551566
rows: List[Dict] = []
552567
for img in sorted(self.images.values(), key=lambda x: x.name):
568+
if img.name in skip_images:
569+
logger.info('Skipping image: %s', img.name)
570+
continue
553571
img.update()
554572
rows.extend(self._rows_for_image(img))
555573
html = self._generate_html(rows, skip_names)
@@ -747,6 +765,10 @@ def parse_args(argv):
747765
default=[], help='Skip these computer names (can be specified '
748766
'multiple times)'
749767
)
768+
p.add_argument(
769+
'-I', '--skip-image', dest='skip_images', action='append',
770+
default=[], help='Skip these image names (can be specified multiple times)'
771+
)
750772
args = p.parse_args(argv)
751773
return args
752774

@@ -786,4 +808,8 @@ def set_log_level_format(lgr: logging.Logger, level: int, fmt: str):
786808
else:
787809
set_log_info(logger)
788810

789-
GlpiDockerReport().run(html_file_only=args.html, skip_names=args.skip_names)
811+
GlpiDockerReport().run(
812+
html_file_only=args.html,
813+
skip_names=args.skip_names,
814+
skip_images=args.skip_images
815+
)

0 commit comments

Comments
 (0)