Skip to content

Commit

Permalink
chore: use the new Inspect method instead
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed May 7, 2024
1 parent d86e692 commit c38bbc1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
1 change: 0 additions & 1 deletion container.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ type Container interface {
CopyFileToContainer(ctx context.Context, hostFilePath string, containerFilePath string, fileMode int64) error
CopyFileFromContainer(ctx context.Context, filePath string) (io.ReadCloser, error)
GetLogProductionErrorChannel() <-chan error
Hostname(ctx context.Context) (string, error)
}

// ImageBuildInfo defines what is needed to build an image
Expand Down
9 changes: 0 additions & 9 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,6 @@ func (c *DockerContainer) Name(ctx context.Context) (string, error) {
return inspect.Name, nil
}

// Hostname gets the name of the container.
func (c *DockerContainer) Hostname(ctx context.Context) (string, error) {
inspect, err := c.Inspect(ctx)
if err != nil {
return "", err
}
return inspect.Config.Hostname, nil
}

// State returns container's running state. This method does not use the cache
// and always fetches the latest state from the Docker daemon.
func (c *DockerContainer) State(ctx context.Context) (*types.ContainerState, error) {
Expand Down
4 changes: 3 additions & 1 deletion modules/kafka/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize
return err
}

hostname, err := c.Hostname(ctx)
inspect, err := c.Inspect(ctx)
if err != nil {
return err
}

hostname := inspect.Config.Hostname

port, err := c.MappedPort(ctx, publicPort)
if err != nil {
return err
Expand Down

0 comments on commit c38bbc1

Please sign in to comment.