PodSandboxConfig generates a pod sandbox config for test.
(name, ns string, opts ...PodSandboxOpts)
| 284 | |
| 285 | // PodSandboxConfig generates a pod sandbox config for test. |
| 286 | func 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 | |
| 314 | func PodSandboxConfigWithCleanup(t *testing.T, name, ns string, opts ...PodSandboxOpts) (string, *runtime.PodSandboxConfig) { |
| 315 | sbConfig := PodSandboxConfig(name, ns, opts...) |
no test coverage detected
searching dependent graphs…