Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
Fixes linting issues
Browse files Browse the repository at this point in the history
Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
  • Loading branch information
m1kola committed Jun 15, 2023
1 parent 500ee17 commit 0be74b0
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 21 deletions.
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ linters:
enable:
- asciicheck
- bodyclose
- depguard
- errorlint
- gofmt
- goimports
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (c *controller) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
return res, reconcileErr
}

func (c *controller) reconcile(ctx context.Context, bundle *rukpakv1alpha1.Bundle) (ctrl.Result, error) {
func (c *controller) reconcile(ctx context.Context, bundle *rukpakv1alpha1.Bundle) (ctrl.Result, error) { //nolint:unparam
bundle.Status.ObservedGeneration = bundle.Generation

finalizedBundle := bundle.DeepCopy()
Expand Down
5 changes: 2 additions & 3 deletions internal/controllers/bundledeployment/bundledeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,13 @@ func SetupWithManager(mgr manager.Manager, opts ...Option) error {
}

controllerName := fmt.Sprintf("controller.bundledeployment.%s", c.provisionerID)
l := mgr.GetLogger().WithName(controllerName)
controller, err := ctrl.NewControllerManagedBy(mgr).
Named(controllerName).
For(&rukpakv1alpha1.BundleDeployment{}, builder.WithPredicates(
util.BundleDeploymentProvisionerFilter(c.provisionerID)),
).
Watches(&source.Kind{Type: &rukpakv1alpha1.Bundle{}}, handler.EnqueueRequestsFromMapFunc(
util.MapBundleToBundleDeploymentHandler(context.Background(), mgr.GetClient(), l, c.provisionerID)),
util.MapBundleToBundleDeploymentHandler(context.Background(), mgr.GetClient(), c.provisionerID)),
).
Build(c)
if err != nil {
Expand Down Expand Up @@ -193,7 +192,7 @@ func (c *controller) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
return res, reconcileErr
}

func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDeployment) (ctrl.Result, error) {
func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDeployment) (ctrl.Result, error) { //nolint:unparam
bd.Status.ObservedGeneration = bd.Generation

bundle, allBundles, err := util.ReconcileDesiredBundle(ctx, c.cl, bd)
Expand Down
16 changes: 8 additions & 8 deletions internal/helm-operator-plugins/predicate/depedent.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ func DependentPredicateFuncs() crtpredicate.Funcs {
// necessary. Ignore updates that only change the status and
// resourceVersion.
UpdateFunc: func(e event.UpdateEvent) bool {
old := e.ObjectOld.(*unstructured.Unstructured).DeepCopy()
new := e.ObjectNew.(*unstructured.Unstructured).DeepCopy()
oldObj := e.ObjectOld.(*unstructured.Unstructured).DeepCopy()
newObj := e.ObjectNew.(*unstructured.Unstructured).DeepCopy()

delete(old.Object, "status")
delete(new.Object, "status")
old.SetResourceVersion("")
new.SetResourceVersion("")
delete(oldObj.Object, "status")
delete(newObj.Object, "status")
oldObj.SetResourceVersion("")
newObj.SetResourceVersion("")

if reflect.DeepEqual(old.Object, new.Object) {
if reflect.DeepEqual(oldObj.Object, newObj.Object) {
return false
}
log.V(1).Info("Reconciling due to dependent resource update", "name", new.GetName(), "namespace", new.GetNamespace(), "apiVersion", new.GroupVersionKind().GroupVersion(), "kind", new.GroupVersionKind().Kind)
log.V(1).Info("Reconciling due to dependent resource update", "name", newObj.GetName(), "namespace", newObj.GetNamespace(), "apiVersion", newObj.GroupVersionKind().GroupVersion(), "kind", newObj.GroupVersionKind().Kind)
return true
},
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provisioner/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
ProvisionerID = "core-rukpak-io-helm"
)

func HandleBundle(ctx context.Context, fsys fs.FS, bundle *rukpakv1alpha1.Bundle) (fs.FS, error) {
func HandleBundle(_ context.Context, fsys fs.FS, _ *rukpakv1alpha1.Bundle) (fs.FS, error) {
// Helm expects an FS whose root contains a single chart directory. Depending on how
// the bundle is sourced, the FS may or may not contain this single chart directory in
// its root (e.g. charts uploaded via 'rukpakctl run <bdName> <chartDir>') would not.
Expand All @@ -37,7 +37,7 @@ func HandleBundle(ctx context.Context, fsys fs.FS, bundle *rukpakv1alpha1.Bundle
return chartFS, nil
}

func HandleBundleDeployment(ctx context.Context, fsys fs.FS, bd *rukpakv1alpha1.BundleDeployment) (*chart.Chart, chartutil.Values, error) {
func HandleBundleDeployment(_ context.Context, fsys fs.FS, bd *rukpakv1alpha1.BundleDeployment) (*chart.Chart, chartutil.Values, error) {
values, err := loadValues(bd)
if err != nil {
return nil, nil, err
Expand Down
2 changes: 1 addition & 1 deletion internal/source/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,6 @@ func (d *billyDirFile) ReadDir(n int) ([]fs.DirEntry, error) {
return entries[:n], err
}

func (d billyDirFile) Read(data []byte) (int, error) {
func (d billyDirFile) Read(_ []byte) (int, error) {
return 0, &fs.PathError{Op: "read", Path: d.path, Err: syscall.EISDIR}
}
5 changes: 1 addition & 4 deletions internal/util/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,5 @@ func FSToTarGZ(w io.Writer, fsys fs.FS) error {
if err := tw.Close(); err != nil {
return err
}
if err := gzw.Close(); err != nil {
return err
}
return nil
return gzw.Close()
}
2 changes: 1 addition & 1 deletion internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func MapBundleToBundleDeployment(ctx context.Context, c client.Client, b rukpakv
// standalone resource, then no BundleDeployment will be returned as static creation of Bundle
// resources is not a supported workflow right now. The provisionerClassName parameter is used
// to filter out BundleDeployments that the caller shouldn't be watching.
func MapBundleToBundleDeploymentHandler(ctx context.Context, cl client.Client, log logr.Logger, provisionerClassName string) handler.MapFunc {
func MapBundleToBundleDeploymentHandler(ctx context.Context, cl client.Client, provisionerClassName string) handler.MapFunc {
return func(object client.Object) []reconcile.Request {
b := object.(*rukpakv1alpha1.Bundle)

Expand Down

0 comments on commit 0be74b0

Please sign in to comment.