Skip to content

Commit

Permalink
chore: remove TLS support for the moment
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Mar 18, 2024
1 parent a65e22b commit ceec832
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
3 changes: 3 additions & 0 deletions docs/modules/influxdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,6 @@ This function is a simple helper to return a URL to the container, using the def

Please check the existence of two methods: `ConnectionUrl` and `MustConnectionUrl`. The latter is used to avoid the need to handle errors,
while the former is used to return the URL and the error. `MustConnectionUrl` will panic if an error occurs.

!!!info
The `ConnectionUrl` and `MustConnectionUrl` methods only support HTTP connections at the moment.
13 changes: 4 additions & 9 deletions modules/influxdb/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize
return &InfluxDbContainer{container}, nil
}

func (c *InfluxDbContainer) MustConnectionUrl(ctx context.Context, tls bool) string {
connectionString, err := c.ConnectionUrl(ctx, tls)
func (c *InfluxDbContainer) MustConnectionUrl(ctx context.Context) string {
connectionString, err := c.ConnectionUrl(ctx)
if err != nil {
panic(err)
}
return connectionString
}

func (c *InfluxDbContainer) ConnectionUrl(ctx context.Context, tls bool) (string, error) {
func (c *InfluxDbContainer) ConnectionUrl(ctx context.Context) (string, error) {
containerPort, err := c.MappedPort(ctx, "8086/tcp")
if err != nil {
return "", err
Expand All @@ -103,12 +103,7 @@ func (c *InfluxDbContainer) ConnectionUrl(ctx context.Context, tls bool) (string
return "", err
}

scheme := "http"
if tls {
scheme = "https"
}

return fmt.Sprintf("%s://%s:%s", scheme, host, containerPort.Port()), nil
return fmt.Sprintf("http://%s:%s", host, containerPort.Port()), nil
}

func WithUsername(username string) testcontainers.CustomizeRequestOption {
Expand Down
4 changes: 2 additions & 2 deletions modules/influxdb/influxdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestWithInitDb(t *testing.T) {
}

cli, err := influxclient.NewHTTPClient(influxclient.HTTPConfig{
Addr: influxDbContainer.MustConnectionUrl(ctx, false),
Addr: influxDbContainer.MustConnectionUrl(ctx),
})
require.NoError(t, err)
defer cli.Close()
Expand Down Expand Up @@ -112,7 +112,7 @@ func TestWithConfigFile(t *testing.T) {

/// influxConnectionUrl {
cli, err := influxclient.NewHTTPClient(influxclient.HTTPConfig{
Addr: influxDbContainer.MustConnectionUrl(context.Background(), false),
Addr: influxDbContainer.MustConnectionUrl(context.Background()),
})
// }
require.NoError(t, err)
Expand Down

0 comments on commit ceec832

Please sign in to comment.