Skip to content

Commit 67fd0dc

Browse files
Merge pull request #496 from Nordix/add-nakedret
🌱 Enable nakedret linter for golangcilint
2 parents f89b610 + 6f44c19 commit 67fd0dc

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

.golangci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ linters:
4343
- mirror
4444
- misspell
4545
#- mnd
46-
#- nakedret
46+
- nakedret
4747
- nilerr
4848
- nilnesserr
4949
- nilnil

internal/controller/ironic_controller.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (r *IronicReconciler) handleIronic(cctx ironic.ControllerContext, ironicCon
113113
if ironicConf.DeletionTimestamp.IsZero() {
114114
requeue, err = ensureFinalizer(cctx, ironicConf)
115115
if requeue || err != nil {
116-
return
116+
return requeue, err
117117
}
118118
} else {
119119
return r.cleanUp(cctx, ironicConf)
@@ -149,36 +149,36 @@ func (r *IronicReconciler) handleIronic(cctx ironic.ControllerContext, ironicCon
149149
ironicConf.Status.RequestedVersion = actuallyRequestedVersion
150150
err = r.setNotReady(cctx, ironicConf, metal3api.IronicReasonInProgress, "new version requested")
151151
if err != nil {
152-
return
152+
return requeue, err
153153
}
154154
}
155155

156156
apiSecret, requeue, err := r.ensureAPISecret(cctx, ironicConf)
157157
if requeue || err != nil {
158-
return
158+
return requeue, err
159159
}
160160

161161
var tlsSecret *corev1.Secret
162162
if tlsSecretName := ironicConf.Spec.TLS.CertificateName; tlsSecretName != "" {
163163
tlsSecret, requeue, err = r.getAndUpdateSecret(cctx, ironicConf, tlsSecretName)
164164
if requeue || err != nil {
165-
return
165+
return requeue, err
166166
}
167167
}
168168

169169
var bmcSecret *corev1.Secret
170170
if bmcSecretName := ironicConf.Spec.TLS.BMCCAName; bmcSecretName != "" {
171171
bmcSecret, requeue, err = r.getAndUpdateSecret(cctx, ironicConf, bmcSecretName)
172172
if requeue || err != nil {
173-
return
173+
return requeue, err
174174
}
175175
}
176176

177177
var trustedCAConfigMap *corev1.ConfigMap
178178
if trustedCAConfigMapName := ironicConf.Spec.TLS.TrustedCAName; trustedCAConfigMapName != "" {
179179
trustedCAConfigMap, requeue, err = r.getConfigMap(cctx, ironicConf, trustedCAConfigMapName)
180180
if requeue || err != nil {
181-
return
181+
return requeue, err
182182
}
183183
}
184184

@@ -193,7 +193,7 @@ func (r *IronicReconciler) handleIronic(cctx ironic.ControllerContext, ironicCon
193193
status, err := ironic.EnsureIronic(cctx, resources)
194194
if err != nil {
195195
cctx.Logger.Error(err, "potentially transient error, will retry")
196-
return
196+
return requeue, err
197197
}
198198

199199
newStatus := ironicConf.Status.DeepCopy()
@@ -208,7 +208,7 @@ func (r *IronicReconciler) handleIronic(cctx ironic.ControllerContext, ironicCon
208208
ironicConf.Status = *newStatus
209209
err = cctx.Client.Status().Update(cctx.Context, ironicConf)
210210
}
211-
return
211+
return requeue, err
212212
}
213213

214214
// Get a secret and update its owner references using SecretManager.
@@ -274,7 +274,7 @@ func (r *IronicReconciler) ensureAPISecret(cctx ironic.ControllerContext, ironic
274274
}
275275

276276
requeue = true
277-
return
277+
return apiSecret, requeue, err
278278
}
279279

280280
apiSecret, requeue, err = r.getAndUpdateSecret(cctx, ironicConf, ironicConf.Spec.APICredentialsName)
@@ -292,7 +292,7 @@ func (r *IronicReconciler) ensureAPISecret(cctx ironic.ControllerContext, ironic
292292
err = cctx.Client.Update(cctx.Context, apiSecret)
293293
}
294294

295-
return
295+
return apiSecret, requeue, err
296296
}
297297

