chore: refactor param cache (#18377)

This commit is contained in:
andig 2025-01-23 16:16:21 +01:00 • committed by GitHub
parent 07fa1b64f8
commit 9e9c15ed58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 128 additions and 146 deletions

View file

@ -9,13 +9,9 @@ import (
"github.com/asaskevich/EventBus"
"github.com/benbjohnson/clock"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util"
)
var (
bus = EventBus.New()
log = util.NewLogger("cache")
)
var bus = EventBus.New()
const (
reset = "reset"

View file

@ -138,9 +138,6 @@ func (p *HTTP) WithPipeline(pipeline *pipeline.Pipeline) *HTTP {
func (p *HTTP) WithAuth(typ, user, password string) (*HTTP, error) {
switch strings.ToLower(typ) {
case "basic":
basicAuth := transport.BasicAuthHeader(user, password)
log.Redact(basicAuth)
p.Client.Transport = transport.BasicAuth(user, password, p.Client.Transport)
case "bearer":
p.Client.Transport = transport.BearerAuth(password, p.Client.Transport)

View file

@ -47,12 +47,12 @@ func NewScriptPluginFromConfig(other map[string]interface{}) (Plugin, error) {
return nil, err
}
p, err := NewScripPlugin(cc.Cmd, cc.Timeout, cc.Scale, cc.Cache)
p, err := NewScriptPlugin(cc.Cmd, cc.Timeout, cc.Scale, cc.Cache)
p.getter = defaultGetters(p, cc.Scale)
if err == nil {
var pipe *pipeline.Pipeline
pipe, err = pipeline.New(log, cc.Settings)
pipe, err = pipeline.New(p.log, cc.Settings)
p.pipeline = pipe
}
@ -61,7 +61,7 @@ func NewScriptPluginFromConfig(other map[string]interface{}) (Plugin, error) {
// NewScriptProvider creates a script plugin.
// Script execution is aborted after given timeout.
func NewScripPlugin(script string, timeout time.Duration, scale float64, cache time.Duration) (*Script, error) {
func NewScriptPlugin(script string, timeout time.Duration, scale float64, cache time.Duration) (*Script, error) {
if strings.TrimSpace(script) == "" {
return nil, errors.New("script is required")
}