def main() -> None: args = argument_parser() ecs_generated_version: str = read_version(args.ref) print('Running generator. ECS version ' + ecs_generated_version) # default location to save files out_dir = 'generated' docs_dir = 'docs' if args.out: default_dirs = False out_dir = os.path.join(args.out, out_dir) docs_dir = os.path.join(args.out, docs_dir) else: default_dirs = True ecs_helpers.make_dirs(out_dir) # To debug issues in the gradual building up of the nested structure, insert # statements like this after any step of interest. # ecs_helpers.yaml_dump('ecs.yml', fields) # Detect usage of experimental changes to tweak artifact version label if args.include and loader.EXPERIMENTAL_SCHEMA_DIR in args.include: ecs_generated_version += "+exp" print('Experimental ECS version ' + ecs_generated_version) fields: dict[str, FieldEntry] = loader.load_schemas(ref=args.ref, included_files=args.include) cleaner.clean(fields, strict=args.strict) finalizer.finalize(fields) fields, docs_only_fields = subset_filter.filter(fields, args.subset, out_dir) fields = exclude_filter.exclude(fields, args.exclude) nested, flat = intermediate_files.generate(fields, os.path.join(out_dir, 'ecs'), default_dirs) if args.intermediate_only: exit() csv_generator.generate(flat, ecs_generated_version, out_dir) es_template.generate(nested, ecs_generated_version, out_dir, args.mapping_settings, args.template_settings) es_template.generate_legacy(flat, ecs_generated_version, out_dir, args.mapping_settings, args.template_settings_legacy) beats.generate(nested, ecs_generated_version, out_dir) if (args.include or args.subset or args.exclude) and not args.force_docs: exit() ecs_helpers.make_dirs(docs_dir) docs_only_nested = intermediate_files.generate_nested_fields( docs_only_fields) asciidoc_fields.generate(nested, docs_only_nested, ecs_generated_version, docs_dir)
def test_load_schemas_no_custom(self): fields = loader.load_schemas([]) self.assertEqual([ 'field_details', 'fields', 'schema_details' ], sorted( fields['process'].keys() ), "Schemas should have 'field_details', 'fields' and 'schema_details' subkeys" ) self.assertEqual( ['field_details'], list(fields['process']['fields']['pid'].keys()), "Leaf fields should have only the 'field_details' subkey") self.assertIn( 'fields', fields['process']['fields']['thread'].keys(), "Fields containing nested fields should at least have the 'fields' subkey" )
def main(): args = argument_parser() ecs_version = read_version(args.ref) print('Running generator. ECS version ' + ecs_version) # default location to save files out_dir = 'generated' docs_dir = 'docs' if args.out: default_dirs = False out_dir = os.path.join(args.out, out_dir) docs_dir = os.path.join(args.out, docs_dir) else: default_dirs = True ecs_helpers.make_dirs(out_dir) ecs_helpers.make_dirs(docs_dir) # To debug issues in the gradual building up of the nested structure, insert # statements like this after any step of interest. # ecs_helpers.yaml_dump('ecs.yml', fields) fields = loader.load_schemas(ref=args.ref, included_files=args.include) if args.oss: oss.fallback(fields) cleaner.clean(fields, strict=args.strict) finalizer.finalize(fields) fields = subset_filter.filter(fields, args.subset, out_dir) nested, flat = intermediate_files.generate(fields, os.path.join(out_dir, 'ecs'), default_dirs) if args.intermediate_only: exit() csv_generator.generate(flat, ecs_version, out_dir) es_template.generate(flat, ecs_version, out_dir, args.template_settings, args.mapping_settings) beats.generate(nested, ecs_version, out_dir) if args.include or args.subset: exit() asciidoc_fields.generate(nested, ecs_version, docs_dir)