Files

32 lines
694 B
Go
Raw Permalink Normal View History

2024-07-23 14:48:37 +08:00
package client
import (
"context"
2024-07-23 14:48:37 +08:00
"fmt"
"net/http"
2024-07-23 14:48:37 +08:00
"github.com/1Panel-dev/1Panel/agent/global"
)
type deadlineTransport struct {
ctx context.Context
base http.RoundTripper
}
func (t deadlineTransport) RoundTrip(req *http.Request) (*http.Response, error) {
if err := t.ctx.Err(); err != nil {
return nil, err
}
return t.base.RoundTrip(req.Clone(t.ctx))
}
2024-07-23 14:48:37 +08:00
func loadParamFromVars(key string, vars map[string]interface{}) string {
if _, ok := vars[key]; !ok {
if key != "bucket" && key != "port" && key != "authMode" && key != "passPhrase" {
2024-07-23 14:48:37 +08:00
global.LOG.Errorf("load param %s from vars failed, err: not exist!", key)
}
return ""
}
return fmt.Sprintf("%v", vars[key])
}