-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CICD: json files should be strictly formatted (#3282)
- Loading branch information
1 parent
2c2d7a1
commit 513b8be
Showing
53 changed files
with
1,308 additions
and
981 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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/python3 | ||
|
||
""" | ||
Convert JSON data to human-readable form. | ||
Usage: | ||
fmtjson.py inputFile [inputFile2...] | ||
or | ||
fmtjson.py <input >output | ||
-n Dry run mode. | ||
""" | ||
|
||
import sys | ||
import json | ||
|
||
def main(args): | ||
problem = False | ||
if len(args) and args[0] == '-n': | ||
files = args[1:] | ||
readonly = True | ||
else: | ||
files = args | ||
readonly = False | ||
|
||
if not files: | ||
if readonly: | ||
json.loads(sys.stdin.read()) | ||
else: | ||
print( | ||
json.dumps( | ||
json.loads(sys.stdin.read()), | ||
sort_keys=True, | ||
indent=2, | ||
separators=(',', ': ') | ||
) | ||
) | ||
else: | ||
for filename in files: | ||
orig = {} | ||
with open(filename, 'r') as f: | ||
try: | ||
orig_data = f.read() | ||
orig = json.loads(orig_data) | ||
except ValueError as e: | ||
print('Reformatting: %s' % filename) | ||
print('ERROR:', str(e)) | ||
problem = True | ||
if (not problem) and (not readonly): | ||
fixed_data = json.dumps(orig, | ||
sort_keys=True, indent=2, separators=(',', ': ')) + '\n' | ||
if orig_data != fixed_data: | ||
print('Reformatting: %s' % filename) | ||
with open(filename, 'w') as f: | ||
f.write(fixed_data) | ||
return problem | ||
|
||
def usage(): | ||
print(__doc__) | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main(sys.argv[1:])) |
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,5 +1,5 @@ | ||
{ | ||
"bind": { | ||
"directory": "test_data" | ||
} | ||
"bind": { | ||
"directory": "test_data" | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,30 +1,30 @@ | ||
{ | ||
"registrars": [ | ||
"dns_providers": [ | ||
{ | ||
"name": "Cloudflare", | ||
"type": "CLOUDFLAREAPI" | ||
} | ||
], | ||
"domains": [ | ||
{ | ||
"dnsProviders": { | ||
"Cloudflare": -1 | ||
}, | ||
"name": "foo.com", | ||
"records": [ | ||
{ | ||
"name": "Third-Party", | ||
"type": "NONE" | ||
"name": "@", | ||
"target": "1.2.3.4", | ||
"type": "A" | ||
} | ||
], | ||
"dns_providers": [ | ||
{ | ||
"name": "Cloudflare", | ||
"type": "CLOUDFLAREAPI" | ||
} | ||
], | ||
"domains": [ | ||
{ | ||
"name": "foo.com", | ||
"registrar": "Third-Party", | ||
"dnsProviders": { | ||
"Cloudflare": -1 | ||
}, | ||
"records": [ | ||
{ | ||
"type": "A", | ||
"name": "@", | ||
"target": "1.2.3.4" | ||
} | ||
] | ||
} | ||
] | ||
], | ||
"registrar": "Third-Party" | ||
} | ||
], | ||
"registrars": [ | ||
{ | ||
"name": "Third-Party", | ||
"type": "NONE" | ||
} | ||
] | ||
} |
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,26 +1,26 @@ | ||
{ | ||
"registrars": [ | ||
{ | ||
"name": "Cloudflare", | ||
"type": "CLOUDFLAREAPI" | ||
} | ||
], | ||
"dns_providers": [], | ||
"domains": [ | ||
{ | ||
"name": "foo.com", | ||
"registrar": "Cloudflare", | ||
"dnsProviders": {}, | ||
"name": "foo.com", | ||
"records": [ | ||
{ | ||
"type": "A", | ||
"name": "@", | ||
"target": "1.2.3.4", | ||
"meta": { | ||
"cloudflare_proxy": "ON" | ||
} | ||
}, | ||
"name": "@", | ||
"target": "1.2.3.4", | ||
"type": "A" | ||
} | ||
] | ||
], | ||
"registrar": "Cloudflare" | ||
} | ||
], | ||
"registrars": [ | ||
{ | ||
"name": "Cloudflare", | ||
"type": "CLOUDFLAREAPI" | ||
} | ||
] | ||
} |
Oops, something went wrong.