func loadCustomDocFile()

in scripts/generate-docs/custom_doc.go [100:142]


func loadCustomDocFile(path string) (eventDoc, error) {
	var result eventDoc

	body, err := ioutil.ReadFile(path)
	if err != nil {
		return result, errors.Wrapf(err, "reading file failed (path: %s)", path)
	}

	err = yaml.UnmarshalStrict(body, &result)
	if err != nil {
		return result, errors.Wrapf(err, "parsing yaml failed (path: %s)", path)
	}

	// do some light validation
	if result.Overview.Name == "" {
		return result, fmt.Errorf("missing overview.name in %s", path)
	}
	if result.Overview.Description == "" {
		return result, fmt.Errorf("missing overview.description in %s", path)
	}

	if len(result.Identification.Os) == 0 {
		return result, fmt.Errorf("missing identification.os in %s", path)
	}
	for _, _os := range result.Identification.Os {
		low := strings.ToLower(_os)
		if low != "linux" && low != "macos" && low != "windows" {
			return result, fmt.Errorf("invalid identification.os value %s", path)
		}
	}

	if result.Identification.DataStream == "" {
		return result, fmt.Errorf("missing identification.data_stream in %s", path)
	}
	if len(result.Identification.Filter) == 0 {
		return result, fmt.Errorf("missing identification.filter in %s", path)
	}
	if len(result.Fields.Endpoint) == 0 {
		return result, fmt.Errorf("missing fields.endpoint in %s", path)
	}

	return result, nil
}