-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from nutanix/task/cicd-pipeline-using-github-a…
…ctions Cicd pipeline using GitHub actions
- Loading branch information
Showing
14 changed files
with
478 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,41 @@ | ||
import json | ||
|
||
|
||
def generate_spec(data, variable_name='', default={}): | ||
def generate_spec(data, variable_name="", default={}): | ||
is_list = False | ||
if 'additionalProperties' in data.keys(): | ||
data = data['additionalProperties'] | ||
if 'items' in data.keys(): | ||
data = data['items'] | ||
if "additionalProperties" in data.keys(): | ||
data = data["additionalProperties"] | ||
if "items" in data.keys(): | ||
data = data["items"] | ||
is_list = True | ||
if 'properties' in data.keys(): | ||
data = data['properties'] | ||
elif 'type' in data.keys() and data['type'] in ['string', 'integer', 'boolean']: | ||
return '{{' + variable_name + '}}' | ||
if "properties" in data.keys(): | ||
data = data["properties"] | ||
elif "type" in data.keys() and data["type"] in ["string", "integer", "boolean"]: | ||
return "{{" + variable_name + "}}" | ||
for k, v in data.items(): | ||
data[k] = generate_spec(v, variable_name + '__' + str(k) if variable_name else str(k)) | ||
data[k] = generate_spec( | ||
v, variable_name + "__" + str(k) if variable_name else str(k) | ||
) | ||
if is_list: | ||
data.update({'list_key': variable_name}) | ||
data.update({"list_key": variable_name}) | ||
return [data] | ||
return data | ||
|
||
|
||
def parse_json_to_spec(json_files_dir='', spec_files_dir=''): | ||
def parse_json_to_spec(json_files_dir="", spec_files_dir=""): | ||
import glob | ||
import os | ||
print(glob.glob(json_files_dir + '*json.json')) | ||
files = glob.glob(json_files_dir + '*json.json') | ||
|
||
print(glob.glob(json_files_dir + "*json.json")) | ||
files = glob.glob(json_files_dir + "*json.json") | ||
for file in files: | ||
file_name = spec_files_dir + os.path.splitext(file)[0] | ||
|
||
with open(file) as f: | ||
data = json.loads(f.read()) | ||
print('--------------------------------') | ||
print("--------------------------------") | ||
spec = generate_spec(data) | ||
with open(file_name + "_spec.json", 'w') as spec_file: | ||
with open(file_name + "_spec.json", "w") as spec_file: | ||
spec_file.write(json.dumps(spec)) | ||
print(json.dumps(spec, indent=4)) | ||
return spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.