chore: add optional provider path
This commit is contained in:
parent
7d58238e06
commit
347e606853
@ -27,7 +27,7 @@ type healthCheckSchema struct {
|
|||||||
|
|
||||||
type proxyProviderSchema struct {
|
type proxyProviderSchema struct {
|
||||||
Type string `provider:"type"`
|
Type string `provider:"type"`
|
||||||
Path string `provider:"path"`
|
Path string `provider:"path,omitempty"`
|
||||||
URL string `provider:"url,omitempty"`
|
URL string `provider:"url,omitempty"`
|
||||||
Interval int `provider:"interval,omitempty"`
|
Interval int `provider:"interval,omitempty"`
|
||||||
Filter string `provider:"filter,omitempty"`
|
Filter string `provider:"filter,omitempty"`
|
||||||
@ -59,14 +59,20 @@ func ParseProxyProvider(name string, mapping map[string]any) (types.ProxyProvide
|
|||||||
hcInterval = uint(schema.HealthCheck.Interval)
|
hcInterval = uint(schema.HealthCheck.Interval)
|
||||||
}
|
}
|
||||||
hc := NewHealthCheck([]C.Proxy{}, schema.HealthCheck.URL, hcInterval, schema.HealthCheck.Lazy, expectedStatus)
|
hc := NewHealthCheck([]C.Proxy{}, schema.HealthCheck.URL, hcInterval, schema.HealthCheck.Lazy, expectedStatus)
|
||||||
path := C.Path.Resolve(schema.Path)
|
|
||||||
|
|
||||||
var vehicle types.Vehicle
|
var vehicle types.Vehicle
|
||||||
switch schema.Type {
|
switch schema.Type {
|
||||||
case "file":
|
case "file":
|
||||||
|
path := C.Path.Resolve(schema.Path)
|
||||||
vehicle = resource.NewFileVehicle(path)
|
vehicle = resource.NewFileVehicle(path)
|
||||||
case "http":
|
case "http":
|
||||||
vehicle = resource.NewHTTPVehicle(schema.URL, path)
|
if schema.Path != "" {
|
||||||
|
path := C.Path.Resolve(schema.Path)
|
||||||
|
vehicle = resource.NewHTTPVehicle(schema.URL, path)
|
||||||
|
} else {
|
||||||
|
path := C.Path.GetPathByHash("proxies", schema.URL)
|
||||||
|
vehicle = resource.NewHTTPVehicle(schema.URL, path)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("%w: %s", errVehicleType, schema.Type)
|
return nil, fmt.Errorf("%w: %s", errVehicleType, schema.Type)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ var (
|
|||||||
type ruleProviderSchema struct {
|
type ruleProviderSchema struct {
|
||||||
Type string `provider:"type"`
|
Type string `provider:"type"`
|
||||||
Behavior string `provider:"behavior"`
|
Behavior string `provider:"behavior"`
|
||||||
Path string `provider:"path"`
|
Path string `provider:"path,omitempty"`
|
||||||
URL string `provider:"url,omitempty"`
|
URL string `provider:"url,omitempty"`
|
||||||
Format string `provider:"format,omitempty"`
|
Format string `provider:"format,omitempty"`
|
||||||
Interval int `provider:"interval,omitempty"`
|
Interval int `provider:"interval,omitempty"`
|
||||||
@ -54,13 +54,19 @@ func ParseRuleProvider(name string, mapping map[string]interface{}, parse func(t
|
|||||||
return nil, fmt.Errorf("unsupported format type: %s", schema.Format)
|
return nil, fmt.Errorf("unsupported format type: %s", schema.Format)
|
||||||
}
|
}
|
||||||
|
|
||||||
path := C.Path.Resolve(schema.Path)
|
|
||||||
var vehicle P.Vehicle
|
var vehicle P.Vehicle
|
||||||
switch schema.Type {
|
switch schema.Type {
|
||||||
case "file":
|
case "file":
|
||||||
|
path := C.Path.Resolve(schema.Path)
|
||||||
vehicle = resource.NewFileVehicle(path)
|
vehicle = resource.NewFileVehicle(path)
|
||||||
case "http":
|
case "http":
|
||||||
vehicle = resource.NewHTTPVehicle(schema.URL, path)
|
if schema.Path != "" {
|
||||||
|
path := C.Path.Resolve(schema.Path)
|
||||||
|
vehicle = resource.NewHTTPVehicle(schema.URL, path)
|
||||||
|
} else {
|
||||||
|
path := C.Path.GetPathByHash("rules", schema.URL)
|
||||||
|
vehicle = resource.NewHTTPVehicle(schema.URL, path)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported vehicle type: %s", schema.Type)
|
return nil, fmt.Errorf("unsupported vehicle type: %s", schema.Type)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user