mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
specgenutil: record the pod userns in the annotations
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -516,6 +516,10 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions
|
|||||||
if len(s.Annotations) == 0 {
|
if len(s.Annotations) == 0 {
|
||||||
s.Annotations = annotations
|
s.Annotations = annotations
|
||||||
}
|
}
|
||||||
|
// Add the user namespace configuration to the annotations
|
||||||
|
if c.UserNS != "" {
|
||||||
|
s.Annotations[define.UserNsAnnotation] = c.UserNS
|
||||||
|
}
|
||||||
|
|
||||||
if len(c.StorageOpts) > 0 {
|
if len(c.StorageOpts) > 0 {
|
||||||
opts := make(map[string]string, len(c.StorageOpts))
|
opts := make(map[string]string, len(c.StorageOpts))
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/containers/common/pkg/machine"
|
"github.com/containers/common/pkg/machine"
|
||||||
|
"github.com/containers/podman/v5/libpod/define"
|
||||||
"github.com/containers/podman/v5/pkg/domain/entities"
|
"github.com/containers/podman/v5/pkg/domain/entities"
|
||||||
"github.com/containers/podman/v5/pkg/specgen"
|
"github.com/containers/podman/v5/pkg/specgen"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -216,3 +217,16 @@ func TestGenRlimits(t *testing.T) {
|
|||||||
_, err = GenRlimits([]string{"nofile=bar:buzz"})
|
_, err = GenRlimits([]string{"nofile=bar:buzz"})
|
||||||
assert.Error(t, err, "err is not nil")
|
assert.Error(t, err, "err is not nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFillOutSpecGenRecorsUserNs(t *testing.T) {
|
||||||
|
sg := specgen.NewSpecGenerator("nothing", false)
|
||||||
|
err := FillOutSpecGen(sg, &entities.ContainerCreateOptions{
|
||||||
|
ImageVolume: "ignore",
|
||||||
|
UserNS: "keep-id",
|
||||||
|
}, []string{})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
v, ok := sg.Annotations[define.UserNsAnnotation]
|
||||||
|
assert.True(t, ok, "UserNsAnnotation is set")
|
||||||
|
assert.Equal(t, "keep-id", v, "UserNsAnnotation is keep-id")
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user