def main(): args = argument_parser() ecs_version = read_version() print 'Running generator. ECS version ' + ecs_version # Load the default schemas print 'Loading default schemas' (nested, flat) = schema_reader.load_schemas() # Maybe load user specified directory of schemas if args.include: include_glob = os.path.join(args.include, '*.yml') print 'Loading user defined schemas: {0}'.format(include_glob) (custom_nested, custom_flat) = schema_reader.load_schemas( sorted(glob.glob(include_glob))) # Merge without allowing user schemas to overwrite default schemas nested = ecs_helpers.safe_merge_dicts(nested, custom_nested) flat = ecs_helpers.safe_merge_dicts(flat, custom_flat) intermediate_files.generate(nested, flat) if args.intermediate_only: exit csv_generator.generate(flat, ecs_version) es_template.generate(flat, ecs_version) beats.generate(nested, ecs_version) asciidoc_fields.generate(nested, ecs_version)
def main(): args = argument_parser() # Get rid of empty include if args.include and [''] == args.include: args.include.clear() ecs_version = read_version() print('Running generator. ECS version ' + ecs_version) # Load the default schemas print('Loading default schemas') intermediate_fields = schema_reader.load_schemas() # Maybe load user specified directory of schemas if args.include: include_glob = ecs_helpers.get_glob_files(args.include, ecs_helpers.YAML_EXT) print('Loading user defined schemas: {0}'.format(include_glob)) intermediate_custom = schema_reader.load_schemas(include_glob) schema_reader.merge_schema_fields(intermediate_fields, intermediate_custom) schema_reader.assemble_reusables(intermediate_fields) if args.subset: subset = {} for arg in args.subset: for file in glob.glob(arg): with open(file) as f: raw = yaml.safe_load(f.read()) ecs_helpers.recursive_merge_subset_dicts(subset, raw) if not subset: raise ValueError('Subset option specified but no subsets found') intermediate_fields = ecs_helpers.fields_subset( subset, intermediate_fields) (nested, flat) = schema_reader.generate_nested_flat(intermediate_fields) # default location to save files out_dir = 'generated' docs_dir = 'docs' if args.out: out_dir = os.path.join(args.out, out_dir) docs_dir = os.path.join(args.out, docs_dir) ecs_helpers.make_dirs(out_dir) ecs_helpers.make_dirs(docs_dir) intermediate_files.generate(nested, flat, out_dir) if args.intermediate_only: exit() csv_generator.generate(flat, ecs_version, out_dir) es_template.generate(flat, ecs_version, out_dir) beats.generate(nested, ecs_version, out_dir) if args.include or args.subset: exit() asciidoc_fields.generate(intermediate_fields, ecs_version, docs_dir)
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 main(): args = argument_parser() ecs_version = read_version() print "Running generator. ECS version " + ecs_version (ecs_nested, ecs_flat) = schema_reader.load_ecs() intermediate_files.generate(ecs_nested, ecs_flat) if args.intermediate_only: exit csv_generator.generate(ecs_flat, ecs_version) es_template.generate(ecs_flat, ecs_version) beats.generate(ecs_nested, ecs_version) asciidoc_fields.generate(ecs_nested, ecs_version)
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)