This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Updates golangci-lint #635
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ linters: | |
enable: | ||
- asciicheck | ||
- bodyclose | ||
- depguard | ||
- errorlint | ||
- gofmt | ||
- goimports | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused |
||
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 { | ||
|
@@ -193,6 +192,10 @@ func (c *controller) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu | |
return res, reconcileErr | ||
} | ||
|
||
// nolint:unparam | ||
// Today we always return ctrl.Result{} and an error. | ||
// But in the future we might update this function | ||
// to return different results (e.g. requeue). | ||
func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDeployment) (ctrl.Result, error) { | ||
bd.Status.ObservedGeneration = bd.Generation | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New was shadowing built-in |
||
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 | ||
}, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and in other places with |
||
// 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. | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and in
internal/controllers/bundledeployment/bundledeployment.go
we always return an empty value inctrl.Result{}
. It makes sense inReconcile
to satisfy the interface, but not in this unexported func.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I agree with this change. If we ever do want to return something other than
ctrl.Result{}
, it'll likely be coming fromreconcile()
, notReconcile()
.I'd be slightly worried that our future selves would be less inclined to change the return values back to
(ctrl.Result, error)
and would instead do something less desirable overall.The primary purpose of this split is to make us not really have to think at all about status updating. The result is merely passed through.
Is a linter complaining about this? If so, WDYT about applying the
//nolint:<whatever>
label with an explanation along these lines.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joelanford I also was not super happy about this linting issue at first, but ended up obeying because I convinced myself that the code is not set in stone. It is super easy to add a new return param once we have a need for it (especially since this is not an exported method).
To me it is the same as adding input arguments into a function: we usually add new args as the need for them arises. There are exceptions (e.g. designing a public interfaces where signature changes are more painful), but it is not the case here.
But I can look into either adding nolint or disabling this linting rule altogether tomorrow. I am not a big fan of inline linting exceptions, but also do not have very strong objections against them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated: added
//nolint:unparam
to both