19
Python script to prepare the PR template for the docker official image
20
This script is used to prepare the PR template for the docker official image
24
generate_kafka_pr_template.py --help
25
Get detailed description of each option
27
generate_kafka_pr_template.py --image-type <image_type>
29
This command will build a PR template for <image_type> as image type (jvm by default) based docker official image,
30
on the directories present under docker/docker_official_images.
31
This PR template will be used to raise a PR in the Docker Official Images Repo.
38
from pathlib import Path
42
def file_commit(*files):
43
return subprocess.check_output(["git", "log", "-1", "--format=format:%H", "HEAD", "--"] + list(files)).strip().decode('utf-8')
47
def dir_commit(directory):
48
docker_required_scripts = [str(path) for path in Path(directory).rglob('*') if path.is_file()]
49
files_to_check = [os.path.join(directory, "Dockerfile")] + docker_required_scripts
50
return file_commit(*files_to_check)
54
def get_version_parts(version):
55
return tuple(int(part) for part in version.name.split('.'))
59
parser = argparse.ArgumentParser()
60
parser.add_argument("--image-type", "-type", choices=[
61
"jvm"], default="jvm", dest="image_type", help="Image type you want to build")
62
args = parser.parse_args()
63
self = os.path.basename(__file__)
64
current_dir = os.path.dirname(os.path.abspath(__file__))
65
docker_official_images_dir = Path(os.path.join(current_dir, "docker_official_images"))
69
# This file is generated via https://github.com/apache/kafka/blob/{file_commit(os.path.join(current_dir, self))}/docker/generate_kafka_pr_template.py
70
Maintainers: The Apache Kafka Project <dev@kafka.apache.org> (@ApacheKafka)
71
GitRepo: https://github.com/apache/kafka.git
74
versions = sorted((d for d in docker_official_images_dir.iterdir() if d.is_dir()), key=get_version_parts, reverse=True)
75
highest_version = max(versions).name if versions else ""
79
tags = version + (", latest" if version == highest_version else "")
80
commit = dir_commit(dir.joinpath(args.image_type))
84
Architectures: amd64,arm64v8
86
Directory: ./docker/docker_official_images/{version}/{args.image_type}
88
print(info.strip(), '\n')
91
if __name__ == "__main__":