Skip to content

Commit

Permalink
Fix the regex to match image in koparse
Browse files Browse the repository at this point in the history
The regex to parse images does not include '/' after the base
registry. It does not take in account the possible tag before
the sha.

Changing the regex and updating tests accordingly.

Signed-off-by: Andrea Frittoli <[email protected]>
  • Loading branch information
afrittoli committed Oct 22, 2020
1 parent 7e376a0 commit 2bf3670
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tekton/koparse/koparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def parse_release(base: str, path: str) -> List[str]:
list of the images parsed from the file
"""
images = []
pattern = re.compile(base + r"[0-9a-z\-]+" + DIGEST_MARKER + r":[0-9a-f]*")
pattern = re.compile(base + r"[0-9a-z\-/]+(?::[0-9a-z]+)?" + DIGEST_MARKER + r":[0-9a-f]+")
with open(path) as f:
for line in f:
found = re.findall(pattern, line)
Expand Down
4 changes: 2 additions & 2 deletions tekton/koparse/test_koparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
PATH_TO_WRONG_FILE = os.path.join(os.path.dirname(
os.path.abspath(__file__)), "koparse.py")
BUILT_IMAGES = [
"gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/kubeconfigwriter@sha256:68453f5bb4b76c0eab98964754114d4f79d3a50413872520d8919a6786ea2b35",
"gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/kubeconfigwriter:withtag@sha256:68453f5bb4b76c0eab98964754114d4f79d3a50413872520d8919a6786ea2b35",
"gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/creds-init@sha256:67448da79e4731ab534b91df08da547bc434ab08e41d905858f2244e70290f48",
"gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init@sha256:7d5520efa2d55e1346c424797988c541327ee52ef810a840b5c6f278a9de934a",
"gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/controller@sha256:bdc6f22a44944c829983c30213091b60f490b41f89577e8492f6a2936be0df41",
"gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/webhook@sha256:cca7069a11aaf0d9d214306d456bc40b2e33e5839429bf07c123ad964d495d8a",
]
EXPECTED_IMAGES = [
"gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/kubeconfigwriter",
"gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/kubeconfigwriter:withtag",
"gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/creds-init",
"gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init",
"gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/controller",
Expand Down
2 changes: 1 addition & 1 deletion tekton/koparse/test_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ spec:
"-logtostderr",
"-stderrthreshold",
"INFO",
"-kubeconfig-writer-image", "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/kubeconfigwriter@sha256:68453f5bb4b76c0eab98964754114d4f79d3a50413872520d8919a6786ea2b35", "-creds-ige", "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/creds-init@sha256:67448da79e4731ab534b91df08da547bc434ab08e41d905858f2244e70290f48",
"-kubeconfig-writer-image", "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/kubeconfigwriter:withtag@sha256:68453f5bb4b76c0eab98964754114d4f79d3a50413872520d8919a6786ea2b35", "-creds-ige", "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/creds-init@sha256:67448da79e4731ab534b91df08da547bc434ab08e41d905858f2244e70290f48",
"-git-image",
"gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init@sha256:7d5520efa2d55e1346c424797988c541327ee52ef810a840b5c6f278a9de934a",
]
Expand Down

0 comments on commit 2bf3670

Please sign in to comment.