mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-14 13:32:56 +00:00
Apply tags from the python
This commit is contained in:
39
tagging/taggers.py
Normal file
39
tagging/taggers.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
from tagger_interface import TaggerInterface
|
||||
from git_helper import GitHelper
|
||||
from plumbum.cmd import docker
|
||||
|
||||
|
||||
def _get_full_name(short_image_name, owner):
|
||||
return f"{owner}/{short_image_name}:latest"
|
||||
|
||||
|
||||
def _get_program_version(short_image_name, owner, program):
|
||||
return docker[
|
||||
"run",
|
||||
"--rm",
|
||||
"-a", "STDOUT",
|
||||
_get_full_name(short_image_name, owner),
|
||||
program, "--version"
|
||||
]().strip()
|
||||
|
||||
|
||||
class SHATagger(TaggerInterface):
|
||||
@staticmethod
|
||||
def tag_value(short_image_name, owner):
|
||||
return GitHelper.commit_hash()[:12]
|
||||
|
||||
@staticmethod
|
||||
def tag_name():
|
||||
return "git_sha"
|
||||
|
||||
|
||||
class PythonVersionTagger(TaggerInterface):
|
||||
@staticmethod
|
||||
def tag_value(short_image_name, owner):
|
||||
return "python-" + _get_program_version(short_image_name, owner, "python").split()[1]
|
||||
|
||||
@staticmethod
|
||||
def tag_name():
|
||||
return "python_version"
|
Reference in New Issue
Block a user