mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 16:58:31 +02:00
refactor(config): enhance provider conflict error messages, streamline provider loading, and improve validation for config files, rename provider.GetType() to Type()
This commit is contained in:
@@ -73,7 +73,7 @@ func (handler *EventHandler) matchAny(events []watcher.Event, route *route.Route
|
||||
}
|
||||
|
||||
func (handler *EventHandler) match(event watcher.Event, route *route.Route) bool {
|
||||
switch handler.provider.GetType() {
|
||||
switch handler.provider.Type() {
|
||||
case types.ProviderTypeDocker, types.ProviderTypeAgent:
|
||||
return route.Container.ContainerID == event.ActorID ||
|
||||
route.Container.ContainerName == event.ActorName
|
||||
|
||||
@@ -20,17 +20,12 @@ type FileProvider struct {
|
||||
l zerolog.Logger
|
||||
}
|
||||
|
||||
func FileProviderImpl(filename string) (ProviderImpl, error) {
|
||||
impl := &FileProvider{
|
||||
func FileProviderImpl(filename string) ProviderImpl {
|
||||
return &FileProvider{
|
||||
fileName: filename,
|
||||
path: path.Join(common.ConfigBasePath, filename),
|
||||
l: logging.With().Str("type", "file").Str("name", filename).Logger(),
|
||||
}
|
||||
_, err := os.Stat(impl.path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return impl, nil
|
||||
}
|
||||
|
||||
func validate(data []byte) (routes route.Routes, err gperr.Error) {
|
||||
|
||||
Reference in New Issue
Block a user