...
1
16
17 package testing
18
19 import (
20 "context"
21
22 v1 "k8s.io/api/core/v1"
23 kubetypes "k8s.io/apimachinery/pkg/types"
24 runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
25 kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
26 )
27
28
29 type FakeRuntimeHelper struct {
30 DNSServers []string
31 DNSSearches []string
32 DNSOptions []string
33 HostName string
34 HostDomain string
35 PodContainerDir string
36 Err error
37 }
38
39 func (f *FakeRuntimeHelper) GenerateRunContainerOptions(_ context.Context, pod *v1.Pod, container *v1.Container, podIP string, podIPs []string) (*kubecontainer.RunContainerOptions, func(), error) {
40 var opts kubecontainer.RunContainerOptions
41 if len(container.TerminationMessagePath) != 0 {
42 opts.PodContainerDir = f.PodContainerDir
43 }
44 return &opts, nil, nil
45 }
46
47 func (f *FakeRuntimeHelper) GetPodCgroupParent(pod *v1.Pod) string {
48 return ""
49 }
50
51 func (f *FakeRuntimeHelper) GetPodDNS(pod *v1.Pod) (*runtimeapi.DNSConfig, error) {
52 return &runtimeapi.DNSConfig{
53 Servers: f.DNSServers,
54 Searches: f.DNSSearches,
55 Options: f.DNSOptions}, f.Err
56 }
57
58
59 func (f *FakeRuntimeHelper) GeneratePodHostNameAndDomain(pod *v1.Pod) (string, string, error) {
60 return f.HostName, f.HostDomain, f.Err
61 }
62
63 func (f *FakeRuntimeHelper) GetPodDir(podUID kubetypes.UID) string {
64 return "/poddir/" + string(podUID)
65 }
66
67 func (f *FakeRuntimeHelper) GetExtraSupplementalGroupsForPod(pod *v1.Pod) []int64 {
68 return nil
69 }
70
71 func (f *FakeRuntimeHelper) GetOrCreateUserNamespaceMappings(pod *v1.Pod, runtimeHandler string) (*runtimeapi.UserNamespace, error) {
72 return nil, nil
73 }
74
75 func (f *FakeRuntimeHelper) PrepareDynamicResources(pod *v1.Pod) error {
76 return nil
77 }
78
79 func (f *FakeRuntimeHelper) UnprepareDynamicResources(pod *v1.Pod) error {
80 return nil
81 }
82
View as plain text