@@ -22,6 +22,7 @@ import (
22
22
"k8s.io/apimachinery/pkg/runtime"
23
23
"k8s.io/apimachinery/pkg/types"
24
24
25
+ clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
25
26
runtimecatalog "sigs.k8s.io/cluster-api/exp/runtime/catalog"
26
27
)
27
28
@@ -179,6 +180,32 @@ type HolderReference struct {
179
180
// ValidateTopology validates the Cluster topology after all patches have been applied.
180
181
func ValidateTopology (* ValidateTopologyRequest , * ValidateTopologyResponse ) {}
181
182
183
+ // DiscoverVariablesRequest is the request of the DiscoverVariables hook.
184
+ // +kubebuilder:object:root=true
185
+ type DiscoverVariablesRequest struct {
186
+ metav1.TypeMeta `json:",inline"`
187
+
188
+ // CommonRequest contains Settings field common to all request types.
189
+ CommonRequest `json:",inline"`
190
+ }
191
+
192
+ // DiscoverVariablesResponse is the response of the DiscoverVariables hook.
193
+ // +kubebuilder:object:root=true
194
+ type DiscoverVariablesResponse struct {
195
+ metav1.TypeMeta `json:",inline"`
196
+
197
+ // CommonResponse contains Status and Message fields common to all response types.
198
+ CommonResponse `json:",inline"`
199
+
200
+ // Variables are variable schemas for variables defined by the DiscoverVariables hook.
201
+ Variables []clusterv1.ClusterClassVariable `json:"variables"`
202
+ }
203
+
204
+ var _ ResponseObject = & DiscoverVariablesResponse {}
205
+
206
+ // DiscoverVariables returns variable schemas defined by a Runtime Extension.
207
+ func DiscoverVariables (* DiscoverVariablesRequest , * DiscoverVariablesResponse ) {}
208
+
182
209
func init () {
183
210
catalogBuilder .RegisterHook (GeneratePatches , & runtimecatalog.HookMeta {
184
211
Tags : []string {"Topology Mutation Hook" },
@@ -203,4 +230,13 @@ func init() {
203
230
"- The call's request contains all templates, the global variables and the template-specific variables used while computing patches\n " +
204
231
"- The response must contain the result of the validation" ,
205
232
})
233
+
234
+ catalogBuilder .RegisterHook (DiscoverVariables , & runtimecatalog.HookMeta {
235
+ Tags : []string {"Topology Mutation Hook" },
236
+ Summary : "Cluster API Runtime will call this hook when ClusterClass variables are being computed" ,
237
+ Description : "Cluster API Runtime will call this hook when ClusterClass variables are being computed " +
238
+ "during the ClusterClass reconcile loop." +
239
+ "Notes:\n " +
240
+ "- The response must contain the schemas of all variables defined by the patch." ,
241
+ })
206
242
}
0 commit comments