From 8735924633321aeaeff1b1d574a3ea60823674c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= Date: Wed, 5 Jun 2024 06:54:17 -0400 Subject: [PATCH 1/5] Handle renovate comments for dockerfile ARG --- .automation/build.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.automation/build.py b/.automation/build.py index a3e42b578d0..a26d43e4086 100644 --- a/.automation/build.py +++ b/.automation/build.py @@ -327,7 +327,11 @@ def build_dockerfile( ) docker_from += [dockerfile_item] # ARG - elif dockerfile_item.startswith("ARG"): + elif dockerfile_item.startswith("ARG") or ( + len(dockerfile_item.splitlines()) > 1 + and dockerfile_item.splitlines()[0].startswith("# renovate: ") + and dockerfile_item.splitlines()[0].startswith("ARG") + ): docker_arg += [dockerfile_item] # COPY elif dockerfile_item.startswith("COPY"): From 9dcebfd8faca27f4c75aa7c658f6da86d932fd5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= Date: Wed, 5 Jun 2024 06:54:32 -0400 Subject: [PATCH 2/5] Handle renovate comment when separating ARGs used in FROM instructions from others --- .automation/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.automation/build.py b/.automation/build.py index a26d43e4086..6458be13437 100644 --- a/.automation/build.py +++ b/.automation/build.py @@ -427,7 +427,7 @@ def build_dockerfile( docker_arg_top = [] docker_arg_main = [] for docker_arg_item in docker_arg: - match = re.match(r"ARG\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*=?\s*", docker_arg_item) + match = re.match(r"(?:# renovate: .*\n)?ARG\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*=?\s*", docker_arg_item) arg_name = match.group(1) if arg_name in all_from_instructions: docker_arg_top += [docker_arg_item] From 9f871a285ed36962cb7f97e07ff2d61953ade964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= Date: Wed, 5 Jun 2024 06:54:40 -0400 Subject: [PATCH 3/5] [MegaLinter] Apply linters fixes --- .automation/build.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.automation/build.py b/.automation/build.py index 6458be13437..7ab78925048 100644 --- a/.automation/build.py +++ b/.automation/build.py @@ -427,7 +427,10 @@ def build_dockerfile( docker_arg_top = [] docker_arg_main = [] for docker_arg_item in docker_arg: - match = re.match(r"(?:# renovate: .*\n)?ARG\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*=?\s*", docker_arg_item) + match = re.match( + r"(?:# renovate: .*\n)?ARG\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*=?\s*", + docker_arg_item, + ) arg_name = match.group(1) if arg_name in all_from_instructions: docker_arg_top += [docker_arg_item] From 3ca3cf54f2aaf7b885195a14e7dc3f8165081604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= Date: Wed, 5 Jun 2024 06:54:48 -0400 Subject: [PATCH 4/5] Handle second line of ARG --- .automation/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.automation/build.py b/.automation/build.py index 7ab78925048..801457402e1 100644 --- a/.automation/build.py +++ b/.automation/build.py @@ -330,7 +330,7 @@ def build_dockerfile( elif dockerfile_item.startswith("ARG") or ( len(dockerfile_item.splitlines()) > 1 and dockerfile_item.splitlines()[0].startswith("# renovate: ") - and dockerfile_item.splitlines()[0].startswith("ARG") + and dockerfile_item.splitlines()[1].startswith("ARG") ): docker_arg += [dockerfile_item] # COPY From 4d34cd7a937a9d8ef7ff10ab3cd45bbbbb70f0f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Thu, 6 Jun 2024 19:56:57 -0400 Subject: [PATCH 5/5] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28cd1716026..b8aa5456ff1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-linter.yml file, or with `oxsecurity/megalinter:beta` docker image - Core + - Handle renovate version comments in build script - Media