Skip to content

Commit d136154

Browse files
authored
refactor: Use a Credentials struct consistently (#663)
**What problem does this PR solve?**: Previously, we used a Credentials struct in some places, and a LocalObjectReference in others. With this change, we use a Credentials struct in all places. **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent fca59eb commit d136154

22 files changed

+290
-115
lines changed

api/v1alpha1/addon_types.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ type CSIProvider struct {
145145

146146
// The reference to any secret used by the CSI Provider.
147147
// +kubebuilder:validation:Optional
148-
Credentials *LocalObjectReference `json:"credentials,omitempty"`
148+
Credentials *CSICredentials `json:"credentials,omitempty"`
149149
}
150150

151151
type StorageClassConfig struct {
@@ -174,11 +174,23 @@ type StorageClassConfig struct {
174174
AllowExpansion bool `json:"allowExpansion,omitempty"`
175175
}
176176

177+
type CSICredentials struct {
178+
// A reference to the Secret containing the credentials used by the CSI provider.
179+
// +kubebuilder:validation:Required
180+
SecretRef LocalObjectReference `json:"secretRef"`
181+
}
182+
177183
// CCM tells us to enable or disable the cloud provider interface.
178184
type CCM struct {
179185
// A reference to the Secret for credential information for the target Prism Central instance
180186
// +kubebuilder:validation:Optional
181-
Credentials *LocalObjectReference `json:"credentials,omitempty"`
187+
Credentials *CCMCredentials `json:"credentials,omitempty"`
188+
}
189+
190+
type CCMCredentials struct {
191+
// A reference to the Secret containing the credentials used by the CCM provider.
192+
// +kubebuilder:validation:Required
193+
SecretRef LocalObjectReference `json:"secretRef"`
182194
}
183195

184196
type ServiceLoadBalancer struct {

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

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,21 @@ spec:
5151
description: A reference to the Secret for credential information
5252
for the target Prism Central instance
5353
properties:
54-
name:
55-
description: |-
56-
Name of the referent.
57-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
58-
minLength: 1
59-
type: string
54+
secretRef:
55+
description: A reference to the Secret containing the
56+
credentials used by the CCM provider.
57+
properties:
58+
name:
59+
description: |-
60+
Name of the referent.
61+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
62+
minLength: 1
63+
type: string
64+
required:
65+
- name
66+
type: object
6067
required:
61-
- name
68+
- secretRef
6269
type: object
6370
type: object
6471
clusterAutoscaler:
@@ -123,14 +130,21 @@ spec:
123130
description: The reference to any secret used by the
124131
CSI Provider.
125132
properties:
126-
name:
127-
description: |-
128-
Name of the referent.
129-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
130-
minLength: 1
131-
type: string
133+
secretRef:
134+
description: A reference to the Secret containing
135+
the credentials used by the CSI provider.
136+
properties:
137+
name:
138+
description: |-
139+
Name of the referent.
140+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
141+
minLength: 1
142+
type: string
143+
required:
144+
- name
145+
type: object
132146
required:
133-
- name
147+
- secretRef
134148
type: object
135149
name:
136150
description: Name of the CSI Provider.

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

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,21 @@ spec:
5252
description: A reference to the Secret for credential information
5353
for the target Prism Central instance
5454
properties:
55-
name:
56-
description: |-
57-
Name of the referent.
58-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
59-
minLength: 1
60-
type: string
55+
secretRef:
56+
description: A reference to the Secret containing the
57+
credentials used by the CCM provider.
58+
properties:
59+
name:
60+
description: |-
61+
Name of the referent.
62+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
63+
minLength: 1
64+
type: string
65+
required:
66+
- name
67+
type: object
6168
required:
62-
- name
69+
- secretRef
6370
type: object
6471
type: object
6572
clusterAutoscaler:
@@ -124,14 +131,21 @@ spec:
124131
description: The reference to any secret used by the
125132
CSI Provider.
126133
properties:
127-
name:
128-
description: |-
129-
Name of the referent.
130-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
131-
minLength: 1
132-
type: string
134+
secretRef:
135+
description: A reference to the Secret containing
136+
the credentials used by the CSI provider.
137+
properties:
138+
name:
139+
description: |-
140+
Name of the referent.
141+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
142+
minLength: 1
143+
type: string
144+
required:
145+
- name
146+
type: object
133147
required:
134-
- name
148+
- secretRef
135149
type: object
136150
name:
137151
description: Name of the CSI Provider.

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

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,21 @@ spec:
6060
description: A reference to the Secret for credential information
6161
for the target Prism Central instance
6262
properties:
63-
name:
64-
description: |-
65-
Name of the referent.
66-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
67-
minLength: 1
68-
type: string
63+
secretRef:
64+
description: A reference to the Secret containing the
65+
credentials used by the CCM provider.
66+
properties:
67+
name:
68+
description: |-
69+
Name of the referent.
70+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
71+
minLength: 1
72+
type: string
73+
required:
74+
- name
75+
type: object
6976
required:
70-
- name
77+
- secretRef
7178
type: object
7279
type: object
7380
clusterAutoscaler:
@@ -132,14 +139,21 @@ spec:
132139
description: The reference to any secret used by the
133140
CSI Provider.
134141
properties:
135-
name:
136-
description: |-
137-
Name of the referent.
138-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
139-
minLength: 1
140-
type: string
142+
secretRef:
143+
description: A reference to the Secret containing
144+
the credentials used by the CSI provider.
145+
properties:
146+
name:
147+
description: |-
148+
Name of the referent.
149+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
150+
minLength: 1
151+
type: string
152+
required:
153+
- name
154+
type: object
141155
required:
142-
- name
156+
- secretRef
143157
type: object
144158
name:
145159
description: Name of the CSI Provider.

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

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,21 @@ spec:
5252
description: A reference to the Secret for credential information
5353
for the target Prism Central instance
5454
properties:
55-
name:
56-
description: |-
57-
Name of the referent.
58-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
59-
minLength: 1
60-
type: string
55+
secretRef:
56+
description: A reference to the Secret containing the
57+
credentials used by the CCM provider.
58+
properties:
59+
name:
60+
description: |-
61+
Name of the referent.
62+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
63+
minLength: 1
64+
type: string
65+
required:
66+
- name
67+
type: object
6168
required:
62-
- name
69+
- secretRef
6370
type: object
6471
type: object
6572
clusterAutoscaler:
@@ -124,14 +131,21 @@ spec:
124131
description: The reference to any secret used by the
125132
CSI Provider.
126133
properties:
127-
name:
128-
description: |-
129-
Name of the referent.
130-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
131-
minLength: 1
132-
type: string
134+
secretRef:
135+
description: A reference to the Secret containing
136+
the credentials used by the CSI provider.
137+
properties:
138+
name:
139+
description: |-
140+
Name of the referent.
141+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
142+
minLength: 1
143+
type: string
144+
required:
145+
- name
146+
type: object
133147
required:
134-
- name
148+
- secretRef
135149
type: object
136150
name:
137151
description: Name of the CSI Provider.
@@ -571,14 +585,21 @@ spec:
571585
description: A reference to the Secret for credential information
572586
for the target Prism Central instance.
573587
properties:
574-
name:
575-
description: |-
576-
Name of the referent.
577-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
578-
minLength: 1
579-
type: string
588+
secretRef:
589+
description: A reference to the Secret containing the
590+
Prism Central credentials.
591+
properties:
592+
name:
593+
description: |-
594+
Name of the referent.
595+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
596+
minLength: 1
597+
type: string
598+
required:
599+
- name
600+
type: object
580601
required:
581-
- name
602+
- secretRef
582603
type: object
583604
insecure:
584605
description: use insecure connection to Prism Central endpoint

api/v1alpha1/nutanix_clusterconfig_types.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ type NutanixPrismCentralEndpointSpec struct {
4545

4646
// A reference to the Secret for credential information for the target Prism Central instance.
4747
// +kubebuilder:validation:Required
48-
Credentials LocalObjectReference `json:"credentials"`
48+
Credentials NutanixPrismCentralEndpointCredentials `json:"credentials"`
49+
}
50+
51+
type NutanixPrismCentralEndpointCredentials struct {
52+
// A reference to the Secret containing the Prism Central credentials.
53+
// +kubebuilder:validation:Required
54+
SecretRef LocalObjectReference `json:"secretRef"`
4955
}
5056

5157
//nolint:gocritic // No need for named return values

api/v1alpha1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)