Skip to content

Commit 14ffcb2

Browse files
authored
Merge pull request #7986 from killianmuldoon/pr-exvars-api-definition
🌱 Add API types for DiscoverVariables hook
2 parents 358a064 + 5dba291 commit 14ffcb2

File tree

3 files changed

+199
-0
lines changed

3 files changed

+199
-0
lines changed

exp/runtime/hooks/api/v1alpha1/topologymutation_types.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
180181
func 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+
182209
func 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
}

exp/runtime/hooks/api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exp/runtime/hooks/api/v1alpha1/zz_generated.openapi.go

Lines changed: 105 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)