Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Moving outputs/transport => common/transport (#16734) #16820

Merged
merged 8 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions filebeat/input/kafka/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/libbeat/monitoring"
"github.com/elastic/beats/v7/libbeat/monitoring/adapter"
"github.com/elastic/beats/v7/libbeat/outputs"
)

type kafkaInputConfig struct {
Expand Down Expand Up @@ -169,7 +168,7 @@ func newSaramaConfig(config kafkaInputConfig) (*sarama.Config, error) {
k.Consumer.Group.Rebalance.Retry.Backoff = config.Rebalance.RetryBackoff
k.Consumer.Group.Rebalance.Retry.Max = config.Rebalance.MaxRetries

tls, err := outputs.LoadTLSConfig(config.TLS)
tls, err := tlscommon.LoadTLSConfig(config.TLS)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions filebeat/input/mqtt/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package mqtt
import (
libmqtt "github.com/eclipse/paho.mqtt.golang"

"github.com/elastic/beats/v7/libbeat/outputs"
"github.com/elastic/beats/v7/libbeat/common/transport/tlscommon"
)

func createClientOptions(config mqttInputConfig, onConnectHandler func(client libmqtt.Client)) (*libmqtt.ClientOptions, error) {
Expand All @@ -36,7 +36,7 @@ func createClientOptions(config mqttInputConfig, onConnectHandler func(client li
}

if config.TLS != nil {
tlsConfig, err := outputs.LoadTLSConfig(config.TLS)
tlsConfig, err := tlscommon.LoadTLSConfig(config.TLS)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions filebeat/inputsource/tcp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/elastic/beats/v7/libbeat/common/atomic"
"github.com/elastic/beats/v7/libbeat/common/transport/tlscommon"
"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/libbeat/outputs/transport"
)

// Server represent a TCP server
Expand All @@ -41,7 +40,7 @@ type Server struct {
done chan struct{}
factory HandlerFactory
log *logp.Logger
tlsConfig *transport.TLSConfig
tlsConfig *tlscommon.TLSConfig
closer *Closer
clientsCount atomic.Int
}
Expand Down
5 changes: 3 additions & 2 deletions heartbeat/monitors/active/dialchain/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import (
"github.com/elastic/beats/v7/heartbeat/monitors/jobs"
"github.com/elastic/beats/v7/heartbeat/monitors/wrappers"
"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/outputs/transport"
"github.com/elastic/beats/v7/libbeat/common/transport"
"github.com/elastic/beats/v7/libbeat/common/transport/tlscommon"
)

// Builder maintains a DialerChain for building dialers and dialer based
Expand All @@ -46,7 +47,7 @@ type Builder struct {
type BuilderSettings struct {
Timeout time.Duration
Socks5 transport.ProxyConfig
TLS *transport.TLSConfig
TLS *tlscommon.TLSConfig
}

// Endpoint configures a host with all port numbers to be monitored by a dialer
Expand Down
2 changes: 1 addition & 1 deletion heartbeat/monitors/active/dialchain/dialchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package dialchain

import (
"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/outputs/transport"
"github.com/elastic/beats/v7/libbeat/common/transport"
)

// DialerChain composes builders for multiple network layers, used to build
Expand Down
2 changes: 1 addition & 1 deletion heartbeat/monitors/active/dialchain/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/elastic/beats/v7/heartbeat/look"
"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/common/transport"
"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/libbeat/outputs/transport"
)

// TCPDialer creates a new NetDialer with constant event fields and default
Expand Down
2 changes: 1 addition & 1 deletion heartbeat/monitors/active/dialchain/socks5.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/elastic/beats/v7/heartbeat/look"
"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/outputs/transport"
"github.com/elastic/beats/v7/libbeat/common/transport"
)

// SOCKS5Layer configures a SOCKS5 proxy layer in a DialerChain.
Expand Down
5 changes: 3 additions & 2 deletions heartbeat/monitors/active/dialchain/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import (
"github.com/elastic/beats/v7/heartbeat/look"
"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/outputs/transport"
"github.com/elastic/beats/v7/libbeat/common/transport"
"github.com/elastic/beats/v7/libbeat/common/transport/tlscommon"
)

// TLSLayer configures the TLS layer in a DialerChain.
Expand All @@ -39,7 +40,7 @@ import (
// "rtt": { "handshake": { "us": ... }}
// }
// }
func TLSLayer(cfg *transport.TLSConfig, to time.Duration) Layer {
func TLSLayer(cfg *tlscommon.TLSConfig, to time.Duration) Layer {
return func(event *beat.Event, next transport.Dialer) (transport.Dialer, error) {
var timer timer

Expand Down
2 changes: 1 addition & 1 deletion heartbeat/monitors/active/dialchain/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"time"

"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/outputs/transport"
"github.com/elastic/beats/v7/libbeat/common/transport"
)

type timer struct {
Expand Down
8 changes: 4 additions & 4 deletions heartbeat/monitors/active/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"github.com/elastic/beats/v7/heartbeat/monitors/jobs"
"github.com/elastic/beats/v7/heartbeat/monitors/wrappers"
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/common/transport"
"github.com/elastic/beats/v7/libbeat/common/transport/tlscommon"
"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/libbeat/outputs"
"github.com/elastic/beats/v7/libbeat/outputs/transport"
)

func init() {
Expand All @@ -47,7 +47,7 @@ func create(
return nil, 0, err
}

tls, err := outputs.LoadTLSConfig(config.TLS)
tls, err := tlscommon.LoadTLSConfig(config.TLS)
if err != nil {
return nil, 0, err
}
Expand Down Expand Up @@ -118,7 +118,7 @@ func create(
return js, len(config.Hosts), nil
}

func newRoundTripper(config *Config, tls *transport.TLSConfig) (*http.Transport, error) {
func newRoundTripper(config *Config, tls *tlscommon.TLSConfig) (*http.Transport, error) {
var proxy func(*http.Request) (*url.URL, error)
if config.ProxyURL != "" {
url, err := url.Parse(config.ProxyURL)
Expand Down
9 changes: 5 additions & 4 deletions heartbeat/monitors/active/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ import (

"github.com/elastic/beats/v7/heartbeat/hbtest"
"github.com/elastic/beats/v7/heartbeat/monitors/wrappers"
schedule "github.com/elastic/beats/v7/heartbeat/scheduler/schedule"
"github.com/elastic/beats/v7/heartbeat/scheduler/schedule"
"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/common/file"
"github.com/elastic/beats/v7/libbeat/outputs/transport"
"github.com/elastic/beats/v7/libbeat/common/transport"
"github.com/elastic/beats/v7/libbeat/common/transport/tlscommon"
btesting "github.com/elastic/beats/v7/libbeat/testing"
"github.com/elastic/go-lookslike"
"github.com/elastic/go-lookslike/isdef"
Expand Down Expand Up @@ -512,7 +513,7 @@ func TestNewRoundTripper(t *testing.T) {

for name, config := range configs {
t.Run(name, func(t *testing.T) {
transp, err := newRoundTripper(&config, &transport.TLSConfig{})
transp, err := newRoundTripper(&config, &tlscommon.TLSConfig{})
require.NoError(t, err)

if config.ProxyURL == "" {
Expand All @@ -525,7 +526,7 @@ func TestNewRoundTripper(t *testing.T) {
require.NotNil(t, transp.Dial)
require.NotNil(t, transport.TLSDialer)

require.Equal(t, (&transport.TLSConfig{}).ToConfig(), transp.TLSClientConfig)
require.Equal(t, (&tlscommon.TLSConfig{}).ToConfig(), transp.TLSClientConfig)
require.True(t, transp.DisableKeepAlives)
})
}
Expand Down
2 changes: 1 addition & 1 deletion heartbeat/monitors/active/http/simple_transp.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"net/url"
"strings"

"github.com/elastic/beats/v7/libbeat/outputs/transport"
"github.com/elastic/beats/v7/libbeat/common/transport"
)

const (
Expand Down
9 changes: 4 additions & 5 deletions heartbeat/monitors/active/http/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import (
"sync"
"time"

"github.com/elastic/beats/v7/libbeat/common/useragent"

"github.com/elastic/beats/v7/heartbeat/eventext"
"github.com/elastic/beats/v7/heartbeat/look"
"github.com/elastic/beats/v7/heartbeat/monitors"
Expand All @@ -39,7 +37,8 @@ import (
"github.com/elastic/beats/v7/heartbeat/reason"
"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/outputs/transport"
"github.com/elastic/beats/v7/libbeat/common/transport/tlscommon"
"github.com/elastic/beats/v7/libbeat/common/useragent"
)

var userAgent = useragent.UserAgent("Heartbeat", true)
Expand Down Expand Up @@ -79,7 +78,7 @@ func newHTTPMonitorHostJob(
func newHTTPMonitorIPsJob(
config *Config,
addr string,
tls *transport.TLSConfig,
tls *tlscommon.TLSConfig,
enc contentEncoder,
body []byte,
validator multiValidator,
Expand All @@ -106,7 +105,7 @@ func newHTTPMonitorIPsJob(
func createPingFactory(
config *Config,
port uint16,
tls *transport.TLSConfig,
tls *tlscommon.TLSConfig,
request *http.Request,
body []byte,
validator multiValidator,
Expand Down
5 changes: 2 additions & 3 deletions heartbeat/monitors/active/tcp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ import (
"errors"
"time"

"github.com/elastic/beats/v7/libbeat/common/transport/tlscommon"
"github.com/elastic/beats/v7/libbeat/outputs/transport"

"github.com/elastic/beats/v7/heartbeat/monitors"
"github.com/elastic/beats/v7/libbeat/common/transport"
"github.com/elastic/beats/v7/libbeat/common/transport/tlscommon"
)

type Config struct {
Expand Down
2 changes: 1 addition & 1 deletion heartbeat/monitors/active/tcp/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/elastic/beats/v7/heartbeat/reason"
"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/outputs/transport"
"github.com/elastic/beats/v7/libbeat/common/transport"
)

func pingHost(
Expand Down
6 changes: 3 additions & 3 deletions heartbeat/monitors/active/tcp/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import (
"github.com/elastic/beats/v7/heartbeat/monitors/jobs"
"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/common/transport"
"github.com/elastic/beats/v7/libbeat/common/transport/tlscommon"
"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/libbeat/outputs"
"github.com/elastic/beats/v7/libbeat/outputs/transport"
)

func init() {
Expand All @@ -54,7 +54,7 @@ func create(
return nil, 0, err
}

tls, err := outputs.LoadTLSConfig(config.TLS)
tls, err := tlscommon.LoadTLSConfig(config.TLS)
if err != nil {
return nil, 0, err
}
Expand Down
Loading