Skip to content

Commit e75946f

Browse files
committed
fixup! refactor: Use simple string for default storageclass config name
1 parent b933076 commit e75946f

12 files changed

+42
-93
lines changed

api/v1alpha1/addon_types.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,15 @@ type ClusterAutoscaler struct {
109109
Strategy AddonStrategy `json:"strategy"`
110110
}
111111

112-
type DefaultStorage struct {
113-
// Name of storage class config in any of the provider objects.
114-
// +kubebuilder:validation:Required
115-
// +kubebuilder:validation:MinLength=1
116-
StorageClassConfigName string `json:"storageClassConfigName"`
117-
}
118-
119112
type CSI struct {
120113
// +kubebuilder:validation:MinItems=1
121114
// +kubebuilder:validation:Required
122115
Providers []CSIProvider `json:"providers"`
123116

117+
// Name of the default storage class config in any of the provider objects.
124118
// +kubebuilder:validation:Required
125-
DefaultStorage DefaultStorage `json:"defaultStorage"`
119+
// +kubebuilder:validation:MinLength=1
120+
DefaultStorageClassConfigName string `json:"defaultStorageClassConfigName"`
126121
}
127122

128123
type CSIProvider struct {

api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,10 @@ spec:
100100
type: object
101101
csi:
102102
properties:
103-
defaultStorage:
104-
properties:
105-
storageClassConfigName:
106-
description: Name of storage class config in any of the provider objects.
107-
minLength: 1
108-
type: string
109-
required:
110-
- storageClassConfigName
111-
type: object
103+
defaultStorageClassConfigName:
104+
description: Name of the default storage class config in any of the provider objects.
105+
minLength: 1
106+
type: string
112107
providers:
113108
items:
114109
properties:
@@ -184,7 +179,7 @@ spec:
184179
minItems: 1
185180
type: array
186181
required:
187-
- defaultStorage
182+
- defaultStorageClassConfigName
188183
- providers
189184
type: object
190185
nfd:

api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,10 @@ spec:
100100
type: object
101101
csi:
102102
properties:
103-
defaultStorage:
104-
properties:
105-
storageClassConfigName:
106-
description: Name of storage class config in any of the provider objects.
107-
minLength: 1
108-
type: string
109-
required:
110-
- storageClassConfigName
111-
type: object
103+
defaultStorageClassConfigName:
104+
description: Name of the default storage class config in any of the provider objects.
105+
minLength: 1
106+
type: string
112107
providers:
113108
items:
114109
properties:
@@ -184,7 +179,7 @@ spec:
184179
minItems: 1
185180
type: array
186181
required:
187-
- defaultStorage
182+
- defaultStorageClassConfigName
188183
- providers
189184
type: object
190185
nfd:

api/v1alpha1/crds/caren.nutanix.com_genericclusterconfigs.yaml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,11 @@ spec:
114114
type: object
115115
csi:
116116
properties:
117-
defaultStorage:
118-
properties:
119-
storageClassConfigName:
120-
description: Name of storage class config in any of the
121-
provider objects.
122-
minLength: 1
123-
type: string
124-
required:
125-
- storageClassConfigName
126-
type: object
117+
defaultStorageClassConfigName:
118+
description: Name of the default storage class config in any
119+
of the provider objects.
120+
minLength: 1
121+
type: string
127122
providers:
128123
items:
129124
properties:
@@ -210,7 +205,7 @@ spec:
210205
minItems: 1
211206
type: array
212207
required:
213-
- defaultStorage
208+
- defaultStorageClassConfigName
214209
- providers
215210
type: object
216211
nfd:

api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,10 @@ spec:
100100
type: object
101101
csi:
102102
properties:
103-
defaultStorage:
104-
properties:
105-
storageClassConfigName:
106-
description: Name of storage class config in any of the provider objects.
107-
minLength: 1
108-
type: string
109-
required:
110-
- storageClassConfigName
111-
type: object
103+
defaultStorageClassConfigName:
104+
description: Name of the default storage class config in any of the provider objects.
105+
minLength: 1
106+
type: string
112107
providers:
113108
items:
114109
properties:
@@ -184,7 +179,7 @@ spec:
184179
minItems: 1
185180
type: array
186181
required:
187-
- defaultStorage
182+
- defaultStorageClassConfigName
188183
- providers
189184
type: object
190185
nfd:

api/v1alpha1/zz_generated.deepcopy.go

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

pkg/handlers/generic/lifecycle/csi/aws-ebs/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func New(
5858
func (a *AWSEBS) Apply(
5959
ctx context.Context,
6060
provider v1alpha1.CSIProvider,
61-
defaultStorageConfig v1alpha1.DefaultStorage,
61+
defaultStorageClassConfigName string,
6262
req *runtimehooksv1.AfterControlPlaneInitializedRequest,
6363
_ logr.Logger,
6464
) error {
@@ -78,7 +78,7 @@ func (a *AWSEBS) Apply(
7878
a.client,
7979
provider.StorageClassConfig,
8080
&req.Cluster,
81-
defaultStorageConfig,
81+
defaultStorageClassConfigName,
8282
v1alpha1.CSIProviderAWSEBS,
8383
v1alpha1.AWSEBSProvisioner,
8484
defaultStorageClassParameters,

pkg/handlers/generic/lifecycle/csi/handler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type CSIProvider interface {
2727
Apply(
2828
context.Context,
2929
v1alpha1.CSIProvider,
30-
v1alpha1.DefaultStorage,
30+
string,
3131
*runtimehooksv1.AfterControlPlaneInitializedRequest,
3232
logr.Logger,
3333
) error
@@ -133,7 +133,7 @@ func (c *CSIHandler) AfterControlPlaneInitialized(
133133
err = handler.Apply(
134134
ctx,
135135
provider,
136-
csi.DefaultStorage,
136+
csi.DefaultStorageClassConfigName,
137137
req,
138138
log,
139139
)
@@ -162,7 +162,7 @@ func validateDefaultStorage(csi v1alpha1.CSI) error {
162162
return slices.ContainsFunc(
163163
provider.StorageClassConfig,
164164
func(scc v1alpha1.StorageClassConfig) bool {
165-
return scc.Name == csi.DefaultStorage.StorageClassConfigName
165+
return scc.Name == csi.DefaultStorageClassConfigName
166166
},
167167
)
168168
}) {

pkg/handlers/generic/lifecycle/csi/handler_test.go

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type fakeCSIProvider struct {
2525
func (p *fakeCSIProvider) Apply(
2626
ctx context.Context,
2727
provider v1alpha1.CSIProvider,
28-
defaultStorageConfig v1alpha1.DefaultStorage,
28+
defaultStorageClassConfigName string,
2929
req *runtimehooksv1.AfterControlPlaneInitializedRequest,
3030
log logr.Logger,
3131
) error {
@@ -80,10 +80,8 @@ func Test_AfterControlPlaneInitialized(t *testing.T) {
8080
{
8181
name: "if csi variable set, must set at least one provider",
8282
csi: &v1alpha1.CSI{
83-
Providers: []v1alpha1.CSIProvider{},
84-
DefaultStorage: v1alpha1.DefaultStorage{
85-
StorageClassConfigName: "example",
86-
},
83+
Providers: []v1alpha1.CSIProvider{},
84+
DefaultStorageClassConfigName: "example",
8785
},
8886
wantStatus: runtimehooksv1.ResponseStatusFailure,
8987
},
@@ -100,9 +98,7 @@ func Test_AfterControlPlaneInitialized(t *testing.T) {
10098
},
10199
},
102100
},
103-
DefaultStorage: v1alpha1.DefaultStorage{
104-
StorageClassConfigName: "test2",
105-
},
101+
DefaultStorageClassConfigName: "test2",
106102
},
107103
wantStatus: runtimehooksv1.ResponseStatusFailure,
108104
},
@@ -119,9 +115,7 @@ func Test_AfterControlPlaneInitialized(t *testing.T) {
119115
},
120116
},
121117
},
122-
DefaultStorage: v1alpha1.DefaultStorage{
123-
StorageClassConfigName: "not-test1-or-test2",
124-
},
118+
DefaultStorageClassConfigName: "not-test1-or-test2",
125119
},
126120
wantStatus: runtimehooksv1.ResponseStatusFailure,
127121
},
@@ -146,9 +140,7 @@ func Test_AfterControlPlaneInitialized(t *testing.T) {
146140
},
147141
},
148142
},
149-
DefaultStorage: v1alpha1.DefaultStorage{
150-
StorageClassConfigName: "test2",
151-
},
143+
DefaultStorageClassConfigName: "test2",
152144
},
153145
wantStatus: runtimehooksv1.ResponseStatusSuccess,
154146
},
@@ -173,9 +165,7 @@ func Test_AfterControlPlaneInitialized(t *testing.T) {
173165
},
174166
},
175167
},
176-
DefaultStorage: v1alpha1.DefaultStorage{
177-
StorageClassConfigName: "sc-1",
178-
},
168+
DefaultStorageClassConfigName: "sc-1",
179169
},
180170
wantStatus: runtimehooksv1.ResponseStatusFailure,
181171
},

