Skip to content
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
44 changes: 4 additions & 40 deletions tools/deprecate_features/deprecate_features.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# A simple script to snag deprecated proto fields and add them to runtime_features.h
# A simple script to snag deprecated proto fields and add them to runtime_features.cc

from __future__ import print_function
import re
Expand All @@ -16,7 +16,8 @@ def deprecate_proto():

# Compile the set of deprecated fields and the files they're in, deduping via set.
deprecated_regex = re.compile(r'.*\/([^\/]*.proto):[^=]* ([^= ]+) =.*')
for line in grep_output.splitlines():
for byte_line in grep_output.splitlines():
line = str(byte_line)
match = deprecated_regex.match(line)
if match:
filenames_and_fields.add(tuple([match.group(1), match.group(2)]))
Expand Down Expand Up @@ -46,46 +47,11 @@ def deprecate_proto():
return email, code


# Sorts out the list of features which should be default enabled and returns a tuple of
# email and code changes.
def flip_runtime_features():
grep_output = subprocess.check_output('grep -r "envoy.reloadable_features\." source/*',
shell=True)

features_to_flip = set()

# Compile the set of features to flip, deduping via set.
deprecated_regex = re.compile(r'.*"(envoy.reloadable_features\.[^"]+)".*')
for line in grep_output.splitlines():
match = deprecated_regex.match(line)
if match:
features_to_flip.add(match.group(1))
else:
print('no match in ' + line + ' please address manually!')

# Exempt the two test flags.
features_to_flip.remove('envoy.reloadable_features.my_feature_name')
features_to_flip.remove('envoy.reloadable_features.test_feature_true')

code_snippets = []
email_snippets = []
for (feature) in features_to_flip:
code_snippets.append(' "' + feature + '",\n')
email_snippets.append(feature + '\n')
code = ''.join(code_snippets)
email = ''
if email_snippets:
email = 'the following features will be defaulted to true:\n' + ''.join(email_snippets)

return email, code


# Gather code and suggested email changes.
runtime_email, runtime_features_code = flip_runtime_features()
deprecate_email, deprecate_code = deprecate_proto()

email = ('The Envoy maintainer team is cutting the next Envoy release. In the new release ' +
runtime_email + deprecate_email)
deprecate_email)

print('\n\nSuggested envoy-announce email: \n')
print(email)
Expand All @@ -94,8 +60,6 @@ def flip_runtime_features():
exit(1)

for line in fileinput.FileInput('source/common/runtime/runtime_features.cc', inplace=1):
if 'envoy.reloadable_features.test_feature_true' in line:
line = line.replace(line, line + runtime_features_code)
if 'envoy.deprecated_features.deprecated.proto:is_deprecated_fatal' in line:
line = line.replace(line, line + deprecate_code)
print(line, end='')
Expand Down
3 changes: 1 addition & 2 deletions tools/deprecate_features/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
GitPython==3.0.0
PyGithub==1.43.8
six==1.12.0