From 947a80e00f342397353bcc36e219467d8a21ac18 Mon Sep 17 00:00:00 2001 From: jwcesign Date: Tue, 2 Jan 2024 19:27:43 +0800 Subject: [PATCH] cleanup: enable revive(var-naming rule) checking Signed-off-by: jwcesign --- .golangci.yml | 1 + pkg/controllers/status/work_status_controller_test.go | 8 ++++---- pkg/dependenciesdistributor/dependencies_distributor.go | 6 +++--- pkg/util/proxy/upgrade_dialer.go | 6 +++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index b0547801c..5899873b9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -83,6 +83,7 @@ linters-settings: - name: blank-imports - name: indent-error-flow - name: unreachable-code + - name: var-naming staticcheck: checks: - all diff --git a/pkg/controllers/status/work_status_controller_test.go b/pkg/controllers/status/work_status_controller_test.go index bea94a9b3..ba20fe19a 100644 --- a/pkg/controllers/status/work_status_controller_test.go +++ b/pkg/controllers/status/work_status_controller_test.go @@ -910,12 +910,12 @@ func TestWorkStatusController_buildStatusIdentifier(t *testing.T) { Status: clusterv1alpha1.ClusterStatus{}, } clusterObj, _ := helper.ToUnstructured(cluster) - clusterJson, _ := json.Marshal(clusterObj) + clusterJSON, _ := json.Marshal(clusterObj) t.Run("normal case", func(t *testing.T) { work.Spec.Workload.Manifests = []workv1alpha1.Manifest{ { - RawExtension: runtime.RawExtension{Raw: clusterJson}, + RawExtension: runtime.RawExtension{Raw: clusterJSON}, }, } idf, err := c.buildStatusIdentifier(work, clusterObj) @@ -925,10 +925,10 @@ func TestWorkStatusController_buildStatusIdentifier(t *testing.T) { t.Run("failed to GetManifestIndex", func(t *testing.T) { wrongClusterObj, _ := helper.ToUnstructured(newCluster("cluster", clusterv1alpha1.ClusterConditionReady, metav1.ConditionTrue)) - wrongClusterJson, _ := json.Marshal(wrongClusterObj) + wrongClusterJSON, _ := json.Marshal(wrongClusterObj) work.Spec.Workload.Manifests = []workv1alpha1.Manifest{ { - RawExtension: runtime.RawExtension{Raw: wrongClusterJson}, + RawExtension: runtime.RawExtension{Raw: wrongClusterJSON}, }, } idf, err := c.buildStatusIdentifier(work, clusterObj) diff --git a/pkg/dependenciesdistributor/dependencies_distributor.go b/pkg/dependenciesdistributor/dependencies_distributor.go index 5e25470ac..e533186da 100644 --- a/pkg/dependenciesdistributor/dependencies_distributor.go +++ b/pkg/dependenciesdistributor/dependencies_distributor.go @@ -62,8 +62,8 @@ import ( ) const ( - // bindingDependedIdLabelKey is the resource id of the independent binding which the attached binding depends on. - bindingDependedIdLabelKey = "resourcebinding.karmada.io/depended-id" + // bindingDependedIDLabelKey is the resource id of the independent binding which the attached binding depends on. + bindingDependedIDLabelKey = "resourcebinding.karmada.io/depended-id" // bindingDependedByLabelKeyPrefix is the prefix to a label key specifying an attached binding referred by which independent binding. // the key is in the label of an attached binding which should be unique, because resource like secret can be referred by multiple deployments. @@ -658,7 +658,7 @@ func buildAttachedBinding(binding *workv1alpha2.ResourceBinding, object *unstruc }) policyID := util.GetLabelValue(binding.Labels, workv1alpha2.ResourceBindingPermanentIDLabel) - dependedLabels = util.DedupeAndMergeLabels(dependedLabels, map[string]string{bindingDependedIdLabelKey: policyID}) + dependedLabels = util.DedupeAndMergeLabels(dependedLabels, map[string]string{bindingDependedIDLabelKey: policyID}) return &workv1alpha2.ResourceBinding{ ObjectMeta: metav1.ObjectMeta{ Name: names.GenerateBindingName(object.GetKind(), object.GetName()), diff --git a/pkg/util/proxy/upgrade_dialer.go b/pkg/util/proxy/upgrade_dialer.go index 4dea5d077..d8be0a8a2 100644 --- a/pkg/util/proxy/upgrade_dialer.go +++ b/pkg/util/proxy/upgrade_dialer.go @@ -120,14 +120,14 @@ func (u *UpgradeDialer) dial(req *http.Request) (net.Conn, error) { case "socks5": return u.dialWithSocks5Proxy(req, proxyURL) case "https", "http", "": - return u.dialWithHttpProxy(req, proxyURL) + return u.dialWithHTTPProxy(req, proxyURL) } return nil, fmt.Errorf("proxy URL scheme not supported: %s", proxyURL.Scheme) } -// dialWithHttpProxy dials the host specified by url through an http or an https proxy. -func (u *UpgradeDialer) dialWithHttpProxy(req *http.Request, proxyURL *url.URL) (net.Conn, error) { +// dialWithHTTPProxy dials the host specified by url through an http or an https proxy. +func (u *UpgradeDialer) dialWithHTTPProxy(req *http.Request, proxyURL *url.URL) (net.Conn, error) { // ensure we use a canonical host with proxyReq targetHost := netutil.CanonicalAddr(req.URL)