Beispiel #1
0
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')

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

    allowed_fieldset_keys = [
        'name', 'title', 'group', 'description', 'footnote', 'type'
    ]
    # other fieldsets
    for fieldset_name in sorted(ecs_nested):
        if 'base' == fieldset_name:
            continue
        fieldset = ecs_nested[fieldset_name]

        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_fields.append(beats_field)

    beats_file = OrderedDict()
    beats_file['key'] = 'ecs'
    beats_file['title'] = 'ECS'
    beats_file['description'] = 'ECS Fields.'
    beats_file['fields'] = beats_fields

    write_beats_yaml(beats_file, ecs_version, out_dir)
Beispiel #2
0
def generate(ecs_nested, ecs_version, out_dir):
    # base first
    beats_fields = fieldset_field_array(ecs_nested['base']['fields'],
                                        ecs_nested['base']['prefix'])

    allowed_fieldset_keys = [
        'name', 'title', 'group', 'description', 'footnote', 'type'
    ]
    # other fieldsets
    for fieldset_name in sorted(ecs_nested):
        if 'base' == fieldset_name:
            continue
        fieldset = ecs_nested[fieldset_name]

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

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

    # Load temporary allowlist for default_fields workaround.
    df_allowlist = ecs_helpers.yaml_load(
        'scripts/generators/beats_default_fields_allowlist.yml')
    # Set default_field configuration.
    set_default_field(beats_fields, df_allowlist)

    beats_file = OrderedDict()
    beats_file['key'] = 'ecs'
    beats_file['title'] = 'ECS'
    beats_file['description'] = 'ECS Fields.'
    beats_file['fields'] = beats_fields

    write_beats_yaml(beats_file, ecs_version, out_dir)