VedarthConfluent commented on code in PR #16027:
URL: https://github.com/apache/kafka/pull/16027#discussion_r1611077695


##########
docker/generate_kafka_pr_template.py:
##########
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+Python script to prepare the PR template for the docker official image
+This script is used to prepare the PR template for the docker official image
+
+Usage:
+    Example command:-
+        generate_kafka_pr_template.py --help
+        Get detailed description of each option
+
+        generate_kafka_pr_template.py --image-type <image_type>
+
+        This command will build a PR template for <image_type> as image type 
(jvm by default) based docker official image,
+        on the directories present under docker/docker_official_images.
+        This PR template will be used to raise a PR in the Docker Official 
Images Repo.
+"""
+
+import os
+import subprocess
+import sys
+import argparse
+from pathlib import Path
+
+
+# Returns the current branch from which the script is being run
+def get_current_branch():
+    return subprocess.check_output(["git", "rev-parse", "--abbrev-ref", 
"HEAD"]).strip().decode('utf-8')
+
+
+# Returns the hash of the most recent commit that modified any of the 
specified files.
+def file_commit(*files):
+    return subprocess.check_output(["git", "log", "-1", "--format=format:%H", 
"HEAD", "--"] + list(files)).strip().decode('utf-8')
+
+
+# Returns the latest commit hash for all files in a given directory.
+def dir_commit(directory):
+    docker_required_scripts = [str(path) for path in 
Path(directory).rglob('*') if path.is_file()]
+    files_to_check = [os.path.join(directory, "Dockerfile")] + 
docker_required_scripts
+    return file_commit(*files_to_check)
+
+
+# Split the version string into parts and convert them to integers for version 
comparision
+def get_version_parts(version):
+    return tuple(int(part) for part in version.name.split('.'))
+
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument("--image-type", "-type", choices=[
+                        "jvm"], default="jvm", dest="image_type", help="Image 
type you want to build")
+    args = parser.parse_args()
+    if get_current_branch() != "trunk":

Review Comment:
   Not needed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to