298298
func (r *IronicReconciler) cleanUp(cctx ironic.ControllerContext, ironicConf *metal3api.Ironic) (bool, error) {

pkg/ironic/containers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func databaseClientMounts(db *metal3api.Database) (volumes []corev1.Volume, moun
350350
})
351351
}
352352

353-
return
353+
return volumes, mounts
354354
}
355355

356356
func buildIronicVolumesAndMounts(resources Resources) (volumes []corev1.Volume, mounts []corev1.VolumeMount) {
@@ -464,7 +464,7 @@ func buildIronicVolumesAndMounts(resources Resources) (volumes []corev1.Volume,
464464
mounts = append(mounts, dbMounts...)
465465
}
466466

467-
return
467+
return volumes, mounts
468468
}
469469

470470
func buildIronicHttpdPorts(ironic *metal3api.Ironic) (ironicPorts []corev1.ContainerPort, httpdPorts []corev1.ContainerPort) {
@@ -498,7 +498,7 @@ func buildIronicHttpdPorts(ironic *metal3api.Ironic) (ironicPorts []corev1.Conta
498498
}
499499
}
500500

501-
return
501+
return ironicPorts, httpdPorts
502502
}
503503

504504
func buildDHCPRange(dhcp *metal3api.DHCP) string {

pkg/ironic/ironic.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,12 @@ func removeIronicDeployment(cctx ControllerContext, ironic *metal3api.Ironic) er
180180
func EnsureIronic(cctx ControllerContext, resources Resources) (status Status, err error) {
181181
if validationErr := ValidateIronic(&resources.Ironic.Spec, nil); validationErr != nil {
182182
status = Status{Fatal: validationErr}
183-
return //nolint:nilerr // validation errors are reported in status, not as return error
183+
return status, nil //nolint:nilerr // validation errors are reported in status, not as return error
184184
}
185185

186186
if validationErr := checkVersion(resources, cctx.VersionInfo.InstalledVersion); validationErr != nil {
187187
status = Status{Fatal: validationErr}
188-
return //nolint:nilerr // validation errors are reported in status, not as return error
188+
return status, nil //nolint:nilerr // validation errors are reported in status, not as return error
189189
}
190190

191191
if resources.Ironic.Spec.Database != nil {
@@ -199,19 +199,19 @@ func EnsureIronic(cctx ControllerContext, resources Resources) (status Status, e
199199
if resources.Ironic.Spec.HighAvailability {
200200
err = removeIronicDeployment(cctx, resources.Ironic)
201201
if err != nil {
202-
return
202+
return status, err
203203
}
204204
status, err = ensureIronicDaemonSet(cctx, resources)
205205
} else {
206206
err = removeIronicDaemonSet(cctx, resources.Ironic)
207207
if err != nil {
208-
return
208+
return status, err
209209
}
210210
status, err = ensureIronicDeployment(cctx, resources)
211211
}
212212

213213
if err != nil || status.IsError() {
214-
return
214+
return status, err
215215
}
216216

217217
// Let the service be created while Ironic is being deployed, but do
@@ -235,7 +235,7 @@ func EnsureIronic(cctx ControllerContext, resources Resources) (status Status, e
235235
return smStatus, err
236236
}
237237

238-
return
238+
return status, err
239239
}
240240

241241
// RemoveIronic removes all bits of the Ironic deployment.

pkg/ironic/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func NewVersionInfo(ironicImages metal3api.Images, ironicVersion string, databas
7171
result.MariaDBImage = defaultMariaDBImage
7272
}
7373

74-
return
74+
return result, nil
7575
}
7676

7777
// Takes VersionInfo with defaults from the configuration and applies any overrides from the Ironic object.

0 commit comments

Comments
 (0)