@@ -24,6 +24,8 @@ pub static DOCUMENT_FINALIZER: &str = "documents.kube.rs";
24
24
/// Generate the Kubernetes wrapper struct `Document` from our Spec and Status struct
25
25
///
26
26
/// This provides a hook for generating the CRD yaml (in crdgen.rs)
27
+ /// NB: CustomResource generates a pub struct Document here
28
+ /// To query for documents.kube.rs with kube, use Api<Document>.
27
29
#[ derive( CustomResource , Deserialize , Serialize , Clone , Debug , JsonSchema ) ]
28
30
#[ cfg_attr( test, derive( Default ) ) ]
29
31
#[ kube( kind = "Document" , group = "kube.rs" , version = "v1" , namespaced) ]
@@ -88,7 +90,8 @@ impl Document {
88
90
// Reconcile (for non-finalizer related changes)
89
91
async fn reconcile ( & self , ctx : Arc < Context > ) -> Result < Action > {
90
92
let client = ctx. client . clone ( ) ;
91
- let recorder = ctx. diagnostics . read ( ) . await . recorder ( client. clone ( ) , self ) ;
93
+ let recorder = ctx. diagnostics . read ( ) . await . recorder ( client. clone ( ) ) ;
94
+ let oref = self . object_ref ( & ( ) ) ;
92
95
let ns = self . namespace ( ) . unwrap ( ) ;
93
96
let name = self . name_any ( ) ;
94
97
let docs: Api < Document > = Api :: namespaced ( client, & ns) ;
@@ -97,13 +100,16 @@ impl Document {
97
100
if !self . was_hidden ( ) && should_hide {
98
101
// send an event once per hide
99
102
recorder
100
- . publish ( Event {
101
- type_ : EventType :: Normal ,
102
- reason : "HideRequested" . into ( ) ,
103
- note : Some ( format ! ( "Hiding `{name}`" ) ) ,
104
- action : "Hiding" . into ( ) ,
105
- secondary : None ,
106
- } )
103
+ . publish (
104
+ Event {
105
+ type_ : EventType :: Normal ,
106
+ reason : "HideRequested" . into ( ) ,
107
+ note : Some ( format ! ( "Hiding `{name}`" ) ) ,
108
+ action : "Hiding" . into ( ) ,
109
+ secondary : None ,
110
+ } ,
111
+ & oref,
112
+ )
107
113
. await
108
114
. map_err ( Error :: KubeError ) ?;
109
115
}
@@ -130,16 +136,20 @@ impl Document {
130
136
131
137
// Finalizer cleanup (the object was deleted, ensure nothing is orphaned)
132
138
async fn cleanup ( & self , ctx : Arc < Context > ) -> Result < Action > {
133
- let recorder = ctx. diagnostics . read ( ) . await . recorder ( ctx. client . clone ( ) , self ) ;
139
+ let recorder = ctx. diagnostics . read ( ) . await . recorder ( ctx. client . clone ( ) ) ;
140
+ let oref = self . object_ref ( & ( ) ) ;
134
141
// Document doesn't have any real cleanup, so we just publish an event
135
142
recorder
136
- . publish ( Event {
137
- type_ : EventType :: Normal ,
138
- reason : "DeleteRequested" . into ( ) ,
139
- note : Some ( format ! ( "Delete `{}`" , self . name_any( ) ) ) ,
140
- action : "Deleting" . into ( ) ,
141
- secondary : None ,
142
- } )
143
+ . publish (
144
+ Event {
145
+ type_ : EventType :: Normal ,
146
+ reason : "DeleteRequested" . into ( ) ,
147
+ note : Some ( format ! ( "Delete `{}`" , self . name_any( ) ) ) ,
148
+ action : "Deleting" . into ( ) ,
149
+ secondary : None ,
150
+ } ,
151
+ & oref,
152
+ )
143
153
. await
144
154
. map_err ( Error :: KubeError ) ?;
145
155
Ok ( Action :: await_change ( ) )
@@ -163,8 +173,8 @@ impl Default for Diagnostics {
163
173
}
164
174
}
165
175
impl Diagnostics {
166
- fn recorder ( & self , client : Client , doc : & Document ) -> Recorder {
167
- Recorder :: new ( client, self . reporter . clone ( ) , doc . object_ref ( & ( ) ) )
176
+ fn recorder ( & self , client : Client ) -> Recorder {
177
+ Recorder :: new ( client, self . reporter . clone ( ) )
168
178
}
169
179
}
170
180
0 commit comments