Skip to content

Commit 9ca35c4

Browse files
committed
Lint fixes
1 parent dc30a72 commit 9ca35c4

16 files changed

Lines changed: 124 additions & 123 deletions

api/core/v1beta1/openstackcontrolplane_webhook.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ func (r *OpenStackControlPlane) ValidateServiceDependencies(basePath *field.Path
715715
return allErrs
716716
}
717717

718+
// ValidateVersion validates the OpenStackVersion reference in the OpenStackControlPlane
718719
func (r *OpenStackControlPlane) ValidateVersion(ctx context.Context, c client.Client) (field.ErrorList, error) {
719720
var allErrs field.ErrorList
720721

@@ -851,7 +852,7 @@ func (r *OpenStackControlPlane) DefaultServices() {
851852
// clean up the APIOverrides for each glanceAPI that has been
852853
// deleted from the ctlplane
853854
apis := maps.Keys(r.Spec.Glance.Template.GlanceAPIs)
854-
for k, _ := range r.Spec.Glance.APIOverride {
855+
for k := range r.Spec.Glance.APIOverride {
855856
if !slices.Contains(apis, k) {
856857
delete(r.Spec.Glance.APIOverride, k)
857858
}
@@ -1113,6 +1114,7 @@ func validateTLSOverrideSpec(override **route.OverrideSpec, basePath *field.Path
11131114
return allErrs
11141115
}
11151116

1117+
// ValidateTopology validates the TopologyRef in the OpenStackControlPlane
11161118
func (r *OpenStackControlPlane) ValidateTopology(basePath *field.Path) *field.Error {
11171119
// When a TopologyRef CR is referenced, fail if a different Namespace is
11181120
// referenced because is not supported

api/core/v1beta1/openstackversion_types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ type OpenStackVersionStatus struct {
213213
// +kubebuilder:printcolumn:name="Target Version",type=string,JSONPath=`.spec.targetVersion`
214214
// +kubebuilder:printcolumn:name="Available Version",type=string,JSONPath=`.status.availableVersion`
215215
// +kubebuilder:printcolumn:name="Deployed Version",type=string,JSONPath=`.status.deployedVersion`
216-
// OpenStackVersion is the Schema for the openstackversionupdates API
216+
217+
// OpenStackVersion defines the Schema for the openstackversionupdates API
217218
type OpenStackVersion struct {
218219
metav1.TypeMeta `json:",inline"`
219220
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -223,6 +224,7 @@ type OpenStackVersion struct {
223224
}
224225

225226
// +kubebuilder:object:root=true
227+
226228
// OpenStackVersionList contains a list of OpenStackVersion
227229
type OpenStackVersionList struct {
228230
metav1.TypeMeta `json:",inline"`
@@ -256,9 +258,8 @@ func getOpenStackReleaseVersion(openstackReleaseVersion string, releaseVersionSc
256258
operatorConditionEpoch := re.FindString(operatorConditionName)
257259
if operatorConditionEpoch == "" {
258260
return openstackReleaseVersion
259-
} else {
260-
return openstackReleaseVersion + operatorConditionEpoch
261261
}
262+
return openstackReleaseVersion + operatorConditionEpoch
262263
}
263264
return openstackReleaseVersion
264265
}

api/dataplane/v1beta1/openstackdataplanedeployment_webhook.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func (spec *OpenStackDataPlaneDeploymentSpec) Default() {
5757

5858
var _ webhook.Validator = &OpenStackDataPlaneDeployment{}
5959

60+
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
6061
func (r *OpenStackDataPlaneDeployment) ValidateCreate() (admission.Warnings, error) {
6162

6263
openstackdataplanedeploymentlog.Info("validate create", "name", r.Name)
@@ -74,12 +75,14 @@ func (r *OpenStackDataPlaneDeployment) ValidateCreate() (admission.Warnings, err
7475
return nil, nil
7576
}
7677

77-
func (r *OpenStackDataPlaneDeploymentSpec) ValidateCreate() field.ErrorList {
78+
// ValidateCreate validates the OpenStackDataPlaneDeploymentSpec on creation
79+
func (spec *OpenStackDataPlaneDeploymentSpec) ValidateCreate() field.ErrorList {
7880
// TODO(user): fill in your validation logic upon object creation.
7981

8082
return field.ErrorList{}
8183
}
8284

85+
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
8386
func (r *OpenStackDataPlaneDeployment) ValidateUpdate(original runtime.Object) (admission.Warnings, error) {
8487
openstackdataplanedeploymentlog.Info("validate update", "name", r.Name)
8588

@@ -97,12 +100,14 @@ func (r *OpenStackDataPlaneDeployment) ValidateUpdate(original runtime.Object) (
97100
return nil, nil
98101
}
99102

100-
func (r *OpenStackDataPlaneDeploymentSpec) ValidateUpdate() field.ErrorList {
103+
// ValidateUpdate validates the OpenStackDataPlaneDeploymentSpec on update
104+
func (spec *OpenStackDataPlaneDeploymentSpec) ValidateUpdate() field.ErrorList {
101105
// TODO(user): fill in your validation logic upon object update.
102106

103107
return field.ErrorList{}
104108
}
105109

110+
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
106111
func (r *OpenStackDataPlaneDeployment) ValidateDelete() (admission.Warnings, error) {
107112
openstackdataplanedeploymentlog.Info("validate delete", "name", r.Name)
108113

@@ -119,7 +124,8 @@ func (r *OpenStackDataPlaneDeployment) ValidateDelete() (admission.Warnings, err
119124
return nil, nil
120125
}
121126

122-
func (r *OpenStackDataPlaneDeploymentSpec) ValidateDelete() field.ErrorList {
127+
// ValidateDelete validates the OpenStackDataPlaneDeploymentSpec on delete
128+
func (spec *OpenStackDataPlaneDeploymentSpec) ValidateDelete() field.ErrorList {
123129
// TODO(user): fill in your validation logic upon object creation.
124130

125131
return field.ErrorList{}

api/dataplane/v1beta1/openstackdataplanenodeset_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@ func (r *OpenStackDataPlaneNodeSetSpec) duplicateNodeCheck(nodeSetList *OpenStac
315315
return
316316
}
317317

318-
// Compare TLS settings of control plane and data plane
319-
// if control plane name is specified attempt to retrieve it
318+
// ValidateTLS compares TLS settings of control plane and data plane.
319+
// If control plane name is specified attempt to retrieve it,
320320
// otherwise get any control plane in the namespace
321-
func (r *OpenStackDataPlaneNodeSetSpec) ValidateTLS(namespace string, reconcilerClient client.Client, ctx context.Context) error {
321+
func (r *OpenStackDataPlaneNodeSetSpec) ValidateTLS(ctx context.Context, namespace string, reconcilerClient client.Client) error {
322322
var err error
323323
controlPlanes := openstackv1.OpenStackControlPlaneList{}
324324
opts := client.ListOptions{
@@ -342,7 +342,7 @@ func (r *OpenStackDataPlaneNodeSetSpec) ValidateTLS(namespace string, reconciler
342342
return err
343343
}
344344

345-
// Do TLS flags match in control plane ingress, pods and data plane
345+
// TLSMatch checks if TLS flags match in control plane ingress, pods and data plane
346346
func (r *OpenStackDataPlaneNodeSetSpec) TLSMatch(controlPlane openstackv1.OpenStackControlPlane) *field.Error {
347347

348348
if controlPlane.Spec.TLS.PodLevel.Enabled != r.TLSEnabled {

api/dataplane/v1beta1/openstackdataplanenodeset_webhook.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,19 @@ func (r *OpenStackDataPlaneNodeSet) ValidateUpdate(ctx context.Context, old runt
178178
return nil, nil
179179
}
180180

181-
func (r *OpenStackDataPlaneNodeSetSpec) ValidateUpdate(oldSpec *OpenStackDataPlaneNodeSetSpec) field.ErrorList {
181+
// ValidateUpdate validates the OpenStackDataPlaneNodeSetSpec on update
182+
func (spec *OpenStackDataPlaneNodeSetSpec) ValidateUpdate(oldSpec *OpenStackDataPlaneNodeSetSpec) field.ErrorList {
182183

183184
var errors field.ErrorList
184185
// Some changes to the baremetalSetTemplate after the initial deployment would necessitate
185186
// a redeploy of the node. Thus we should block these changes and require the user to
186187
// delete and redeploy should they wish to make such changes after the initial deploy.
187188
// If the BaremetalSetTemplate is changed, we will offload the parsing of these details
188189
// to the openstack-baremetal-operator webhook to avoid duplicating logic.
189-
if !reflect.DeepEqual(r.BaremetalSetTemplate, oldSpec.BaremetalSetTemplate) {
190+
if !reflect.DeepEqual(spec.BaremetalSetTemplate, oldSpec.BaremetalSetTemplate) {
190191
// Call openstack-baremetal-operator webhook Validate() to parse changes
191-
if r.BaremetalSetTemplate != nil && oldSpec.BaremetalSetTemplate != nil {
192-
err := r.BaremetalSetTemplate.ValidateTemplate(
192+
if spec.BaremetalSetTemplate != nil && oldSpec.BaremetalSetTemplate != nil {
193+
err := spec.BaremetalSetTemplate.ValidateTemplate(
193194
len(oldSpec.Nodes), *oldSpec.BaremetalSetTemplate)
194195
if err != nil {
195196
errors = append(errors, field.Forbidden(
@@ -219,7 +220,8 @@ func (r *OpenStackDataPlaneNodeSet) ValidateDelete(ctx context.Context, c client
219220
return nil, nil
220221
}
221222

222-
func (r *OpenStackDataPlaneNodeSetSpec) ValidateDelete() field.ErrorList {
223+
// ValidateDelete validates the OpenStackDataPlaneNodeSetSpec on delete
224+
func (spec *OpenStackDataPlaneNodeSetSpec) ValidateDelete() field.ErrorList {
223225
// TODO(user): fill in your validation logic upon object deletion.
224226

225227
return field.ErrorList{}

api/dataplane/v1beta1/openstackdataplaneservice_types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ type OpenStackDataPlaneServiceStatus struct {
130130
// +kubebuilder:subresource:status
131131
// +kubebuilder:resource:shortName=osdps;osdpservice;osdpservices
132132
// +operator-sdk:csv:customresourcedefinitions:displayName="OpenStack Data Plane Service"
133-
// OpenStackDataPlaneService is the Schema for the openstackdataplaneservices API
133+
134+
// OpenStackDataPlaneService defines the Schema for the openstackdataplaneservices API.
134135
// OpenStackDataPlaneService name must be a valid RFC1123 as it is used in labels
135136
type OpenStackDataPlaneService struct {
136137
metav1.TypeMeta `json:",inline"`
@@ -141,6 +142,7 @@ type OpenStackDataPlaneService struct {
141142
}
142143

143144
// +kubebuilder:object:root=true
145+
144146
// OpenStackDataPlaneServiceList contains a list of OpenStackDataPlaneService
145147
type OpenStackDataPlaneServiceList struct {
146148
metav1.TypeMeta `json:",inline"`
@@ -152,7 +154,7 @@ func init() {
152154
SchemeBuilder.Register(&OpenStackDataPlaneService{}, &OpenStackDataPlaneServiceList{})
153155
}
154156

155-
// DefaultLabel - adding default label to the OpenStackDataPlaneService
157+
// DefaultLabels adds default labels to the OpenStackDataPlaneService
156158
func (r *OpenStackDataPlaneService) DefaultLabels() {
157159
labels := map[string]string{
158160
"app.kubernetes.io/name": "openstackdataplaneservice",

api/dataplane/v1beta1/openstackdataplaneservice_webhook.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func (spec *OpenStackDataPlaneServiceSpec) Default(name string) {
6060

6161
var _ webhook.Validator = &OpenStackDataPlaneService{}
6262

63+
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
6364
func (r *OpenStackDataPlaneService) ValidateCreate() (admission.Warnings, error) {
6465

6566
openstackdataplaneservicelog.Info("validate create", "name", r.Name)
@@ -78,31 +79,34 @@ func (r *OpenStackDataPlaneService) ValidateCreate() (admission.Warnings, error)
7879
return nil, nil
7980
}
8081

81-
func (r *OpenStackDataPlaneServiceSpec) ValidateArtifact() field.ErrorList {
82-
if len(r.Playbook) == len(r.PlaybookContents) && len(r.Playbook) == len(r.Role) && len(r.Playbook) == 0 {
82+
// ValidateArtifact validates that at least one of Playbook, PlaybookContents, or Role is specified
83+
func (spec *OpenStackDataPlaneServiceSpec) ValidateArtifact() field.ErrorList {
84+
if len(spec.Playbook) == len(spec.PlaybookContents) && len(spec.Playbook) == len(spec.Role) && len(spec.Playbook) == 0 {
8385
return field.ErrorList{
8486
field.Invalid(
8587
field.NewPath("Playbook"),
86-
r.Playbook, "Playbook, PlaybookContents and Role cannot be empty at the same time",
88+
spec.Playbook, "Playbook, PlaybookContents and Role cannot be empty at the same time",
8789
),
8890
field.Invalid(
8991
field.NewPath("PlaybookContents"),
90-
r.Playbook, "Playbook, PlaybookContents and Role cannot be empty at the same time",
92+
spec.Playbook, "Playbook, PlaybookContents and Role cannot be empty at the same time",
9193
),
9294
field.Invalid(
9395
field.NewPath("Role"),
94-
r.Playbook, "Playbook, PlaybookContents and Role cannot be empty at the same time",
96+
spec.Playbook, "Playbook, PlaybookContents and Role cannot be empty at the same time",
9597
),
9698
}
9799
}
98100

99101
return field.ErrorList{}
100102
}
101103

102-
func (r *OpenStackDataPlaneServiceSpec) ValidateCreate() field.ErrorList {
103-
return r.ValidateArtifact()
104+
// ValidateCreate validates the OpenStackDataPlaneServiceSpec on creation
105+
func (spec *OpenStackDataPlaneServiceSpec) ValidateCreate() field.ErrorList {
106+
return spec.ValidateArtifact()
104107
}
105108

109+
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
106110
func (r *OpenStackDataPlaneService) ValidateUpdate(original runtime.Object) (admission.Warnings, error) {
107111
openstackdataplaneservicelog.Info("validate update", "name", r.Name)
108112
errors := r.Spec.ValidateUpdate()
@@ -118,10 +122,12 @@ func (r *OpenStackDataPlaneService) ValidateUpdate(original runtime.Object) (adm
118122
return nil, nil
119123
}
120124

121-
func (r *OpenStackDataPlaneServiceSpec) ValidateUpdate() field.ErrorList {
122-
return r.ValidateArtifact()
125+
// ValidateUpdate validates the OpenStackDataPlaneServiceSpec on update
126+
func (spec *OpenStackDataPlaneServiceSpec) ValidateUpdate() field.ErrorList {
127+
return spec.ValidateArtifact()
123128
}
124129

130+
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
125131
func (r *OpenStackDataPlaneService) ValidateDelete() (admission.Warnings, error) {
126132
openstackdataplaneservicelog.Info("validate delete", "name", r.Name)
127133

@@ -138,7 +144,8 @@ func (r *OpenStackDataPlaneService) ValidateDelete() (admission.Warnings, error)
138144
return nil, nil
139145
}
140146

141-
func (r *OpenStackDataPlaneServiceSpec) ValidateDelete() field.ErrorList {
147+
// ValidateDelete validates the OpenStackDataPlaneServiceSpec on delete
148+
func (spec *OpenStackDataPlaneServiceSpec) ValidateDelete() field.ErrorList {
142149
// TODO(user): fill in your validation logic upon object creation.
143150

144151
return field.ErrorList{}

api/operator/v1beta1/openstack_types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"k8s.io/utils/ptr"
2525
)
2626

27+
// Operator names for OpenStack components
2728
const (
2829
OpenStackOperatorName = "openstack"
2930
BarbicanOperatorName = "barbican"
@@ -270,7 +271,8 @@ type OpenStackStatus struct {
270271
// +operator-sdk:csv:customresourcedefinitions:displayName="OpenStack"
271272
// +kubebuilder:printcolumn:name="Deployed Operator Count",type=integer,JSONPath=`.status.deployedOperatorCount`
272273
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[0].status",description="Status"
273-
// OpenStack is the Schema for the openstacks API
274+
275+
// OpenStack defines the Schema for the openstacks API
274276
type OpenStack struct {
275277
metav1.TypeMeta `json:",inline"`
276278
metav1.ObjectMeta `json:"metadata,omitempty"`

bindata/operator/managers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ spec:
1111
replicas: {{ .Deployment.Replicas }}
1212
selector:
1313
matchLabels:
14-
app.kubernetes.io/name: {{ .Name }}
14+
app.kubernetes.io/name: {{ .Name }}-operator
1515
template:
1616
metadata:
1717
annotations:

cmd/main.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import (
4141
clientcontroller "github.com/openstack-k8s-operators/openstack-operator/internal/controller/client"
4242
corecontroller "github.com/openstack-k8s-operators/openstack-operator/internal/controller/core"
4343
dataplanecontroller "github.com/openstack-k8s-operators/openstack-operator/internal/controller/dataplane"
44-
operatorcontroller "github.com/openstack-k8s-operators/openstack-operator/internal/controller/operator"
4544
webhookcorev1beta1 "github.com/openstack-k8s-operators/openstack-operator/internal/webhook/core/v1beta1"
4645
webhookdataplanev1beta1 "github.com/openstack-k8s-operators/openstack-operator/internal/webhook/dataplane/v1beta1"
4746

@@ -355,14 +354,6 @@ func main() {
355354
setupLog.Error(err, "unable to create controller", "controller", "OpenStackDataPlaneDeployment")
356355
os.Exit(1)
357356
}
358-
if err := (&operatorcontroller.OpenStackReconciler{
359-
Client: mgr.GetClient(),
360-
Scheme: mgr.GetScheme(),
361-
Kclient: kclient,
362-
}).SetupWithManager(mgr); err != nil {
363-
setupLog.Error(err, "unable to create controller", "controller", "OpenStack")
364-
os.Exit(1)
365-
}
366357

367358
corecontroller.SetupVersionDefaults()
368359

0 commit comments

Comments
 (0)