Skip to content

Commit c72a218

Browse files
committed
fix errcheck linter
Signed-off-by: Tim Ramlot <[email protected]>
1 parent 4a3ccc1 commit c72a218

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

.golangci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ linters:
66
presets: [comments, common-false-positives, legacy, std-error-handling]
77
rules:
88
- linters:
9-
- errcheck
109
- errchkjson
1110
- forbidigo
1211
- gocritic

pkg/agent/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func InitAgentCmdFlags(c *cobra.Command, cfg *AgentCmdFlags) {
232232
false,
233233
fmt.Sprintf("Turns on the %s mode. The flag --credentials-file must also be passed.", JetstackSecureOAuth),
234234
)
235-
c.PersistentFlags().MarkHidden("venafi-cloud")
235+
_ = c.PersistentFlags().MarkHidden("venafi-cloud")
236236
c.PersistentFlags().StringVarP(
237237
&cfg.ClientID,
238238
"client-id",
@@ -334,7 +334,7 @@ func InitAgentCmdFlags(c *cobra.Command, cfg *AgentCmdFlags) {
334334
false,
335335
"Deprecated. No longer has an effect.",
336336
)
337-
c.PersistentFlags().MarkDeprecated("disable-compression", "no longer has an effect")
337+
_ = c.PersistentFlags().MarkDeprecated("disable-compression", "no longer has an effect")
338338

339339
// This is a hidden feature flag we use to build the "Machine Hub" feature
340340
// gradually without impacting customers. Once the feature is GA, we will
@@ -345,7 +345,7 @@ func InitAgentCmdFlags(c *cobra.Command, cfg *AgentCmdFlags) {
345345
false,
346346
"Enables the MachineHub mode. The agent will push data to CyberArk MachineHub.",
347347
)
348-
c.PersistentFlags().MarkHidden("machine-hub")
348+
_ = c.PersistentFlags().MarkHidden("machine-hub")
349349

350350
}
351351

