Skip to content

Commit 33d6a60

Browse files
committed
Show all imagestreams in imagestream file
New Python function is created so the imagestreams are shown always. This fixes PR #256 Signed-off-by: Petr "Stone" Hracek <[email protected]>
1 parent 741a503 commit 33d6a60

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

show_all_imagestreams.py

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/env python3
2+
3+
# MIT License
4+
#
5+
# Copyright (c) 2018-2019 Red Hat, Inc.
6+
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
# SOFTWARE.
24+
25+
import json
26+
import os
27+
28+
from pathlib import Path
29+
from typing import Dict, Any
30+
31+
IMAGESTREAMS_DIR: str = "imagestreams"
32+
33+
34+
class ShowAllImageStreams(object):
35+
version: str = ""
36+
37+
def __init__(self):
38+
pass
39+
40+
def load_json_file(self, filename: Path) -> Any:
41+
with open(str(filename)) as f:
42+
data = json.load(f)
43+
isinstance(data, Dict)
44+
return data
45+
46+
def show_all_imagestreams(self):
47+
p = Path(".")
48+
json_files = p.glob(f"{IMAGESTREAMS_DIR}/*.json")
49+
if not json_files:
50+
print(f"No json files present in {IMAGESTREAMS_DIR}.")
51+
return 0
52+
for f in json_files:
53+
if os.environ.get("TARGET") in ("rhel7", "centos7") and "aarch64" in str(f):
54+
print("Imagestream aarch64 is not supported on rhel7")
55+
continue
56+
json_dict = self.load_json_file(f)
57+
print(f"Tags in the image stream {f}:")
58+
for tag in json_dict["spec"]["tags"]:
59+
print(f"- {tag['name']} -> {tag['from']['name']}")
60+
61+
62+
if __name__ == "__main__":
63+
isc = ShowAllImageStreams()
64+
isc.show_all_imagestreams()

test-lib.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,7 @@ ct_check_image_availability() {
11261126
fi
11271127
}
11281128

1129+
11291130
# ct_check_latest_imagestreams
11301131
# -----------------------------
11311132
# Check if the latest version present in Makefile in the variable VERSIONS
@@ -1147,9 +1148,11 @@ ct_check_latest_imagestreams() {
11471148
[ -f "$latest_version/.exclude-$OS" ] && latest_version=$(grep '^VERSIONS' Makefile | rev | cut -d ' ' -f 2 | rev )
11481149
# Only test the imagestream once, when the version matches
11491150
# ignore the SC warning, $VERSION is always available
1151+
1152+
test_lib_dir=$(dirname "$(readlink -f "$0")")
1153+
python3 "${test_lib_dir}/show_all_imagestreams.py"
11501154
# shellcheck disable=SC2153
11511155
if [ "$latest_version" == "$VERSION" ]; then
1152-
test_lib_dir=$(dirname "$(readlink -f "$0")")
11531156
python3 "${test_lib_dir}/check_imagestreams.py" "$latest_version"
11541157
else
11551158
echo "Image version $VERSION is not latest, skipping ct_check_latest_imagestreams"

tests/check_imagestreams.sh

+5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
set -x
44

55
check_imagestreams=$(dirname "$(readlink -f "$0")")/../check_imagestreams.py
6+
show_all_imagestreams=$(dirname "$(readlink -f "$0")")/../show_all_imagestreams.py
67
"${PYTHON-python3}" "$check_imagestreams" "2.5"
78
test $? -eq 1
89
"${PYTHON-python3}" "$check_imagestreams" "2.4"
910
test $? -eq 0
11+
echo "Check full is output"
12+
output=$("${PYTHON-python3}" "$show_all_imagestreams")
13+
test "${output#*"- latest -> 2.4"}" != "$output" && echo "latest found in the output"
14+
test "${output#*"- 2.4 -> registry.redhat.io/rhscl/httpd-24-rhel7"}" != "$output" && echo "2.4 found in the output"

0 commit comments

Comments
 (0)