Skip to content
This repository was archived by the owner on Jul 28, 2023. It is now read-only.

Commit 104bb14

Browse files
authored
Merge pull request #340 from groeges/release-0.9-codewind
Add support for deprecated stack to codewind index generation
2 parents b82d65d + 4971516 commit 104bb14

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

ci/create_codewind_index.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@
44
import json
55
import os
66
import fnmatch
7-
import sys
87
from collections import OrderedDict
8+
import argparse
9+
from argparse import ArgumentDefaultsHelpFormatter
910

10-
base_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
11+
parser = argparse.ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
1112

12-
displayNamePrefix = "Appsody"
13-
if len(sys.argv) > 1:
14-
displayNamePrefix = sys.argv[1]
13+
parser.add_argument("-n", "--namePrefix", help="Display name prefix.", default="Appsody")
14+
parser.add_argument("-f", "--file", help="Absolute or relative path, to a yaml file or directory of yaml files.", default=os.getcwd())
1515

16-
# directory to store assets for test or release
17-
assets_dir = base_dir + "/assets/"
16+
args = parser.parse_args()
1817

19-
for file in os.listdir(assets_dir):
20-
if fnmatch.fnmatch(file, '*index.yaml'):
21-
with open(assets_dir + file, 'r') as yamlFile, open(assets_dir + os.path.splitext(file)[0] + ".json", 'wb') as jsonFile:
18+
displayNamePrefix = args.namePrefix
19+
20+
yaml_dir = os.path.normpath(args.file)
21+
22+
def generate_json():
23+
with open(inputFile, 'r') as yamlFile, open(inputFile.rsplit('.', 1)[0] + ".json", 'wb') as jsonFile:
2224
try:
2325
doc = yaml.safe_load(yamlFile)
2426
list = []
@@ -32,7 +34,7 @@
3234
template = ""
3335
else:
3436
template = " " + item['templates'][n]['id']
35-
37+
3638
# populate stack details
3739
res = (OrderedDict([
3840
("displayName", displayNamePrefix + " " + item['name'] + template + " template"),
@@ -46,10 +48,23 @@
4648
item['id'] + "/devfile.yaml")
4749
]))
4850
]))
51+
52+
if ('deprecated' in item):
53+
res.update([("displayName", "[Deprecated] " + displayNamePrefix + " " + item['name'] + template + " template"),
54+
("deprecated", item['deprecated'])])
55+
4956
list.append(res)
5057

5158
jsonFile.write(json.dumps(list, indent=4, ensure_ascii=False).encode('utf8'))
52-
print("Generated: " + os.path.splitext(file)[0] + ".json")
53-
59+
print("Generated: " + inputFile.rsplit('.', 1)[0] + ".json")
5460
except yaml.YAMLError as exc:
5561
print(exc)
62+
63+
if os.path.isdir(yaml_dir):
64+
for file in os.listdir(yaml_dir):
65+
if fnmatch.fnmatch(file, '*.yaml'):
66+
inputFile = yaml_dir + "/" + file
67+
generate_json()
68+
else:
69+
inputFile = yaml_dir
70+
generate_json()

ci/package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ done
202202
exec_hooks $script_dir/ext/post_package.d
203203

204204
if [ "$CODEWIND_INDEX" == "true" ]; then
205-
python3 $script_dir/create_codewind_index.py $DISPLAY_NAME_PREFIX
205+
python3 $script_dir/create_codewind_index.py -n $DISPLAY_NAME_PREFIX -f $assets_dir
206206

207207
# iterate over each repo
208208
for codewind_file in $assets_dir/*.json

0 commit comments

Comments
 (0)