@@ -98,7 +98,11 @@ func (a *Server) WithResourceAndStrategy(obj resource.Object, strategy rest.Stra
98
98
_ = a .forGroupVersionResource (gvr , parentStorageProvider )
99
99
100
100
// automatically create status subresource if the object implements the status interface
101
- a .withSubResourceIfExists (obj , parentStorageProvider )
101
+
102
+ defer func () {
103
+ // automatically create status subresource if the object implements the status interface
104
+ a .withSubResourceIfExists (obj , parentStorageProvider )
105
+ }()
102
106
return a
103
107
}
104
108
@@ -112,6 +116,10 @@ func (a *Server) WithResourceAndStrategy(obj resource.Object, strategy rest.Stra
112
116
func (a * Server ) WithResourceAndHandler (obj resource.Object , sp rest.ResourceHandlerProvider ) * Server {
113
117
gvr := obj .GetGroupVersionResource ()
114
118
a .schemeBuilder .Register (resource .AddToScheme (obj ))
119
+ defer func () {
120
+ // automatically create status subresource if the object implements the status interface
121
+ a .withSubResourceIfExists (obj , sp )
122
+ }()
115
123
return a .forGroupVersionResource (gvr , sp )
116
124
}
117
125
@@ -126,7 +134,12 @@ func (a *Server) WithResourceAndHandler(obj resource.Object, sp rest.ResourceHan
126
134
func (a * Server ) WithResourceAndStorage (obj resource.Object , fn rest.StoreFn ) * Server {
127
135
gvr := obj .GetGroupVersionResource ()
128
136
a .schemeBuilder .Register (resource .AddToScheme (obj ))
129
- return a .forGroupVersionResource (gvr , rest .NewWithFn (obj , fn ))
137
+ sp := rest .NewWithFn (obj , fn )
138
+ defer func () {
139
+ // automatically create status subresource if the object implements the status interface
140
+ a .withSubResourceIfExists (obj , sp )
141
+ }()
142
+ return a .forGroupVersionResource (gvr , sp )
130
143
}
131
144
132
145
// forGroupVersionResource manually registers storage for a specific resource.
0 commit comments