Repository: traefik/traefik
File: pkg/plugins/builder.go (Go)

Code before:
			}

			pb.providerBuilders[pName] = builder

		default:
			return nil, fmt.Errorf("unknow plugin type: %s", manifest.Type)
		}
	}
	return pb, nil
}

// Build builds a middleware plugin.
func (b Builder) Build(pName string, config map[string]interface{}, middlewareName string) (Constructor, error) {
	if b.middlewareBuilders == nil {
		return nil, fmt.Errorf("no plugin definitions in the static configuration: %s", pName)
	}

	// plugin (pName) can be located in yaegi or wasm middleware builders.
	if descriptor, ok := b.middlewareBuilders[pName]; ok {
		m, err := descriptor.newMiddleware(config, middlewareName)
		if err != nil {
			return nil, err
		}
		return m.NewHandler, nil
	}

	return nil, fmt.Errorf("unknown plugin type: %s", pName)
}

func newMiddlewareBuilder(ctx context.Context, manifest *Manifest, moduleName string) (middlewareBuilder, error) {
	switch manifest.Runtime {
	case RuntimeWasm:
		return newWasmMiddlewareBuilder(localGoPath, moduleName), nil

	case RuntimeYaegi, "":
		i, err := newInterpreter(ctx, localGoPath, manifest.Import)
		if err != nil {
			return nil, fmt.Errorf("failed to craete Yaegi intepreter: %w", err)
		}

		return newYaegiMiddlewareBuilder(i, manifest.BasePkg, manifest.Import)

	default:
		return nil, fmt.Errorf("unknown plugin runtime: %s", manifest.Runtime)
	}
}

func newProviderBuilder(ctx context.Context, manifest *Manifest, goPath string) (providerBuilder, error) {
	switch manifest.Runtime {
	case RuntimeYaegi, "":
		i, err := newInterpreter(ctx, goPath, manifest.Import)

Review comment (suggestion):
```suggestion
		}
		
		return m.NewHandler, nil
```

Code after:
				return nil, fmt.Errorf("%s: %w", desc.ModuleName, err)
			}

			pb.providerBuilders[pName] = builder

		default:
			return nil, fmt.Errorf("unknow plugin type: %s", manifest.Type)
		}
	}
	return pb, nil
}

// Build builds a middleware plugin.
func (b Builder) Build(pName string, config map[string]interface{}, middlewareName string) (Constructor, error) {
	if b.middlewareBuilders == nil {
		return nil, fmt.Errorf("no plugin definitions in the static configuration: %s", pName)
	}

	// plugin (pName) can be located in yaegi or wasm middleware builders.
	if descriptor, ok := b.middlewareBuilders[pName]; ok {
		m, err := descriptor.newMiddleware(config, middlewareName)
		if err != nil {
			return nil, err
		}

		return m.NewHandler, nil
	}

	return nil, fmt.Errorf("unknown plugin type: %s", pName)
}

func newMiddlewareBuilder(ctx context.Context, goPath string, manifest *Manifest, moduleName string) (middlewareBuilder, error) {
	switch manifest.Runtime {
	case runtimeWasm:
		wasmPath, err := getWasmPath(manifest)
		if err != nil {
			return nil, fmt.Errorf("wasm path: %w", err)
		}

		return newWasmMiddlewareBuilder(goPath, moduleName, wasmPath), nil

	case runtimeYaegi, "":
		i, err := newInterpreter(ctx, goPath, manifest.Import)
		if err != nil {
			return nil, fmt.Errorf("failed to craete Yaegi intepreter: %w", err)
		}

		return newYaegiMiddlewareBuilder(i, manifest.BasePkg, manifest.Import)

	default:
		return nil, fmt.Errorf("unknown plugin runtime: %s", manifest.Runtime)