Skip to content

Commit

Permalink
retrieving AllowValues from botocore during --update-specs
Browse files Browse the repository at this point in the history
  • Loading branch information
PatMyron committed Sep 22, 2020
1 parent 3565486 commit 0456cf4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/cfnlint/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import multiprocessing
import os
import jsonpatch
import requests
import cfnlint
from cfnlint.helpers import get_url_content, url_has_newer_version
from cfnlint.helpers import SPEC_REGIONS
Expand Down Expand Up @@ -58,6 +59,26 @@ def update_resource_spec(region, url):
with open(filename, 'w') as f:
json.dump(spec, f, indent=2, sort_keys=True, separators=(',', ': '))

lines = []
with open(filename, 'r') as f:
for line in f:
if 'botocore' in line:
service_and_type = line.split('"')[3]
service = '/'.join(service_and_type.split('/')[:-1])
type = service_and_type.split('/')[-1]
r = requests.get('https://raw.githubusercontent.com/boto/botocore/master/botocore/data/' + service + '/service-2.json').json()
lines += ' "AllowedValues": [\n'
for value in sorted(r['shapes'][type]['enum']):
lines.append(' "' + value + '",\n')
lines[-1] = lines[-1].replace(',', '')
lines += ' ]\n'
else:
lines += line

with open(filename, 'w') as f:
for line in lines:
f.write(line)

def update_documentation(rules):
"""Generate documentation"""

Expand Down

0 comments on commit 0456cf4

Please sign in to comment.