Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79bccb6ec5 | ||
|
|
e7ec870159 | ||
|
|
62743cc3b2 | ||
|
|
7f8c776eb3 | ||
|
|
928afd6549 | ||
|
|
83b2e0196c | ||
|
|
4dbb6018ce | ||
|
|
1effa17117 | ||
|
|
92a07290e6 | ||
|
|
003f2538a8 | ||
|
|
4a8c58581c | ||
|
|
c9ad40709c | ||
|
|
7b5f878929 |
+179
@@ -0,0 +1,179 @@
|
||||
*~
|
||||
.\#*
|
||||
\#*\#
|
||||
.*.~undo-tree~
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/python
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=python
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
#poetry.lock
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
#pdm.lock
|
||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||
# in version control.
|
||||
# https://pdm.fming.dev/#use-with-ide
|
||||
.pdm.toml
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
### Python Patch ###
|
||||
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
|
||||
poetry.toml
|
||||
|
||||
# ruff
|
||||
.ruff_cache/
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/python
|
||||
|
||||
@@ -2,4 +2,8 @@
|
||||
** 0.1.0 <2023-06-18 Sun>
|
||||
First release
|
||||
Added the function that gets a list of repositories from a namespace.
|
||||
** 0.2.0 <2023-06-18 Sun>
|
||||
Added the function that gets a list of tags from a repository.
|
||||
** 0.3.0 <2023-06-18 Sun>
|
||||
Added the filter option for a list of tags.
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from rich.console import Console
|
||||
import typer
|
||||
from docker_tags_getter.cli.repos import repos
|
||||
from docker_tags_getter.cli.repo import repo
|
||||
|
||||
console = Console()
|
||||
cli_app = typer.Typer(rich_markup_mode="rich")
|
||||
cli_app.add_typer(repos, name="repos", help="Manage repos information")
|
||||
cli_app.add_typer(repo, name="repo", help="Manage repo information")
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
################################################################################
|
||||
# Copyright (C) 2023 Kostiantyn Klochko <kklochko@protonmail.com> #
|
||||
# #
|
||||
# This file is part of docker_tags_getter. #
|
||||
# #
|
||||
# docker_tags_getter is free software: you can redistribute it and/or modify #
|
||||
# it under the terms of the GNU Lesser General Public License as published by #
|
||||
# the Free Software Foundation, either version 3 of the License, or (at your #
|
||||
# option) any later version. #
|
||||
# #
|
||||
# docker_tags_getter is distributed in the hope that it will be useful, but #
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public #
|
||||
# License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU Lesser General Public License #
|
||||
#along with docker_tags_getter. If not, see <https://www.gnu.org/licenses/>. #
|
||||
################################################################################
|
||||
|
||||
from rich.console import Console
|
||||
from rich.prompt import Prompt
|
||||
from typing import List, Optional
|
||||
import typer
|
||||
|
||||
from docker_tags_getter.config.headers_config import HeadersConfig
|
||||
from docker_tags_getter.fetcher.api_fetcher import ApiFetcher
|
||||
from docker_tags_getter.filters.tags_filter import TagsFilter
|
||||
from docker_tags_getter.api.v2.repositories_api import RepositoriesAPI
|
||||
from docker_tags_getter.api.v2.tags_api import TagsAPI
|
||||
|
||||
console = Console()
|
||||
repo = typer.Typer()
|
||||
|
||||
@repo.command()
|
||||
def tags(
|
||||
namespace: str = typer.Option(
|
||||
None, "--namespace", "-ns",
|
||||
help="[b]The namespace[/] is a uniq identification of [b]a user or a organisation[/].",
|
||||
show_default=False
|
||||
),
|
||||
repository: str = typer.Option(
|
||||
None, "--repository", "-r",
|
||||
help="[b]The repository[/] is a uniq identification of [b]a project[/].",
|
||||
show_default=False
|
||||
),
|
||||
filter: bool = typer.Option(
|
||||
None, "--filter", "-f",
|
||||
help="[b]The tags[/] will be filtered.",
|
||||
show_default=False
|
||||
),
|
||||
):
|
||||
"""
|
||||
[green b]All tags[/] will be returned for the [yellow b]namespace[/].
|
||||
"""
|
||||
if namespace is None:
|
||||
console.print(f"[red b][ERROR] Please, give the namespace name!!![/]")
|
||||
return
|
||||
|
||||
if namespace is None:
|
||||
console.print(f"[red b][ERROR] Please, give the repository name!!![/]")
|
||||
return
|
||||
|
||||
headers_config = HeadersConfig()
|
||||
fetcher = ApiFetcher(headers_config)
|
||||
|
||||
tags_api = TagsAPI(fetcher, namespace, repository)
|
||||
|
||||
tags = tags_api.get_list()
|
||||
|
||||
if filter:
|
||||
if 'latest' in tags:
|
||||
tags.remove('latest')
|
||||
|
||||
tags_filter = TagsFilter()
|
||||
tags = tags_filter.filter_list(tags)
|
||||
|
||||
for tag in tags:
|
||||
console.print(tag)
|
||||
|
||||
@@ -42,6 +42,7 @@ def all(
|
||||
"""
|
||||
if namespace is None:
|
||||
console.print(f"[red b][ERROR] Please, give the namespace name!!![/]")
|
||||
return
|
||||
|
||||
headers_config = HeadersConfig()
|
||||
fetcher = ApiFetcher(headers_config)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import re
|
||||
|
||||
class TagsFilter:
|
||||
def __init__(self):
|
||||
self._pattern = r'-\D\w+'
|
||||
self.regexp = re.compile(self._pattern)
|
||||
|
||||
def check(self):
|
||||
return lambda tag: len(self.regexp.findall(tag)) == 0
|
||||
|
||||
def filter_list(self, tags: list):
|
||||
return list(filter(self.check(), tags))
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "docker-tags-getter"
|
||||
version = "0.1.0"
|
||||
version = "0.3.0"
|
||||
description = ""
|
||||
authors = ["Kostiantyn Klochko <kostya_klochko@ukr.net>"]
|
||||
readme = "README.rst"
|
||||
|
||||
Reference in New Issue
Block a user