MCPcopy Index your code
hub / github.com/containerd/containerd / PodSandboxConfig

Function PodSandboxConfig

integration/main_test.go:286–312  ·  view source on GitHub ↗

PodSandboxConfig generates a pod sandbox config for test.

(name, ns string, opts ...PodSandboxOpts)

Source from the content-addressed store, hash-verified

284
285// PodSandboxConfig generates a pod sandbox config for test.
286func PodSandboxConfig(name, ns string, opts ...PodSandboxOpts) *runtime.PodSandboxConfig {
287 var cgroupParent string
288 runtimeConfig, err := runtimeService.RuntimeConfig(&runtime.RuntimeConfigRequest{})
289 if err != nil {
290 log.L.WithError(err).Errorf("runtime service call RuntimeConfig error")
291 } else if runtimeConfig.GetLinux().GetCgroupDriver() == runtime.CgroupDriver_SYSTEMD {
292 cgroupParent = defaultCgroupSystemdParent
293 }
294 config := &runtime.PodSandboxConfig{
295 Metadata: &runtime.PodSandboxMetadata{
296 Name: name,
297 // Using random id as uuid is good enough for local
298 // integration test.
299 Uid: util.GenerateID(),
300 Namespace: Randomize(ns),
301 },
302 Linux: &runtime.LinuxPodSandboxConfig{
303 CgroupParent: cgroupParent,
304 },
305 Annotations: make(map[string]string),
306 Labels: make(map[string]string),
307 }
308 for _, opt := range opts {
309 opt(config)
310 }
311 return config
312}
313
314func PodSandboxConfigWithCleanup(t *testing.T, name, ns string, opts ...PodSandboxOpts) (string, *runtime.PodSandboxConfig) {
315 sbConfig := PodSandboxConfig(name, ns, opts...)

Calls 2

RandomizeFunction · 0.85
RuntimeConfigMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…