Compare commits

..
20 Commits
Author SHA1 Message Date
KKlochko cd7f896c7d Add docker-tags-getter and docker_tags_getter as command names.
continuous-integration/drone/push Build is passing
2023-06-21 10:36:28 +03:00
KKlochko f4080a4b95 Add an option to show the tag full name (namespace/repository:tag). 2023-06-21 10:33:40 +03:00
KKlochko 8ac62992f9 Fix the error in README.rst.
continuous-integration/drone/push Build is passing
2023-06-19 10:20:46 +03:00
KKlochko 8e771728c4 Update the description.
continuous-integration/drone/push Build is failing
2023-06-19 10:05:27 +03:00
KKlochko b8be14da88 Add the CI/CD configuration and tests.
continuous-integration/drone/push Build is failing
2023-06-19 09:58:09 +03:00
KKlochko 75358b59dd Add the filter test for architectures tags. 2023-06-19 09:48:34 +03:00
KKlochko e608a98743 Add the pytest. 2023-06-19 09:47:59 +03:00
KKlochko 79bccb6ec5 Added the filter option for a list of tags. 2023-06-18 22:48:13 +03:00
KKlochko e7ec870159 Add a filter for tags. 2023-06-18 22:44:46 +03:00
KKlochko 62743cc3b2 Fix showing only error messages. 2023-06-18 22:00:59 +03:00
KKlochko 7f8c776eb3 Add the function that gets a list of tags from a repository. 2023-06-18 21:49:12 +03:00
KKlochko 928afd6549 Add the CHANGELOG file. 2023-06-18 21:47:02 +03:00
KKlochko 83b2e0196c Add the .gitignore file. 2023-06-18 21:46:39 +03:00
KKlochko 4dbb6018ce Add the function that gets a list of repositories from a namespace. 2023-06-18 21:45:58 +03:00
KKlochko 1effa17117 Add the API handler for repositories' tags. 2023-06-18 21:44:23 +03:00
KKlochko 92a07290e6 Add the license, LGPLv3. 2023-06-18 21:43:33 +03:00
KKlochko 003f2538a8 Add the headers config. 2023-06-18 21:42:03 +03:00
KKlochko 4a8c58581c Update project information. 2023-06-18 09:48:43 +03:00
KKlochko c9ad40709c Add the API handler for repositories. 2023-06-18 09:47:32 +03:00
KKlochko 7b5f878929 Add the API fetcher. 2023-06-18 09:46:47 +03:00
14 changed files with 449 additions and 4 deletions
+30
View File
@@ -0,0 +1,30 @@
kind: pipeline
type: docker
name: default
steps:
- name: run tests
image: python:3.10-alpine
commands:
- export POETRY_HOME=/opt/poetry
- python3 -m venv $POETRY_HOME
- $POETRY_HOME/bin/pip install poetry==1.3.2
- $POETRY_HOME/bin/poetry install
- $POETRY_HOME/bin/poetry run pytest -s
- name: publishing
image: python:3.10-alpine
environment:
PYPI_USERNAME:
from_secret: PYPI_USERNAME
PYPI_PASSWORD:
from_secret: PYPI_PASSWORD
commands:
- export POETRY_HOME=/opt/poetry
- python3 -m venv $POETRY_HOME
- $POETRY_HOME/bin/pip install poetry==1.3.2
- $POETRY_HOME/bin/poetry install
- $POETRY_HOME/bin/poetry publish --build --username $PYPI_USERNAME --password $PYPI_PASSWORD
when:
branch:
- main
+179
View File
@@ -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
+10
View File
@@ -2,4 +2,14 @@
** 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.
** 0.3.1 <2023-06-19 Mon>
Added the CI/CD configuration and tests.
** 0.3.2 <2023-06-19 Mon>
Updated the description.
** 0.3.3 <2023-06-19 Mon>
Fixed the error in README.rst.
+1 -1
View File
@@ -1,5 +1,5 @@
docker_tags_getter
=========
==================
docker_tags_getter is the application that will help you to get tags from yours docker repository.
+2
View File
@@ -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")
+88
View File
@@ -0,0 +1,88 @@
################################################################################
# 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
),
full_name: bool = typer.Option(
None, "--full-name", "-fn",
help="[b]The tags[/] will be shown with their [b]namespace and repository[/].",
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)
prefix = ''
if full_name:
prefix = f'{namespace}/{repository}:'
for tag in tags:
console.print(f'{prefix}{tag}')
+1
View File
@@ -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)
+13
View File
@@ -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))
Generated
+91 -1
View File
@@ -124,6 +124,21 @@ files = [
{file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
]
[[package]]
name = "exceptiongroup"
version = "1.1.1"
description = "Backport of PEP 654 (exception groups)"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
{file = "exceptiongroup-1.1.1-py3-none-any.whl", hash = "sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e"},
{file = "exceptiongroup-1.1.1.tar.gz", hash = "sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785"},
]
[package.extras]
test = ["pytest (>=6)"]
[[package]]
name = "idna"
version = "3.4"
@@ -136,6 +151,18 @@ files = [
{file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"},
]
[[package]]
name = "iniconfig"
version = "2.0.0"
description = "brain-dead simple config-ini parsing"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
{file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"},
{file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"},
]
[[package]]
name = "markdown-it-py"
version = "3.0.0"
@@ -173,6 +200,34 @@ files = [
{file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"},
]
[[package]]
name = "packaging"
version = "23.1"
description = "Core utilities for Python packages"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
{file = "packaging-23.1-py3-none-any.whl", hash = "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61"},
{file = "packaging-23.1.tar.gz", hash = "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"},
]
[[package]]
name = "pluggy"
version = "1.0.0"
description = "plugin and hook calling mechanisms for python"
category = "dev"
optional = false
python-versions = ">=3.6"
files = [
{file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"},
{file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"},
]
[package.extras]
dev = ["pre-commit", "tox"]
testing = ["pytest", "pytest-benchmark"]
[[package]]
name = "pygments"
version = "2.15.1"
@@ -188,6 +243,29 @@ files = [
[package.extras]
plugins = ["importlib-metadata"]
[[package]]
name = "pytest"
version = "7.3.2"
description = "pytest: simple powerful testing with Python"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
{file = "pytest-7.3.2-py3-none-any.whl", hash = "sha256:cdcbd012c9312258922f8cd3f1b62a6580fdced17db6014896053d47cddf9295"},
{file = "pytest-7.3.2.tar.gz", hash = "sha256:ee990a3cc55ba808b80795a79944756f315c67c12b56abd3ac993a7b8c17030b"},
]
[package.dependencies]
colorama = {version = "*", markers = "sys_platform == \"win32\""}
exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""}
iniconfig = "*"
packaging = "*"
pluggy = ">=0.12,<2.0"
tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""}
[package.extras]
testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
[[package]]
name = "requests"
version = "2.31.0"
@@ -229,6 +307,18 @@ pygments = ">=2.13.0,<3.0.0"
[package.extras]
jupyter = ["ipywidgets (>=7.5.1,<9)"]
[[package]]
name = "tomli"
version = "2.0.1"
description = "A lil' TOML parser"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
]
[[package]]
name = "typer"
version = "0.9.0"
@@ -284,4 +374,4 @@ zstd = ["zstandard (>=0.18.0)"]
[metadata]
lock-version = "2.0"
python-versions = "^3.9"
content-hash = "9a11dcaec82f8878f39d103439a0655df2a47c50cd984889e8897b65140ef23d"
content-hash = "7ceb8c42d937b3942cbda1632636bdf5a742914ce255fb2e6252effc2b54445c"
+7 -2
View File
@@ -1,7 +1,7 @@
[tool.poetry]
name = "docker-tags-getter"
version = "0.1.0"
description = ""
version = "0.3.5"
description = "docker_tags_getter will help you to get tags from your docker repository."
authors = ["Kostiantyn Klochko <kostya_klochko@ukr.net>"]
readme = "README.rst"
license = "LGPL-3.0-or-later"
@@ -20,6 +20,11 @@ requests = "^2.31.0"
[tool.poetry.scripts]
dtg = "docker_tags_getter.main:main"
docker_tags_getter = "docker_tags_getter.main:main"
docker-tags-getter = "docker_tags_getter.main:main"
[tool.poetry.group.dev.dependencies]
pytest = "^7.3.2"
[build-system]
requires = ["poetry-core"]
View File
+14
View File
@@ -0,0 +1,14 @@
import pytest
@pytest.fixture
def tags_architectures():
def get_architectures_tags():
tags = [
"8.0.33-25.1",
"8.0.33-25.1-aarch64",
"8.0.33-25.1-multi"
]
return tags
return get_architectures_tags
+13
View File
@@ -0,0 +1,13 @@
import pytest
from docker_tags_getter.filters.tags_filter import TagsFilter
def test_filter_architectures(tags_architectures):
tags = tags_architectures()
tags_filter = TagsFilter()
assert 3 == len(tags)
tags = tags_filter.filter_list(tags)
assert 1 == len(tags)