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

stacks: generated index.json for CodeWind #163

Merged
merged 24 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ if [ -z $STACKS_LIST ]; then
. $base_dir/ci/list.sh $base_dir
fi
. $base_dir/ci/package.sh $base_dir
. $base_dir/ci/test.sh $base_dir
. $base_dir/ci/test.sh $base_dir

python $base_dir/ci/create_codewind_index.py $base_dir
51 changes: 51 additions & 0 deletions ci/create_codewind_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python

import yaml
import json
import os
import fnmatch
import sys
from collections import OrderedDict

base_dir = os.path.abspath(os.path.dirname(sys.argv[0]))

# directory to store assets for test or release
assets_dir = base_dir + "/assets/"

for file in os.listdir(assets_dir):
if fnmatch.fnmatch(file, '*index.yaml'):
with open(assets_dir + file, 'r') as yamlFile, open(assets_dir + os.path.splitext(file)[0] + ".json", 'w') as jsonFile:
try:
doc = yaml.safe_load(yamlFile)
list = []

if (doc['stacks'] != None):
for item in doc['stacks']:

# get template name
for n in range(0, len(item['templates'])):
if len(item['templates'])==1:
template = ""
else:
template = " " + item['templates'][n]['id']

# populate stack details
res = (OrderedDict([
("displayName", "Appsody " + item['name'] + template + " template"),
("description", item['description']),
("language", ""),
("projectType", "appsodyExtension"),
("projectStyle", "Appsody"),
("location", item['templates'][n]['url']),
("links", OrderedDict([
("self", "/devfiles/" +
item['id'] + "/devfile.yaml")
]))
]))
list.append(res)

jsonFile.write(json.dumps(list, indent=4, ensure_ascii=False).encode('utf8'))
print("Generated: " + os.path.splitext(file)[0] + ".json")

except yaml.YAMLError as exc:
print(exc)