mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
logpolicy: do not upload logs in tests
Fixes tailscale/corp#10030 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
parent
7300b908fb
commit
8ac5976897
@ -13,6 +13,7 @@
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
@ -52,6 +53,8 @@
|
|||||||
"tailscale.com/version/distro"
|
"tailscale.com/version/distro"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func inTest() bool { return flag.Lookup("test.v") != nil }
|
||||||
|
|
||||||
var getLogTargetOnce struct {
|
var getLogTargetOnce struct {
|
||||||
sync.Once
|
sync.Once
|
||||||
v string // URL of logs server, or empty for default
|
v string // URL of logs server, or empty for default
|
||||||
@ -559,7 +562,7 @@ func NewWithConfigPath(collection, dir, cmdName string) *Policy {
|
|||||||
conf.IncludeProcSequence = true
|
conf.IncludeProcSequence = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if envknob.NoLogsNoSupport() {
|
if envknob.NoLogsNoSupport() || inTest() {
|
||||||
log.Println("You have disabled logging. Tailscale will not be able to provide support.")
|
log.Println("You have disabled logging. Tailscale will not be able to provide support.")
|
||||||
conf.HTTPC = &http.Client{Transport: noopPretendSuccessTransport{}}
|
conf.HTTPC = &http.Client{Transport: noopPretendSuccessTransport{}}
|
||||||
} else if val := getLogTarget(); val != "" {
|
} else if val := getLogTarget(); val != "" {
|
||||||
@ -720,7 +723,10 @@ func DialContext(ctx context.Context, netw, addr string) (net.Conn, error) {
|
|||||||
|
|
||||||
// NewLogtailTransport returns an HTTP Transport particularly suited to uploading
|
// NewLogtailTransport returns an HTTP Transport particularly suited to uploading
|
||||||
// logs to the given host name. See DialContext for details on how it works.
|
// logs to the given host name. See DialContext for details on how it works.
|
||||||
func NewLogtailTransport(host string) *http.Transport {
|
func NewLogtailTransport(host string) http.RoundTripper {
|
||||||
|
if inTest() {
|
||||||
|
return noopPretendSuccessTransport{}
|
||||||
|
}
|
||||||
// Start with a copy of http.DefaultTransport and tweak it a bit.
|
// Start with a copy of http.DefaultTransport and tweak it a bit.
|
||||||
tr := http.DefaultTransport.(*http.Transport).Clone()
|
tr := http.DefaultTransport.(*http.Transport).Clone()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user