...
1
16
17 package v1
18
19 import (
20 "k8s.io/apimachinery/pkg/conversion"
21 "k8s.io/apimachinery/pkg/runtime"
22 "k8s.io/apimachinery/pkg/runtime/schema"
23 "k8s.io/apimachinery/pkg/watch"
24 )
25
26
27
28
29
30
31 type WatchEvent struct {
32 Type string `json:"type" protobuf:"bytes,1,opt,name=type"`
33
34
35
36
37
38
39 Object runtime.RawExtension `json:"object" protobuf:"bytes,2,opt,name=object"`
40 }
41
42 func Convert_watch_Event_To_v1_WatchEvent(in *watch.Event, out *WatchEvent, s conversion.Scope) error {
43 out.Type = string(in.Type)
44 switch t := in.Object.(type) {
45 case *runtime.Unknown:
46
47 out.Object.Raw = t.Raw
48 case nil:
49 default:
50 out.Object.Object = in.Object
51 }
52 return nil
53 }
54
55 func Convert_v1_InternalEvent_To_v1_WatchEvent(in *InternalEvent, out *WatchEvent, s conversion.Scope) error {
56 return Convert_watch_Event_To_v1_WatchEvent((*watch.Event)(in), out, s)
57 }
58
59 func Convert_v1_WatchEvent_To_watch_Event(in *WatchEvent, out *watch.Event, s conversion.Scope) error {
60 out.Type = watch.EventType(in.Type)
61 if in.Object.Object != nil {
62 out.Object = in.Object.Object
63 } else if in.Object.Raw != nil {
64
65 out.Object = &runtime.Unknown{
66 Raw: in.Object.Raw,
67 ContentType: runtime.ContentTypeJSON,
68 }
69 }
70 return nil
71 }
72
73 func Convert_v1_WatchEvent_To_v1_InternalEvent(in *WatchEvent, out *InternalEvent, s conversion.Scope) error {
74 return Convert_v1_WatchEvent_To_watch_Event(in, (*watch.Event)(out), s)
75 }
76
77
78
79 type InternalEvent watch.Event
80
81 func (e *InternalEvent) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind }
82 func (e *WatchEvent) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind }
83 func (e *InternalEvent) DeepCopyObject() runtime.Object {
84 if c := e.DeepCopy(); c != nil {
85 return c
86 } else {
87 return nil
88 }
89 }
90
View as plain text