Skip to content
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

Support for cap-add/cap-drop #555

Merged
merged 4 commits into from Oct 7, 2022
Merged

Conversation

dhuckins
Copy link
Contributor

@dhuckins dhuckins commented Oct 6, 2022

context from slack

adds cap-add/cap-drop to container request and passes to docker host config

Signed-off-by: Daniel Huckins <dhuckins@users.noreply.github.com>
@dhuckins dhuckins requested a review from a team as a code owner October 6, 2022 14:45
@codecov
Copy link

codecov bot commented Oct 6, 2022

Codecov Report

Merging #555 (537c95e) into main (66fed81) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #555      +/-   ##
==========================================
+ Coverage   69.01%   69.04%   +0.02%     
==========================================
  Files          22       22              
  Lines        2172     2174       +2     
==========================================
+ Hits         1499     1501       +2     
  Misses        535      535              
  Partials      138      138              
Impacted Files Coverage Δ
container.go 80.72% <ø> (ø)
docker.go 71.73% <100.00%> (+0.05%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@mdelapenya mdelapenya self-assigned this Oct 6, 2022
@mdelapenya mdelapenya added the feature New functionality or new behaviors on the existing one label Oct 6, 2022
@mdelapenya mdelapenya changed the title Cap-add/cap-drop Support for cap-add/cap-drop Oct 6, 2022
Copy link
Collaborator

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, although I encourage you to add a test :)

Take this as an example:

func TestDockerContainerResources(t *testing.T) {
if providerType == ProviderPodman {
t.Skip("Rootless Podman does not support setting rlimit")
}
ctx := context.Background()
expected := []*units.Ulimit{
{
Name: "memlock",
Hard: -1,
Soft: -1,
},
{
Name: "nofile",
Hard: 65536,
Soft: 65536,
},
}
nginxC, err := GenericContainer(ctx, GenericContainerRequest{
ProviderType: providerType,
ContainerRequest: ContainerRequest{
Image: nginxAlpineImage,
ExposedPorts: []string{nginxDefaultPort},
WaitingFor: wait.ForListeningPort(nginxDefaultPort),
Resources: container.Resources{
Ulimits: expected,
},
},
Started: true,
})
require.NoError(t, err)
terminateContainerOnEnd(t, ctx, nginxC)
c, err := client.NewClientWithOpts(client.FromEnv)
require.NoError(t, err)
c.NegotiateAPIVersion(ctx)
containerID := nginxC.GetContainerID()
resp, err := c.ContainerInspect(ctx, containerID)
require.NoError(t, err)
assert.Equal(t, expected, resp.HostConfig.Ulimits)
}

Signed-off-by: Daniel Huckins <dhuckins@users.noreply.github.com>
@dhuckins
Copy link
Contributor Author

dhuckins commented Oct 7, 2022

@mdelapenya added test

Copy link
Collaborator

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks taking the time to contribute this ❤️

LGTM!

@mdelapenya mdelapenya merged commit 917b257 into testcontainers:main Oct 7, 2022
@dhuckins dhuckins deleted the cap-add branch October 7, 2022 16:18
mdelapenya referenced this pull request in mdelapenya/testcontainers-go Dec 21, 2022
* main:
  Add system requirements parent docs page for podman and colima (#562)
  Support for cap-add/cap-drop (#555)
  fix container NetworkMode usage (#560)
  chore: use hashed versions of test-summary action (#556)
  chore: use container.State() function in tests (#543)
  Log docker server info (#548)
  docs: add docs regarding Colima usage (#547)
  chore: add emoji to breaking changes in release drafter (#542)
  chore: add CONTRIBUTING file (#539)
  issue #537 Rename the wait/multi.go file to wait/all.go (#541)
  docs: add a basic layout for wait strategies in docs (#536)
  docs: improve consistency and fix typos (#534)
  chore: do not skip test (#528)
  chore: include test flakiness in the release drafter (#535)
  chore: retire old versions of Go (#530)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or new behaviors on the existing one
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants