-
-
Notifications
You must be signed in to change notification settings - Fork 499
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
chore: deprecate BindMount APIs #1907
Merged
mdelapenya
merged 4 commits into
testcontainers:main
from
mdelapenya:deprecate-mount-apis
Nov 8, 2023
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ import ( | |
"github.com/docker/docker/api/types" | ||
"github.com/docker/docker/api/types/container" | ||
"github.com/docker/docker/api/types/strslice" | ||
"github.com/docker/docker/api/types/volume" | ||
"github.com/docker/docker/errdefs" | ||
"github.com/docker/go-units" | ||
"github.com/stretchr/testify/assert" | ||
|
@@ -142,8 +141,13 @@ func TestContainerWithHostNetworkOptions(t *testing.T) { | |
gcr := GenericContainerRequest{ | ||
ProviderType: providerType, | ||
ContainerRequest: ContainerRequest{ | ||
Image: nginxAlpineImage, | ||
Mounts: Mounts(BindMount(absPath, "/etc/nginx/conf.d/default.conf")), | ||
Image: nginxAlpineImage, | ||
Files: []ContainerFile{ | ||
{ | ||
HostFilePath: absPath, | ||
ContainerFilePath: "/etc/nginx/conf.d/default.conf", | ||
}, | ||
}, | ||
ExposedPorts: []string{ | ||
nginxHighPort, | ||
}, | ||
|
@@ -258,7 +262,12 @@ func TestContainerWithHostNetwork(t *testing.T) { | |
ContainerRequest: ContainerRequest{ | ||
Image: nginxAlpineImage, | ||
WaitingFor: wait.ForListeningPort(nginxHighPort), | ||
Mounts: Mounts(BindMount(absPath, "/etc/nginx/conf.d/default.conf")), | ||
Files: []ContainerFile{ | ||
{ | ||
HostFilePath: absPath, | ||
ContainerFilePath: "/etc/nginx/conf.d/default.conf", | ||
}, | ||
}, | ||
HostConfigModifier: func(hc *container.HostConfig) { | ||
hc.NetworkMode = "host" | ||
}, | ||
|
@@ -1187,43 +1196,29 @@ func ExampleContainer_MappedPort() { | |
// } | ||
} | ||
|
||
func TestContainerCreationWithBindAndVolume(t *testing.T) { | ||
func TestContainerCreationWithVolumeAndFileWritingToIt(t *testing.T) { | ||
absPath, err := filepath.Abs(filepath.Join(".", "testdata", "hello.sh")) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
ctx, cnl := context.WithTimeout(context.Background(), 30*time.Second) | ||
defer cnl() | ||
// Create a Docker client. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to instantiate a client for the volume, as Docker will handle the mounts correctly. |
||
dockerCli, err := NewDockerClientWithOpts(context.Background()) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// Create the volume. | ||
vol, err := dockerCli.VolumeCreate(ctx, volume.CreateOptions{ | ||
Driver: "local", | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
volumeName := vol.Name | ||
t.Cleanup(func() { | ||
ctx, cnl := context.WithTimeout(context.Background(), 5*time.Second) | ||
defer cnl() | ||
defer dockerCli.Close() | ||
volumeName := "volumeName" | ||
|
||
err := dockerCli.VolumeRemove(ctx, volumeName, true) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
}) | ||
// Create the container that writes into the mounted volume. | ||
bashC, err := GenericContainer(ctx, GenericContainerRequest{ | ||
ProviderType: providerType, | ||
ContainerRequest: ContainerRequest{ | ||
Image: "docker.io/bash", | ||
Mounts: Mounts(BindMount(absPath, "/hello.sh"), VolumeMount(volumeName, "/data")), | ||
Image: "docker.io/bash", | ||
Files: []ContainerFile{ | ||
{ | ||
HostFilePath: absPath, | ||
ContainerFilePath: "/hello.sh", | ||
}, | ||
}, | ||
Mounts: Mounts(VolumeMount(volumeName, "/data")), | ||
Cmd: []string{"bash", "/hello.sh"}, | ||
WaitingFor: wait.ForLog("done"), | ||
}, | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I think the validation functions are very little useful, as they actually do too few checks.
We probably need a follow up discussion to remove it or rethink what to check here