Skip to content

Commit f73b00d

Browse files
authored
Merge pull request #7562 from ykakarap/runtimesdk-runtimeextensions-settings
✨ add Settings support to RuntimeExtensions
2 parents a9c2e40 + 95158a3 commit f73b00d

26 files changed

+625
-29
lines changed

api/v1beta1/clusterclass_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,12 @@ type ExternalPatchDefinition struct {
532532
// ValidateExtension references an extension which is called to validate the topology.
533533
// +optional
534534
ValidateExtension *string `json:"validateExtension,omitempty"`
535+
536+
// Settings defines key value pairs to be passed to the extensions.
537+
// Values defined here take precedence over the values defined in the
538+
// corresponding ExtensionConfig.
539+
// +optional
540+
Settings map[string]string `json:"settings,omitempty"`
535541
}
536542

537543
// LocalObjectTemplate defines a template for a topology Class.

api/v1beta1/zz_generated.deepcopy.go

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

api/v1beta1/zz_generated.openapi.go

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

config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml

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

config/crd/bases/runtime.cluster.x-k8s.io_extensionconfigs.yaml

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

exp/runtime/api/v1alpha1/extensionconfig_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ type ExtensionConfigSpec struct {
3434
// Defaults to the empty LabelSelector, which matches all objects.
3535
// +optional
3636
NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"`
37+
38+
// Settings defines key value pairs to be passed to all calls
39+
// to all supported RuntimeExtensions.
40+
// Note: Settings can be overridden on the ClusterClass.
41+
// +optional
42+
Settings map[string]string `json:"settings,omitempty"`
3743
}
3844

3945
// ClientConfig contains the information to make a client

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

Lines changed: 7 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/common_types.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,33 @@ import (
2020
"k8s.io/apimachinery/pkg/runtime"
2121
)
2222

23+
// RequestObject is a runtime.Object extended with methods to handle request-specific fields.
24+
// +kubebuilder:object:generate=false
25+
type RequestObject interface {
26+
runtime.Object
27+
GetSettings() map[string]string
28+
SetSettings(settings map[string]string)
29+
}
30+
31+
// CommonRequest is the data structure common to all request types.
32+
// Note: By embedding CommonRequest in a runtime.Object the RequestObject
33+
// interface is satisfied.
34+
type CommonRequest struct {
35+
// Settings defines key value pairs to be passed to the call.
36+
// +optional
37+
Settings map[string]string `json:"settings,omitempty"`
38+
}
39+
40+
// GetSettings get the Settings field from the CommonRequest.
41+
func (r *CommonRequest) GetSettings() map[string]string {
42+
return r.Settings
43+
}
44+
45+
// SetSettings sets the Settings field in the CommonRequest.
46+
func (r *CommonRequest) SetSettings(settings map[string]string) {
47+
r.Settings = settings
48+
}
49+
2350
// ResponseObject is a runtime.Object extended with methods to handle response-specific fields.
2451
// +kubebuilder:object:generate=false
2552
type ResponseObject interface {

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ import (
2828
type BeforeClusterCreateRequest struct {
2929
metav1.TypeMeta `json:",inline"`
3030

31+
// CommonRequest contains fields common to all request types.
32+
CommonRequest `json:",inline"`
33+
3134
// Cluster is the cluster object the lifecycle hook corresponds to.
3235
Cluster clusterv1.Cluster `json:"cluster"`
3336
}
@@ -51,6 +54,9 @@ func BeforeClusterCreate(*BeforeClusterCreateRequest, *BeforeClusterCreateRespon
5154
type AfterControlPlaneInitializedRequest struct {
5255
metav1.TypeMeta `json:",inline"`
5356

57+
// CommonRequest contains fields common to all request types.
58+
CommonRequest `json:",inline"`
59+
5460
// Cluster is the cluster object the lifecycle hook corresponds to.
5561
Cluster clusterv1.Cluster `json:"cluster"`
5662
}
@@ -75,6 +81,9 @@ func AfterControlPlaneInitialized(*AfterControlPlaneInitializedRequest, *AfterCo
7581
type BeforeClusterUpgradeRequest struct {
7682
metav1.TypeMeta `json:",inline"`
7783

84+
// CommonRequest contains fields common to all request types.
85+
CommonRequest `json:",inline"`
86+
7887
// Cluster is the cluster object the lifecycle hook corresponds to.
7988
Cluster clusterv1.Cluster `json:"cluster"`
8089

@@ -105,6 +114,9 @@ func BeforeClusterUpgrade(*BeforeClusterUpgradeRequest, *BeforeClusterUpgradeRes
105114
type AfterControlPlaneUpgradeRequest struct {
106115
metav1.TypeMeta `json:",inline"`
107116

117+
// CommonRequest contains fields common to all request types.
118+
CommonRequest `json:",inline"`
119+
108120
// Cluster is the cluster object the lifecycle hook corresponds to.
109121
Cluster clusterv1.Cluster `json:"cluster"`
110122

@@ -132,6 +144,9 @@ func AfterControlPlaneUpgrade(*AfterControlPlaneUpgradeRequest, *AfterControlPla
132144
type AfterClusterUpgradeRequest struct {
133145
metav1.TypeMeta `json:",inline"`
134146

147+
// CommonRequest contains fields common to all request types.
148+
CommonRequest `json:",inline"`
149+
135150
// Cluster is the cluster object the lifecycle hook corresponds to.
136151
Cluster clusterv1.Cluster `json:"cluster"`
137152

@@ -159,6 +174,9 @@ func AfterClusterUpgrade(*AfterClusterUpgradeRequest, *AfterClusterUpgradeRespon
159174
type BeforeClusterDeleteRequest struct {
160175
metav1.TypeMeta `json:",inline"`
161176

177+
// CommonRequest contains fields common to all request types.
178+
CommonRequest `json:",inline"`
179+
162180
// Cluster is the cluster object the lifecycle hook corresponds to.
163181
Cluster clusterv1.Cluster `json:"cluster"`
164182
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ import (
3030
type GeneratePatchesRequest struct {
3131
metav1.TypeMeta `json:",inline"`
3232

33+
// CommonRequest contains Settings field common to all request types.
34+
CommonRequest `json:",inline"`
35+
3336
// Variables are global variables for all templates.
3437
Variables []Variable `json:"variables"`
3538

@@ -107,6 +110,9 @@ func GeneratePatches(*GeneratePatchesRequest, *GeneratePatchesResponse) {}
107110
type ValidateTopologyRequest struct {
108111
metav1.TypeMeta `json:",inline"`
109112

113+
// CommonRequest contains Settings field common to all request types.
114+
CommonRequest `json:",inline"`
115+
110116
// Variables are global variables for all templates.
111117
Variables []Variable `json:"variables"`
112118

0 commit comments

Comments
 (0)