pkg/handlers/generic/lifecycle/csi/localpath/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func New(
4444
func (l *LocalPathProvisionerCSI) Apply(
4545
ctx context.Context,
4646
provider v1alpha1.CSIProvider,
47-
defaultStorageConfig v1alpha1.DefaultStorage,
47+
defaultStorageClassConfigName string,
4848
req *runtimehooksv1.AfterControlPlaneInitializedRequest,
4949
log logr.Logger,
5050
) error {
@@ -65,7 +65,7 @@ func (l *LocalPathProvisionerCSI) Apply(
6565
l.client,
6666
provider.StorageClassConfig,
6767
&req.Cluster,
68-
defaultStorageConfig,
68+
defaultStorageClassConfigName,
6969
v1alpha1.CSIProviderLocalPath,
7070
v1alpha1.LocalPathProvisioner,
7171
nil,

pkg/handlers/generic/lifecycle/csi/nutanix-csi/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func New(
8080
func (n *NutanixCSI) Apply(
8181
ctx context.Context,
8282
provider v1alpha1.CSIProvider,
83-
defaultStorageConfig v1alpha1.DefaultStorage,
83+
defaultStorageClassConfigName string,
8484
req *runtimehooksv1.AfterControlPlaneInitializedRequest,
8585
log logr.Logger,
8686
) error {
@@ -121,7 +121,7 @@ func (n *NutanixCSI) Apply(
121121
n.client,
122122
provider.StorageClassConfig,
123123
&req.Cluster,
124-
defaultStorageConfig,
124+
defaultStorageClassConfigName,
125125
v1alpha1.CSIProviderNutanix,
126126
v1alpha1.NutanixProvisioner,
127127
defaultStorageClassParameters,

pkg/handlers/generic/lifecycle/utils/scs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func CreateStorageClassOnRemote(
6060
cl ctrlclient.Client,
6161
configs []v1alpha1.StorageClassConfig,
6262
cluster *clusterv1.Cluster,
63-
defaultStorageConfig v1alpha1.DefaultStorage,
63+
defaultStorageClassConfigName string,
6464
csiProvider string,
6565
provisioner v1alpha1.StorageProvisioner,
6666
defaultParameters map[string]string,
@@ -76,7 +76,7 @@ func CreateStorageClassOnRemote(
7676
}
7777

7878
for _, config := range configs {
79-
setAsDefault := config.Name == defaultStorageConfig.StorageClassConfigName
79+
setAsDefault := config.Name == defaultStorageClassConfigName
8080
sc := CreateStorageClass(
8181
config,
8282
provisioner,

0 commit comments

Comments
 (0)