Skip to content

Commit d6cb733

Browse files
JustinKuliopenshift-ci[bot]
authored andcommitted
Fix gosec:G104
Signed-off-by: Justin Kulikauskas <[email protected]>
1 parent b07a057 commit d6cb733

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

controllers/templatesync/template_sync.go

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ func (r *PolicyReconciler) Reconcile(ctx context.Context, request reconcile.Requ
263263
resultError = err
264264
errMsg := fmt.Sprintf("Failed to decode policy template with err: %s", err)
265265

266-
//nolint:errcheck // it will already be requeued for the resultError.
267-
r.emitTemplateError(ctx, instance, tIndex, fmt.Sprintf("[template %v]", tIndex), false, errMsg)
266+
_ = r.emitTemplateError(ctx, instance, tIndex, fmt.Sprintf("[template %v]", tIndex), false, errMsg)
267+
268268
reqLogger.Error(resultError, "Failed to decode the policy template", "templateIndex", tIndex)
269269

270270
policyUserErrorsCounter.WithLabelValues(instance.Name, "", "format-error").Inc()
@@ -312,9 +312,9 @@ func (r *PolicyReconciler) Reconcile(ctx context.Context, request reconcile.Requ
312312
resultError = fmt.Errorf("dependency on %s has conflicting compliance states", dep.Name)
313313
errMsg := fmt.Sprintf("Failed to decode policy template with err: %s", resultError)
314314

315-
//nolint:errcheck // it will already be requeued for the resultError.
316-
r.emitTemplateError(ctx, instance, tIndex,
315+
_ = r.emitTemplateError(ctx, instance, tIndex,
317316
fmt.Sprintf("[template %v]", tIndex), isClusterScoped, errMsg)
317+
318318
reqLogger.Error(resultError, "Failed to decode the policy template", "templateIndex", tIndex)
319319

320320
depConflictErr = true
@@ -342,8 +342,9 @@ func (r *PolicyReconciler) Reconcile(ctx context.Context, request reconcile.Requ
342342
errMsg := fmt.Sprintf("Failed to get name from policy template at index %v", tIndex)
343343
resultError = k8serrors.NewBadRequest(errMsg)
344344

345-
//nolint:errcheck // it will already be requeued for the resultError.
346-
r.emitTemplateError(ctx, instance, tIndex, fmt.Sprintf("[template %v]", tIndex), isClusterScoped, errMsg)
345+
_ = r.emitTemplateError(ctx, instance, tIndex,
346+
fmt.Sprintf("[template %v]", tIndex), isClusterScoped, errMsg)
347+
347348
reqLogger.Error(resultError, "Failed to process the policy template", "templateIndex", tIndex)
348349

349350
policyUserErrorsCounter.WithLabelValues(instance.Name, "", "format-error").Inc()
@@ -372,8 +373,8 @@ func (r *PolicyReconciler) Reconcile(ctx context.Context, request reconcile.Requ
372373

373374
errMsg += fmt.Sprintf(": %s", err)
374375

375-
//nolint:errcheck // it will already be requeued for the resultError.
376-
r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
376+
_ = r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
377+
377378
tLogger.Error(err, "Could not find an API mapping for the object definition",
378379
"group", gvk.Group,
379380
"version", gvk.Version,
@@ -421,8 +422,8 @@ func (r *PolicyReconciler) Reconcile(ctx context.Context, request reconcile.Requ
421422

422423
resultError = err
423424

424-
//nolint:errcheck // it will already be requeued for the resultError.
425-
r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
425+
_ = r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
426+
426427
tLogger.Error(err, "Unsupported policy-template kind found in object definition",
427428
"group", gvk.Group,
428429
"version", gvk.Version,
@@ -442,8 +443,8 @@ func (r *PolicyReconciler) Reconcile(ctx context.Context, request reconcile.Requ
442443
errMsg := fmt.Sprintf("Templates are not supported for kind : %s", gvk.Kind)
443444
resultError = k8serrors.NewBadRequest(errMsg)
444445

445-
//nolint:errcheck // it will already be requeued for the resultError.
446-
r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
446+
_ = r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
447+
447448
tLogger.Error(resultError, "Failed to process the policy template")
448449

449450
policyUserErrorsCounter.WithLabelValues(instance.Name, tName, "format-error").Inc()
@@ -472,8 +473,8 @@ func (r *PolicyReconciler) Reconcile(ctx context.Context, request reconcile.Requ
472473
resultError = err
473474
errMsg := fmt.Sprintf("Failed to unmarshal the policy template: %s", err)
474475

475-
//nolint:errcheck // it will already be requeued for the resultError.
476-
r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
476+
_ = r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
477+
477478
tLogger.Error(resultError, "Failed to unmarshal the policy template")
478479

479480
policySystemErrorsCounter.WithLabelValues(instance.Name, tName, "unmarshal-error").Inc()
@@ -546,8 +547,8 @@ func (r *PolicyReconciler) Reconcile(ctx context.Context, request reconcile.Requ
546547
resultError = err
547548
errMsg := fmt.Sprintf("Failed to create policy template: %s", err)
548549

549-
//nolint:errcheck // it will already be requeued for the resultError.
550-
r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
550+
_ = r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
551+
551552
tLogger.Error(resultError, "Failed to create policy template")
552553

553554
policySystemErrorsCounter.WithLabelValues(instance.Name, tName, "create-error").Inc()
@@ -595,8 +596,8 @@ func (r *PolicyReconciler) Reconcile(ctx context.Context, request reconcile.Requ
595596
resultError = err
596597
errMsg := fmt.Sprintf("Failed to get the object in the policy template: %s", err)
597598

598-
//nolint:errcheck // it will already be requeued for the resultError.
599-
r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
599+
_ = r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
600+
600601
tLogger.Error(err, "Failed to get the object in the policy template",
601602
"namespace", instance.GetNamespace(),
602603
"kind", gvk.Kind,
@@ -692,8 +693,8 @@ func (r *PolicyReconciler) Reconcile(ctx context.Context, request reconcile.Requ
692693

693694
resultError = k8serrors.NewBadRequest(errMsg)
694695

695-
//nolint:errcheck // it will already be requeued for the resultError.
696-
r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
696+
_ = r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
697+
697698
tLogger.Error(resultError, "Failed to create the policy template")
698699

699700
policyUserErrorsCounter.WithLabelValues(instance.Name, tName, "format-error").Inc()
@@ -739,8 +740,8 @@ func (r *PolicyReconciler) Reconcile(ctx context.Context, request reconcile.Requ
739740
resultError = err
740741
errMsg := fmt.Sprintf("Failed to update policy template %s: %s", tName, err)
741742

742-
//nolint:errcheck // it will already be requeued for the resultError.
743-
r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
743+
_ = r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
744+
744745
tLogger.Error(err, "Failed to update the policy template")
745746

746747
policySystemErrorsCounter.WithLabelValues(instance.Name, tName, "patch-error").Inc()

0 commit comments

Comments
 (0)