Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Add default collector port configuration #378

Merged
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
12 changes: 6 additions & 6 deletions agent/collector/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (suite *CollectorClientTestSuite) TestCollectorClient_NewClientWithTLS() {
collectorClient, err := NewCollectorClient(&Config{
EnablemTLS: true,
CollectorHost: "localhost",
CollectorPort: 8443,
CollectorPort: 8081,
Cert: "../../test/certs/client-cert.pem",
Key: "../../test/certs/client-key.pem",
CA: "../../test/certs/ca-cert.pem",
Expand All @@ -47,7 +47,7 @@ func (suite *CollectorClientTestSuite) TestCollectorClient_NewClientWithoutTLS()
collectorClient, err := NewCollectorClient(&Config{
EnablemTLS: false,
CollectorHost: "localhost",
CollectorPort: 8443,
CollectorPort: 8081,
Cert: "",
Key: "",
CA: "",
Expand All @@ -64,7 +64,7 @@ func (suite *CollectorClientTestSuite) TestCollectorClient_PublishingSuccess() {
collectorClient, err := NewCollectorClient(&Config{
EnablemTLS: true,
CollectorHost: "localhost",
CollectorPort: 8443,
CollectorPort: 8081,
Cert: "../../test/certs/client-cert.pem",
Key: "../../test/certs/client-key.pem",
CA: "../../test/certs/ca-cert.pem",
Expand Down Expand Up @@ -92,7 +92,7 @@ func (suite *CollectorClientTestSuite) TestCollectorClient_PublishingSuccess() {

suite.EqualValues(requestBody, string(bodyBytes))

suite.Equal(req.URL.String(), "https://localhost:8443/api/collect")
suite.Equal(req.URL.String(), "https://localhost:8081/api/collect")
return &http.Response{
StatusCode: 202,
}
Expand All @@ -107,13 +107,13 @@ func (suite *CollectorClientTestSuite) TestCollectorClient_PublishingFailure() {
collectorClient, err := NewCollectorClient(&Config{
EnablemTLS: false,
CollectorHost: "localhost",
CollectorPort: 8443,
CollectorPort: 8081,
})

suite.NoError(err)

collectorClient.httpClient.Transport = helpers.RoundTripFunc(func(req *http.Request) *http.Response {
suite.Equal(req.URL.String(), "http://localhost:8443/api/collect")
suite.Equal(req.URL.String(), "http://localhost:8081/api/collect")
return &http.Response{
StatusCode: 500,
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewAgentCmd() *cobra.Command {
startCmd.Flags().IntVarP(&discoveryPeriod, "discovery-period", "", 2, "Discovery mechanism loop period on minutes")

startCmd.Flags().StringVar(&collectorHost, "collector-host", "localhost", "Data Collector host")
startCmd.Flags().IntVar(&collectorPort, "collector-port", 8888, "Data Collector port")
startCmd.Flags().IntVar(&collectorPort, "collector-port", 8081, "Data Collector port")

startCmd.Flags().BoolVar(&enablemTLS, "enable-mtls", false, "Enable mTLS authentication between server and agent")
startCmd.Flags().StringVar(&cert, "cert", "", "mTLS client certificate")
Expand Down
5 changes: 4 additions & 1 deletion cmd/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var dbPort string
var dbUser string
var dbPassword string
var dbName string

var collectorPort int
var enablemTLS bool
var cert string
var key string
Expand All @@ -40,7 +42,7 @@ func NewWebCmd() *cobra.Command {
}

serveCmd.Flags().StringVar(&host, "host", "0.0.0.0", "The host to bind the HTTP service to")
serveCmd.Flags().IntVarP(&port, "port", "p", 8080, "The port for the HTTP service to listen at")
serveCmd.Flags().IntVarP(&port, "port", "p", 8080, "The port for the HTTP service to listen on")
serveCmd.Flags().StringVar(&araAddr, "ara-addr", "127.0.0.1:8000", "Address where ARA is running (ex: localhost:80)")

serveCmd.Flags().StringVar(&dbHost, "db-host", "localhost", "The database host")
Expand All @@ -49,6 +51,7 @@ func NewWebCmd() *cobra.Command {
serveCmd.Flags().StringVar(&dbPassword, "db-password", "postgres", "The database password")
serveCmd.Flags().StringVar(&dbName, "db-name", "trento", "The database name that the application will use")

serveCmd.Flags().IntVar(&collectorPort, "collector-port", 8081, "The port for the data collector service to listen on")
serveCmd.Flags().BoolVar(&enablemTLS, "enable-mtls", false, "Enable mTLS authentication between server and agents")
serveCmd.Flags().StringVar(&cert, "cert", "", "mTLS server certificate")
serveCmd.Flags().StringVar(&key, "key", "", "mTLS server key")
Expand Down
2 changes: 1 addition & 1 deletion web/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (a *App) Start(ctx context.Context) error {
return err
}
collectorServer := &http.Server{
Addr: fmt.Sprintf("%s:%d", a.config.Host, 8443),
Addr: fmt.Sprintf("%s:%d", a.config.Host, a.config.CollectorPort),
Handler: a.collectorEngine,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
Expand Down