in plugins/testfetchers/uri/uri.go [47:79]
func (tf URI) ValidateFetchParameters(_ xcontext.Context, params []byte) (interface{}, error) {
var fp FetchParameters
if err := json.Unmarshal(params, &fp); err != nil {
return nil, err
}
if fp.TestName == "" {
return nil, fmt.Errorf("test name cannot be empty for fetch parameters")
}
if fp.URI == nil {
return nil, fmt.Errorf("file URI not specified in fetch parameters")
}
scheme := fp.URI.Scheme
if scheme == "" {
// if no scheme is specified, assume "file://"
scheme = "file"
}
scheme = strings.ToLower(scheme)
supported := false
for _, s := range supportedSchemes {
if s == scheme {
supported = true
}
}
if !supported {
return nil, fmt.Errorf("unsupported scheme %s", scheme)
}
if scheme == "file" {
if fp.URI.Host != "" && fp.URI.Host != "localhost" {
return nil, fmt.Errorf("invalid host in URI: '%s'. Only 'localhost' or empty string are supported for scheme %s", fp.URI.Host, scheme)
}
}
return fp, nil
}