github.com/rumpl/bof@v23.0.0-rc.2+incompatible/integration/internal/container/ns.go (about) 1 package container 2 3 import ( 4 "context" 5 "strings" 6 "testing" 7 8 "github.com/docker/docker/client" 9 "gotest.tools/v3/assert" 10 is "gotest.tools/v3/assert/cmp" 11 ) 12 13 // GetContainerNS gets the value of the specified namespace of a container 14 func GetContainerNS(ctx context.Context, t *testing.T, client client.APIClient, cID, nsName string) string { 15 t.Helper() 16 res, err := Exec(ctx, client, cID, []string{"readlink", "/proc/self/ns/" + nsName}) 17 assert.NilError(t, err) 18 assert.Assert(t, is.Len(res.Stderr(), 0)) 19 assert.Equal(t, 0, res.ExitCode) 20 return strings.TrimSpace(res.Stdout()) 21 }