Skip to content

Commit bd83e7c

Browse files
committed
refactor: Rename GenericClusterConfig to AllProvidersSpec
This reduces stuttering, and aligns better with the names of the similar types AWSSpec and DockerSpec. This is not an API change, because the struct is inlined, and the name is not part of the API.
1 parent 89f8887 commit bd83e7c

File tree

13 files changed

+98
-98
lines changed

13 files changed

+98
-98
lines changed

api/v1alpha1/clusterconfig_types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ type ClusterConfigSpec struct {
4141
// +optional
4242
Docker *DockerSpec `json:"docker,omitempty"`
4343

44-
GenericClusterConfig `json:",inline"`
44+
AllProvidersSpec `json:",inline"`
4545

4646
//+optional
4747
ControlPlane *NodeConfigSpec `json:"controlPlane,omitempty"`
4848
}
4949

5050
func (s ClusterConfigSpec) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect.
51-
clusterConfigProps := GenericClusterConfig{}.VariableSchema()
51+
clusterConfigProps := AllProvidersSpec{}.VariableSchema()
5252

5353
switch {
5454
case s.AWS != nil:
@@ -76,8 +76,8 @@ func (s ClusterConfigSpec) VariableSchema() clusterv1.VariableSchema { //nolint:
7676
return clusterConfigProps
7777
}
7878

79-
// GenericClusterConfig defines the generic cluster configdesired.
80-
type GenericClusterConfig struct {
79+
// AllProvidersSpec defines the generic cluster configdesired.
80+
type AllProvidersSpec struct {
8181
// +optional
8282
KubernetesImageRepository *KubernetesImageRepository `json:"kubernetesImageRepository,omitempty"`
8383

@@ -100,7 +100,7 @@ type GenericClusterConfig struct {
100100
Addons *Addons `json:"addons,omitempty"`
101101
}
102102

103-
func (s GenericClusterConfig) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect.
103+
func (s AllProvidersSpec) VariableSchema() clusterv1.VariableSchema { //nolint:gocritic,lll // Passed by value for no potential side-effect.
104104
return clusterv1.VariableSchema{
105105
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
106106
Description: "Cluster configuration",

api/v1alpha1/zz_generated.deepcopy.go

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

pkg/handlers/generic/clusterconfig/variables.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (h *clusterConfigVariableHandler) DiscoverVariables(
4848
resp.Variables = append(resp.Variables, clusterv1.ClusterClassVariable{
4949
Name: MetaVariableName,
5050
Required: false,
51-
Schema: v1alpha1.GenericClusterConfig{}.VariableSchema(),
51+
Schema: v1alpha1.AllProvidersSpec{}.VariableSchema(),
5252
})
5353
resp.SetStatus(runtimehooksv1.ResponseStatusSuccess)
5454
}

pkg/handlers/generic/clusterconfig/variables_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ func TestVariableValidation(t *testing.T) {
1616
capitest.ValidateDiscoverVariables(
1717
t,
1818
MetaVariableName,
19-
ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()),
19+
ptr.To(v1alpha1.AllProvidersSpec{}.VariableSchema()),
2020
false,
2121
NewVariable,
2222
capitest.VariableTestDef{
2323
Name: "valid config",
24-
Vals: v1alpha1.GenericClusterConfig{
24+
Vals: v1alpha1.AllProvidersSpec{
2525
Proxy: &v1alpha1.HTTPProxy{
2626
HTTP: "http://a.b.c.example.com",
2727
HTTPS: "https://a.b.c.example.com",

pkg/handlers/generic/lifecycle/clusterautoscaler/variables_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ func TestVariableValidation(t *testing.T) {
1717
capitest.ValidateDiscoverVariables(
1818
t,
1919
clusterconfig.MetaVariableName,
20-
ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()),
20+
ptr.To(v1alpha1.AllProvidersSpec{}.VariableSchema()),
2121
false,
2222
clusterconfig.NewVariable,
2323
capitest.VariableTestDef{
2424
Name: "ClusterResourceSet strategy",
25-
Vals: v1alpha1.GenericClusterConfig{
25+
Vals: v1alpha1.AllProvidersSpec{
2626
Addons: &v1alpha1.Addons{
2727
ClusterAutoscaler: &v1alpha1.ClusterAutoscaler{
2828
Strategy: v1alpha1.AddonStrategyClusterResourceSet,
@@ -32,7 +32,7 @@ func TestVariableValidation(t *testing.T) {
3232
},
3333
capitest.VariableTestDef{
3434
Name: "HelmAddon strategy",
35-
Vals: v1alpha1.GenericClusterConfig{
35+
Vals: v1alpha1.AllProvidersSpec{
3636
Addons: &v1alpha1.Addons{
3737
ClusterAutoscaler: &v1alpha1.ClusterAutoscaler{
3838
Strategy: v1alpha1.AddonStrategyHelmAddon,
@@ -42,7 +42,7 @@ func TestVariableValidation(t *testing.T) {
4242
},
4343
capitest.VariableTestDef{
4444
Name: "invalid strategy",
45-
Vals: v1alpha1.GenericClusterConfig{
45+
Vals: v1alpha1.AllProvidersSpec{
4646
Addons: &v1alpha1.Addons{
4747
ClusterAutoscaler: &v1alpha1.ClusterAutoscaler{
4848
Strategy: "invalid-strategy",

pkg/handlers/generic/lifecycle/cni/variables_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ func TestVariableValidation(t *testing.T) {
1717
capitest.ValidateDiscoverVariables(
1818
t,
1919
clusterconfig.MetaVariableName,
20-
ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()),
20+
ptr.To(v1alpha1.AllProvidersSpec{}.VariableSchema()),
2121
false,
2222
clusterconfig.NewVariable,
2323
capitest.VariableTestDef{
2424
Name: "set with valid provider using ClusterResourceSet strategy",
25-
Vals: v1alpha1.GenericClusterConfig{
25+
Vals: v1alpha1.AllProvidersSpec{
2626
Addons: &v1alpha1.Addons{
2727
CNI: &v1alpha1.CNI{
2828
Provider: v1alpha1.CNIProviderCalico,
@@ -33,7 +33,7 @@ func TestVariableValidation(t *testing.T) {
3333
},
3434
capitest.VariableTestDef{
3535
Name: "set with valid provider using HelmAddon strategy",
36-
Vals: v1alpha1.GenericClusterConfig{
36+
Vals: v1alpha1.AllProvidersSpec{
3737
Addons: &v1alpha1.Addons{
3838
CNI: &v1alpha1.CNI{
3939
Provider: v1alpha1.CNIProviderCalico,
@@ -44,7 +44,7 @@ func TestVariableValidation(t *testing.T) {
4444
},
4545
capitest.VariableTestDef{
4646
Name: "set with invalid provider",
47-
Vals: v1alpha1.GenericClusterConfig{
47+
Vals: v1alpha1.AllProvidersSpec{
4848
Addons: &v1alpha1.Addons{
4949
CNI: &v1alpha1.CNI{
5050
Provider: "invalid-provider",
@@ -56,7 +56,7 @@ func TestVariableValidation(t *testing.T) {
5656
},
5757
capitest.VariableTestDef{
5858
Name: "set with invalid strategy",
59-
Vals: v1alpha1.GenericClusterConfig{
59+
Vals: v1alpha1.AllProvidersSpec{
6060
Addons: &v1alpha1.Addons{
6161
CNI: &v1alpha1.CNI{
6262
Provider: v1alpha1.CNIProviderCalico,

pkg/handlers/generic/lifecycle/nfd/variables_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ func TestVariableValidation(t *testing.T) {
1717
capitest.ValidateDiscoverVariables(
1818
t,
1919
clusterconfig.MetaVariableName,
20-
ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()),
20+
ptr.To(v1alpha1.AllProvidersSpec{}.VariableSchema()),
2121
false,
2222
clusterconfig.NewVariable,
2323
capitest.VariableTestDef{
2424
Name: "ClusterResourceSet strategy",
25-
Vals: v1alpha1.GenericClusterConfig{
25+
Vals: v1alpha1.AllProvidersSpec{
2626
Addons: &v1alpha1.Addons{
2727
NFD: &v1alpha1.NFD{
2828
Strategy: v1alpha1.AddonStrategyClusterResourceSet,
@@ -32,7 +32,7 @@ func TestVariableValidation(t *testing.T) {
3232
},
3333
capitest.VariableTestDef{
3434
Name: "HelmAddon strategy",
35-
Vals: v1alpha1.GenericClusterConfig{
35+
Vals: v1alpha1.AllProvidersSpec{
3636
Addons: &v1alpha1.Addons{
3737
NFD: &v1alpha1.NFD{
3838
Strategy: v1alpha1.AddonStrategyHelmAddon,
@@ -42,7 +42,7 @@ func TestVariableValidation(t *testing.T) {
4242
},
4343
capitest.VariableTestDef{
4444
Name: "invalid strategy",
45-
Vals: v1alpha1.GenericClusterConfig{
45+
Vals: v1alpha1.AllProvidersSpec{
4646
Addons: &v1alpha1.Addons{
4747
NFD: &v1alpha1.NFD{
4848
Strategy: "invalid-strategy",

pkg/handlers/generic/mutation/etcd/variables_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ func TestVariableValidation(t *testing.T) {
1717
capitest.ValidateDiscoverVariables(
1818
t,
1919
clusterconfig.MetaVariableName,
20-
ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()),
20+
ptr.To(v1alpha1.AllProvidersSpec{}.VariableSchema()),
2121
false,
2222
clusterconfig.NewVariable,
2323
capitest.VariableTestDef{
2424
Name: "unset",
25-
Vals: v1alpha1.GenericClusterConfig{
25+
Vals: v1alpha1.AllProvidersSpec{
2626
Etcd: &v1alpha1.Etcd{},
2727
},
2828
},
2929
capitest.VariableTestDef{
3030
Name: "set with valid image values",
31-
Vals: v1alpha1.GenericClusterConfig{
31+
Vals: v1alpha1.AllProvidersSpec{
3232
Etcd: &v1alpha1.Etcd{
3333
Image: &v1alpha1.Image{
3434
Repository: "my-registry.io/my-org/my-repo",
@@ -39,7 +39,7 @@ func TestVariableValidation(t *testing.T) {
3939
},
4040
capitest.VariableTestDef{
4141
Name: "set with invalid image repository",
42-
Vals: v1alpha1.GenericClusterConfig{
42+
Vals: v1alpha1.AllProvidersSpec{
4343
Etcd: &v1alpha1.Etcd{
4444
Image: &v1alpha1.Image{
4545
Repository: "https://this.should.not.have.a.scheme",
@@ -50,7 +50,7 @@ func TestVariableValidation(t *testing.T) {
5050
},
5151
capitest.VariableTestDef{
5252
Name: "set with invalid image tag",
53-
Vals: v1alpha1.GenericClusterConfig{
53+
Vals: v1alpha1.AllProvidersSpec{
5454
Etcd: &v1alpha1.Etcd{
5555
Image: &v1alpha1.Image{
5656
Tag: "this:is:not:a:valid:tag",

pkg/handlers/generic/mutation/extraapiservercertsans/variables_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ func TestVariableValidation(t *testing.T) {
1717
capitest.ValidateDiscoverVariables(
1818
t,
1919
clusterconfig.MetaVariableName,
20-
ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()),
20+
ptr.To(v1alpha1.AllProvidersSpec{}.VariableSchema()),
2121
false,
2222
clusterconfig.NewVariable,
2323
capitest.VariableTestDef{
2424
Name: "single valid SAN",
25-
Vals: v1alpha1.GenericClusterConfig{
25+
Vals: v1alpha1.AllProvidersSpec{
2626
ExtraAPIServerCertSANs: v1alpha1.ExtraAPIServerCertSANs{"a.b.c.example.com"},
2727
},
2828
},
2929
capitest.VariableTestDef{
3030
Name: "single invalid SAN",
31-
Vals: v1alpha1.GenericClusterConfig{
31+
Vals: v1alpha1.AllProvidersSpec{
3232
ExtraAPIServerCertSANs: v1alpha1.ExtraAPIServerCertSANs{"invalid:san"},
3333
},
3434
ExpectError: true,
3535
},
3636
capitest.VariableTestDef{
3737
Name: "duplicate valid SANs",
38-
Vals: v1alpha1.GenericClusterConfig{
38+
Vals: v1alpha1.AllProvidersSpec{
3939
ExtraAPIServerCertSANs: v1alpha1.ExtraAPIServerCertSANs{
4040
"a.b.c.example.com",
4141
"a.b.c.example.com",

pkg/handlers/generic/mutation/httpproxy/variables_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ func TestVariableValidation(t *testing.T) {
1717
capitest.ValidateDiscoverVariables(
1818
t,
1919
clusterconfig.MetaVariableName,
20-
ptr.To(v1alpha1.GenericClusterConfig{}.VariableSchema()),
20+
ptr.To(v1alpha1.AllProvidersSpec{}.VariableSchema()),
2121
false,
2222
clusterconfig.NewVariable,
2323
// HTTPProxy
2424
capitest.VariableTestDef{
2525
Name: "valid proxy config",
26-
Vals: v1alpha1.GenericClusterConfig{
26+
Vals: v1alpha1.AllProvidersSpec{
2727
Proxy: &v1alpha1.HTTPProxy{
2828
HTTP: "http://a.b.c.example.com",
2929
HTTPS: "https://a.b.c.example.com",

0 commit comments

Comments
 (0)