func breakdownFileName()

in events/generate/events_generate.go [70:101]


func breakdownFileName(path string) (string, string, bool) {

	// Must be a JSON file.
	if !strings.HasSuffix(path, ".json") {
		return "", "", false
	}
	fileName := strings.TrimSuffix(path, ".json")

	isConverted := strings.HasSuffix(fileName, converted)
	if isConverted {
		fileName = strings.TrimSuffix(fileName, "-"+converted)
	}

	var et, ft string
	if strings.HasSuffix(fileName, input) {
		ft = input
		fileName = strings.TrimSuffix(fileName, "-"+input)
	} else if strings.HasSuffix(fileName, output) {
		ft = output
		fileName = strings.TrimSuffix(fileName, "-"+output)
	}

	if strings.HasSuffix(fileName, legacyType) {
		et = legacyType
		fileName = strings.TrimSuffix(fileName, "-"+legacyType)
	} else if strings.HasSuffix(fileName, cloudeventType) {
		et = cloudeventType
		fileName = strings.TrimSuffix(fileName, "-"+cloudeventType)
	}

	return fileName, et + ft, isConverted
}