@@ -22,6 +22,7 @@ import (
2222 "k8s.io/apimachinery/pkg/runtime"
2323 "k8s.io/apimachinery/pkg/types"
2424
25+ clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2526 runtimecatalog "sigs.k8s.io/cluster-api/exp/runtime/catalog"
2627)
2728
@@ -179,6 +180,32 @@ type HolderReference struct {
179180// ValidateTopology validates the Cluster topology after all patches have been applied.
180181func ValidateTopology (* ValidateTopologyRequest , * ValidateTopologyResponse ) {}
181182
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+
182209func init () {
183210 catalogBuilder .RegisterHook (GeneratePatches , & runtimecatalog.HookMeta {
184211 Tags : []string {"Topology Mutation Hook" },
@@ -203,4 +230,13 @@ func init() {
203230 "- The call's request contains all templates, the global variables and the template-specific variables used while computing patches\n " +
204231 "- The response must contain the result of the validation" ,
205232 })
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+ })
206242}
0 commit comments