Skip to content

Commit

Permalink
chore: remove more deprecated types
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Jun 6, 2024
1 parent 47e2a9d commit d9c41c7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 67 deletions.
34 changes: 0 additions & 34 deletions mount/docker_mounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,11 @@ import (
)

var mountTypeMapping = map[Type]mount.Type{
TypeBind: mount.TypeBind, // Deprecated, it will be removed in a future release
TypeVolume: mount.TypeVolume,
TypeTmpfs: mount.TypeTmpfs,
TypePipe: mount.TypeNamedPipe,
}

// Deprecated: use Files or HostConfigModifier in the ContainerRequest, or copy files container APIs to make containers portable across Docker environments
// BindMounter can optionally be implemented by mount sources
// to support advanced scenarios based on mount.BindOptions
type BindMounter interface {
GetBindOptions() *mount.BindOptions
}

// VolumeMounter can optionally be implemented by mount sources
// to support advanced scenarios based on mount.VolumeOptions
type VolumeMounter interface {
Expand All @@ -32,30 +24,6 @@ type TmpfsMounter interface {
GetTmpfsOptions() *mount.TmpfsOptions
}

// Deprecated: use Files or HostConfigModifier in the ContainerRequest, or copy files container APIs to make containers portable across Docker environments
type DockerBindSource struct {
*mount.BindOptions

// HostPath is the path mounted into the container
// the same host path might be mounted to multiple locations within a single container
HostPath string
}

// Deprecated: use Files or HostConfigModifier in the ContainerRequest, or copy files container APIs to make containers portable across Docker environments
func (s DockerBindSource) Source() string {
return s.HostPath
}

// Deprecated: use Files or HostConfigModifier in the ContainerRequest, or copy files container APIs to make containers portable across Docker environments
func (DockerBindSource) Type() Type {
return TypeBind
}

// Deprecated: use Files or HostConfigModifier in the ContainerRequest, or copy files container APIs to make containers portable across Docker environments
func (s DockerBindSource) GetBindOptions() *mount.BindOptions {
return s.BindOptions
}

type DockerVolumeSource struct {
*mount.VolumeOptions

Expand Down Expand Up @@ -112,8 +80,6 @@ func (m ContainerMounts) Prepare() []mount.Mount {
containerMount.VolumeOptions = typedMounter.GetVolumeOptions()
case TmpfsMounter:
containerMount.TmpfsOptions = typedMounter.GetTmpfsOptions()
case BindMounter:
// Logger.Printf("Mount type %s is not supported by Testcontainers for Go", m.Source.Type())
default:
// The provided source type has no custom options
}
Expand Down
35 changes: 2 additions & 33 deletions mount/mounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package mount
import "errors"

const (
TypeBind Type = iota // Deprecated: Use TypeVolume instead
TypeVolume
TypeVolume Type = iota
TypeTmpfs
TypePipe
)
Expand All @@ -15,7 +14,6 @@ var (
)

var (
_ ContainerSource = (*GenericBindSource)(nil) // Deprecated: use Files or HostConfigModifier in the ContainerRequest, or copy files container APIs to make containers portable across Docker environments
_ ContainerSource = (*GenericVolumeSource)(nil)
_ ContainerSource = (*GenericTmpfsSource)(nil)
)
Expand All @@ -37,25 +35,6 @@ type ContainerSource interface {
Type() Type
}

// Deprecated: use Files or HostConfigModifier in the ContainerRequest, or copy files container APIs to make containers portable across Docker environments
// GenericBindSource implements ContainerSource and represents a bind mount
// Optionally mount.BindOptions might be added for advanced scenarios
type GenericBindSource struct {
// HostPath is the path mounted into the container
// the same host path might be mounted to multiple locations within a single container
HostPath string
}

// Deprecated: use Files or HostConfigModifier in the ContainerRequest, or copy files container APIs to make containers portable across Docker environments
func (s GenericBindSource) Source() string {
return s.HostPath
}

// Deprecated: use Files or HostConfigModifier in the ContainerRequest, or copy files container APIs to make containers portable across Docker environments
func (GenericBindSource) Type() Type {
return TypeBind
}

// GenericVolumeSource implements ContainerSource and represents a volume mount
type GenericVolumeSource struct {
// Name refers to the name of the volume to be mounted
Expand Down Expand Up @@ -91,16 +70,6 @@ func (t ContainerTarget) Target() string {
return string(t)
}

// Deprecated: use Files or HostConfigModifier in the ContainerRequest, or copy files container APIs to make containers portable across Docker environments
// BindMount returns a new ContainerMount with a GenericBindMountSource as source
// This is a convenience method to cover typical use cases.
func BindMount(hostPath string, mountTarget ContainerTarget) ContainerMount {
return ContainerMount{
Source: GenericBindSource{HostPath: hostPath},
Target: mountTarget,
}
}

// VolumeMount returns a new ContainerMount with a GenericVolumeMountSource as source
// This is a convenience method to cover typical use cases.
func VolumeMount(volumeName string, mountTarget ContainerTarget) ContainerMount {
Expand All @@ -117,7 +86,7 @@ func Mounts(mounts ...ContainerMount) ContainerMounts {

// ContainerMount models a mount into a container
type ContainerMount struct {
// Source is typically either a GenericVolumeSource, as BindMount is not supported by all Docker environments
// Source is typically either a GenericVolumeSource or a GenericTmpfsSource
Source ContainerSource
// Target is the path where the mount should be mounted within the container
Target ContainerTarget
Expand Down

0 comments on commit d9c41c7

Please sign in to comment.