Skip to content

Commit

Permalink
Adjust terminology - change whitelist to allowlist (#1315) (#1330)
Browse files Browse the repository at this point in the history
Co-authored-by: Dominic Page <11043991+djptek@users.noreply.github.com>
  • Loading branch information
ebeahan and djptek authored Mar 29, 2021
1 parent 77954fb commit a1a2deb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Thanks, you're awesome :-) -->
#### Improvements

* Go code generator now supports the `flattened` data type. #1302
* Adjustments to use terminology that doesn't have negative connotation. #1315

#### Deprecated

Expand Down
16 changes: 8 additions & 8 deletions scripts/generators/beats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@


def generate(ecs_nested, ecs_version, out_dir):
# Load temporary whitelist for default_fields workaround.
df_whitelist = ecs_helpers.yaml_load('scripts/generators/beats_default_fields_whitelist.yml')
# Load temporary allowlist for default_fields workaround.
df_allowlist = ecs_helpers.yaml_load('scripts/generators/beats_default_fields_allowlist.yml')

# base first
beats_fields = fieldset_field_array(ecs_nested['base']['fields'], df_whitelist, ecs_nested['base']['prefix'])
beats_fields = fieldset_field_array(ecs_nested['base']['fields'], df_allowlist, ecs_nested['base']['prefix'])

allowed_fieldset_keys = ['name', 'title', 'group', 'description', 'footnote', 'type']
# other fieldsets
Expand All @@ -19,11 +19,11 @@ def generate(ecs_nested, ecs_version, out_dir):

# Handle when `root:true`
if fieldset.get('root', False):
beats_fields.extend(fieldset_field_array(fieldset['fields'], df_whitelist, fieldset['prefix']))
beats_fields.extend(fieldset_field_array(fieldset['fields'], df_allowlist, fieldset['prefix']))
continue

beats_field = ecs_helpers.dict_copy_keys_ordered(fieldset, allowed_fieldset_keys)
beats_field['fields'] = fieldset_field_array(fieldset['fields'], df_whitelist, fieldset['prefix'])
beats_field['fields'] = fieldset_field_array(fieldset['fields'], df_allowlist, fieldset['prefix'])
beats_fields.append(beats_field)

beats_file = OrderedDict()
Expand All @@ -35,7 +35,7 @@ def generate(ecs_nested, ecs_version, out_dir):
write_beats_yaml(beats_file, ecs_version, out_dir)


def fieldset_field_array(source_fields, df_whitelist, fieldset_prefix):
def fieldset_field_array(source_fields, df_allowlist, fieldset_prefix):
allowed_keys = ['name', 'level', 'required', 'type', 'object_type',
'ignore_above', 'multi_fields', 'format', 'input_format',
'output_format', 'output_precision', 'description',
Expand All @@ -56,15 +56,15 @@ def fieldset_field_array(source_fields, df_whitelist, fieldset_prefix):
for mf in ecs_field['multi_fields']:
# Set default_field if necessary. Avoid adding the key if the parent
# field already is marked with default_field: false.
if not mf['flat_name'] in df_whitelist and ecs_field['flat_name'] in df_whitelist:
if not mf['flat_name'] in df_allowlist and ecs_field['flat_name'] in df_allowlist:
mf['default_field'] = False
cleaned_multi_fields.append(
ecs_helpers.dict_copy_keys_ordered(mf, multi_fields_allowed_keys))
beats_field['multi_fields'] = cleaned_multi_fields

beats_field['name'] = contextual_name

if not ecs_field['flat_name'] in df_whitelist:
if not ecs_field['flat_name'] in df_allowlist:
beats_field['default_field'] = False

fields.append(beats_field)
Expand Down

0 comments on commit a1a2deb

Please sign in to comment.