Skip to content

Commit

Permalink
Merge pull request #9284 from rhatdan/annotations
Browse files Browse the repository at this point in the history
Support annotations from containers.conf
  • Loading branch information
openshift-merge-robot authored Feb 9, 2021
2 parents 8600c3b + 46385dd commit 2d829ae
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/specgen/generate/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package generate
import (
"context"
"os"
"strings"

"github.com/containers/image/v5/manifest"
"github.com/containers/podman/v2/libpod"
Expand Down Expand Up @@ -197,6 +198,15 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat
annotations[ann.ContainerType] = ann.ContainerTypeContainer
}

for _, v := range rtc.Containers.Annotations {
split := strings.SplitN(v, "=", 2)
k := split[0]
v := ""
if len(split) == 2 {
v = split[1]
}
annotations[k] = v
}
// now pass in the values from client
for k, v := range s.Annotations {
annotations[k] = v
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/config/containers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ tz = "Pacific/Honolulu"

umask = "0002"

annotations=["run.oci.keep_original_groups=1",]

[engine]

network_cmd_options=["allow_host_loopback=true"]
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/containers_conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,15 @@ var _ = Describe("Podman run", func() {
Expect(session.OutputToString()).To(Equal("0022"))
})

It("podman run containers.conf annotations test", func() {
//containers.conf is set to "run.oci.keep_original_groups=1"
session := podmanTest.Podman([]string{"create", "--rm", "--name", "test", fedoraMinimal})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))

inspect := podmanTest.Podman([]string{"inspect", "--format", "{{ .Config.Annotations }}", "test"})
inspect.WaitWithDefaultTimeout()
Expect(inspect.OutputToString()).To(ContainSubstring("run.oci.keep_original_groups:1"))
})

})
6 changes: 6 additions & 0 deletions test/e2e/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ var _ = Describe("Podman run", func() {
It("podman run user capabilities test", func() {
// We need to ignore the containers.conf on the test distribution for this test
os.Setenv("CONTAINERS_CONF", "/dev/null")
if IsRemote() {
podmanTest.RestartRemoteService()
}
session := podmanTest.Podman([]string{"run", "--rm", "--user", "bin", ALPINE, "grep", "CapBnd", "/proc/self/status"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
Expand Down Expand Up @@ -424,6 +427,9 @@ var _ = Describe("Podman run", func() {
It("podman run user capabilities test with image", func() {
// We need to ignore the containers.conf on the test distribution for this test
os.Setenv("CONTAINERS_CONF", "/dev/null")
if IsRemote() {
podmanTest.RestartRemoteService()
}
dockerfile := `FROM busybox
USER bin`
podmanTest.BuildImage(dockerfile, "test", "false")
Expand Down

0 comments on commit 2d829ae

Please sign in to comment.