blob: 05724fc7c27cfbdbc031a0c0c883f3948978f1bd [file] [log] [blame]
Jan Schära48bd3c2024-07-29 17:22:18 +02001// Package object holds functions that convert the objects from the k8s API in
2// to a more memory efficient structures.
3//
4// Adding new fields to any of the structures defined in pod.go, endpoint.go
5// and service.go should not be done lightly as this increases the memory use
6// and will leads to OOMs in the k8s scale test.
7package object
8
9// Taken and modified from the Kubernetes plugin of CoreDNS, under Apache 2.0.
10
11import (
12 v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13 "k8s.io/apimachinery/pkg/runtime/schema"
14 "k8s.io/apimachinery/pkg/types"
15 "k8s.io/client-go/tools/cache"
16)
17
18// ToFunc converts one v1.Object to another v1.Object.
19type ToFunc func(v1.Object) (v1.Object, error)
20
21// ProcessorBuilder returns function to process cache events.
22type ProcessorBuilder func(cache.Indexer, cache.ResourceEventHandler) cache.ProcessFunc
23
24// Empty is an empty struct.
25type Empty struct{}
26
27// GetObjectKind implements the ObjectKind interface as a noop.
28func (e *Empty) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind }
29
30// GetGenerateName implements the metav1.Object interface.
31func (e *Empty) GetGenerateName() string { return "" }
32
33// SetGenerateName implements the metav1.Object interface.
34func (e *Empty) SetGenerateName(name string) {}
35
36// GetUID implements the metav1.Object interface.
37func (e *Empty) GetUID() types.UID { return "" }
38
39// SetUID implements the metav1.Object interface.
40func (e *Empty) SetUID(uid types.UID) {}
41
42// GetGeneration implements the metav1.Object interface.
43func (e *Empty) GetGeneration() int64 { return 0 }
44
45// SetGeneration implements the metav1.Object interface.
46func (e *Empty) SetGeneration(generation int64) {}
47
48// GetSelfLink implements the metav1.Object interface.
49func (e *Empty) GetSelfLink() string { return "" }
50
51// SetSelfLink implements the metav1.Object interface.
52func (e *Empty) SetSelfLink(selfLink string) {}
53
54// GetCreationTimestamp implements the metav1.Object interface.
55func (e *Empty) GetCreationTimestamp() v1.Time { return v1.Time{} }
56
57// SetCreationTimestamp implements the metav1.Object interface.
58func (e *Empty) SetCreationTimestamp(timestamp v1.Time) {}
59
60// GetDeletionTimestamp implements the metav1.Object interface.
61func (e *Empty) GetDeletionTimestamp() *v1.Time { return &v1.Time{} }
62
63// SetDeletionTimestamp implements the metav1.Object interface.
64func (e *Empty) SetDeletionTimestamp(timestamp *v1.Time) {}
65
66// GetDeletionGracePeriodSeconds implements the metav1.Object interface.
67func (e *Empty) GetDeletionGracePeriodSeconds() *int64 { return nil }
68
69// SetDeletionGracePeriodSeconds implements the metav1.Object interface.
70func (e *Empty) SetDeletionGracePeriodSeconds(*int64) {}
71
72// GetLabels implements the metav1.Object interface.
73func (e *Empty) GetLabels() map[string]string { return nil }
74
75// SetLabels implements the metav1.Object interface.
76func (e *Empty) SetLabels(labels map[string]string) {}
77
78// GetAnnotations implements the metav1.Object interface.
79func (e *Empty) GetAnnotations() map[string]string { return nil }
80
81// SetAnnotations implements the metav1.Object interface.
82func (e *Empty) SetAnnotations(annotations map[string]string) {}
83
84// GetFinalizers implements the metav1.Object interface.
85func (e *Empty) GetFinalizers() []string { return nil }
86
87// SetFinalizers implements the metav1.Object interface.
88func (e *Empty) SetFinalizers(finalizers []string) {}
89
90// GetOwnerReferences implements the metav1.Object interface.
91func (e *Empty) GetOwnerReferences() []v1.OwnerReference { return nil }
92
93// SetOwnerReferences implements the metav1.Object interface.
94func (e *Empty) SetOwnerReferences([]v1.OwnerReference) {}
95
96// GetZZZ_DeprecatedClusterName implements the metav1.Object interface.
97func (e *Empty) GetZZZ_DeprecatedClusterName() string { return "" }
98
99// SetZZZ_DeprecatedClusterName implements the metav1.Object interface.
100func (e *Empty) SetZZZ_DeprecatedClusterName(clusterName string) {}
101
102// GetManagedFields implements the metav1.Object interface.
103func (e *Empty) GetManagedFields() []v1.ManagedFieldsEntry { return nil }
104
105// SetManagedFields implements the metav1.Object interface.
106func (e *Empty) SetManagedFields(managedFields []v1.ManagedFieldsEntry) {}