pkg/datagatherer/k8s/dynamic.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,15 @@ func redactList(list []*api.GatheredResource, excludeAnnotKeys, excludeLabelKeys
371371
for _, gvk := range gvks {
372372
// secret object
373373
if gvk.Kind == "Secret" && (gvk.Group == "core" || gvk.Group == "") {
374-
Select(SecretSelectedFields, resource)
374+
if err := Select(SecretSelectedFields, resource); err != nil {
375+
return err
376+
}
375377

376378
// route object
377379
} else if gvk.Kind == "Route" && gvk.Group == "route.openshift.io" {
378-
Select(RouteSelectedFields, resource)
380+
if err := Select(RouteSelectedFields, resource); err != nil {
381+
return err
382+
}
379383
}
380384
}
381385

pkg/datagatherer/k8s/dynamic_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ func TestDynamicGatherer_Fetch(t *testing.T) {
667667
factory := dynamicinformer.NewFilteredDynamicSharedInformerFactory(cl, 10*time.Minute, metav1.NamespaceAll, nil)
668668
resourceInformer := factory.ForResource(tc.config.GroupVersionResource)
669669
testInformer := resourceInformer.Informer()
670-
testInformer.AddEventHandler(k8scache.ResourceEventHandlerFuncs{
670+
_, err = testInformer.AddEventHandler(k8scache.ResourceEventHandlerFuncs{
671671
DeleteFunc: func(obj interface{}) {
672672
defer wg.Done()
673673
time.Sleep(100 * time.Millisecond)
@@ -677,6 +677,7 @@ func TestDynamicGatherer_Fetch(t *testing.T) {
677677
time.Sleep(100 * time.Millisecond)
678678
},
679679
})
680+
require.NoError(t, err)
680681
//start test Informer
681682
factory.Start(ctx.Done())
682683
k8scache.WaitForCacheSync(ctx.Done(), testInformer.HasSynced)
@@ -983,7 +984,7 @@ func TestDynamicGathererNativeResources_Fetch(t *testing.T) {
983984
informers.WithNamespace(metav1.NamespaceAll),
984985
informers.WithTweakListOptions(func(options *metav1.ListOptions) {}))
985986
testInformer := factory.Core().V1().Pods().Informer()
986-
testInformer.AddEventHandler(k8scache.ResourceEventHandlerFuncs{
987+
_, err = testInformer.AddEventHandler(k8scache.ResourceEventHandlerFuncs{
987988
DeleteFunc: func(obj interface{}) {
988989
defer wg.Done()
989990
time.Sleep(100 * time.Millisecond)
@@ -993,6 +994,7 @@ func TestDynamicGathererNativeResources_Fetch(t *testing.T) {
993994
time.Sleep(100 * time.Millisecond)
994995
},
995996
})
997+
require.NoError(t, err)
996998

997999
//start test Informer
9981000
factory.Start(ctx.Done())

pkg/datagatherer/k8s/fieldfilter.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ func Select(fields []FieldPath, resource *unstructured.Unstructured) error {
8080
}
8181

8282
// Redact removes the supplied fields from the resource
83-
func Redact(fields []FieldPath, resource *unstructured.Unstructured) error {
83+
func Redact(fields []FieldPath, resource *unstructured.Unstructured) {
8484
for _, field := range fields {
8585
unstructured.RemoveNestedField(resource.Object, field...)
8686
}
87-
88-
return nil
8987
}

pkg/datagatherer/k8s/fieldfilter_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ func TestRedactSecret(t *testing.T) {
175175
{"data", "tls.key"},
176176
}
177177

178-
err := Redact(fieldsToRedact, resource)
179-
require.NoError(t, err)
178+
Redact(fieldsToRedact, resource)
180179

181180
bytes, err := json.MarshalIndent(resource, "", " ")
182181
require.NoError(t, err)
@@ -217,8 +216,7 @@ func TestRedactPod(t *testing.T) {
217216
{"metadata", "managedFields"},
218217
}
219218

220-
err := Redact(fieldsToRedact, resource)
221-
require.NoError(t, err)
219+
Redact(fieldsToRedact, resource)
222220

223221
bytes, err := json.MarshalIndent(resource, "", " ")
224222
require.NoError(t, err)
@@ -248,8 +246,7 @@ func TestRedactMissingField(t *testing.T) {
248246
{"missing"},
249247
}
250248

251-
err := Redact(fieldsToRedact, resource)
252-
require.NoError(t, err)
249+
Redact(fieldsToRedact, resource)
253250
bytes, err := json.MarshalIndent(resource, "", " ")
254251
require.NoError(t, err)
255252

pkg/logs/logs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func AddFlags(fs *pflag.FlagSet) {
7777
features.AddFlag(&tfs)
7878
tfs.VisitAll(func(f *pflag.Flag) {
7979
if !visibleFlagNames.Has(f.Name) {
80-
tfs.MarkHidden(f.Name)
80+
_ = tfs.MarkHidden(f.Name)
8181
}
8282

8383
// The original usage string includes details about how

pkg/testutil/envtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func FakeVenafiCloud(t *testing.T) (_ *httptest.Server, _ *x509.Certificate, set
203203
apiKey := r.Header.Get("Tppl-Api-Key")
204204
if accessToken != "VALID_ACCESS_TOKEN" && apiKey != "VALID_API_KEY" {
205205
w.WriteHeader(http.StatusUnauthorized)
206-
w.Write([]byte(`{"error":"expected header 'Authorization: Bearer VALID_ACCESS_TOKEN' or 'tppl-api-key: VALID_API_KEY', but got Authorization=` + r.Header.Get("Authorization") + ` and tppl-api-key=` + r.Header.Get("Tppl-Api-Key")))
206+
_, _ = w.Write([]byte(`{"error":"expected header 'Authorization: Bearer VALID_ACCESS_TOKEN' or 'tppl-api-key: VALID_API_KEY', but got Authorization=` + r.Header.Get("Authorization") + ` and tppl-api-key=` + r.Header.Get("Tppl-Api-Key")))
207207
return
208208
}
209209
if r.URL.Path == "/v1/tlspk/upload/clusterdata/no" {

0 commit comments

Comments
 (0)