func()

in plugins/targetmanagers/csvtargetmanager/csvfile.go [64:87]


func (tf CSVFileTargetManager) ValidateAcquireParameters(params []byte) (interface{}, error) {
	var ap AcquireParameters
	if err := json.Unmarshal(params, &ap); err != nil {
		return nil, err
	}
	for idx, hp := range ap.HostPrefixes {
		hp = strings.TrimSpace(hp)
		if hp == "" {
			return nil, fmt.Errorf("Host prefix cannot be empty string if specified")
		}
		// reassign after removing surrounding spaces
		ap.HostPrefixes[idx] = hp
	}
	if ap.FileURI == nil {
		return nil, fmt.Errorf("file URI not specified in acquire parameters")
	}
	if ap.FileURI.Scheme != "file" && ap.FileURI.Scheme != "" {
		return nil, fmt.Errorf("unsupported scheme: '%s', only 'file' or empty string are accepted", ap.FileURI.Scheme)
	}
	if ap.FileURI.Host != "" && ap.FileURI.Host != "localhost" {
		return nil, fmt.Errorf("unsupported host '%s', only 'localhost' or empty string are accepted", ap.FileURI.Host)
	}
	return ap, nil
}