mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/1Panel-dev/1Panel.git
synced 2026-09-21 00:24:12 +08:00
* fix: apply timeout to snapshot uploads * fix: honor snapshot upload timeouts for sftp and upyun
33 lines
694 B
Go
33 lines
694 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"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))
|
|
}
|
|
|
|
func loadParamFromVars(key string, vars map[string]interface{}) string {
|
|
if _, ok := vars[key]; !ok {
|
|
if key != "bucket" && key != "port" && key != "authMode" && key != "passPhrase" {
|
|
global.LOG.Errorf("load param %s from vars failed, err: not exist!", key)
|
|
}
|
|
return ""
|
|
}
|
|
|
|
return fmt.Sprintf("%v", vars[key])
|
|
}
|